Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [rfa] delete macro SYMBOL_LINKAGE_NAME
@ 2003-01-21  0:58 David Carlton
  2003-02-03 18:30 ` Elena Zannoni
  0 siblings, 1 reply; 5+ messages in thread
From: David Carlton @ 2003-01-21  0:58 UTC (permalink / raw)
  To: gdb-patches; +Cc: Elena Zannoni, Jim Blandy

This is the first part of my plan to clean up symbol accessors.  It
deletes the macro SYMBOL_LINKAGE_NAME: that macro is only used in two
places in one function, and is easy to replace by an equivalent use of
asm_demangle, SYMBOL_SOURCE_NAME, and SYMBOL_NAME.  Given that I'd
like to use the name SYMBOL_LINKAGE_NAME for something else, I'd like
to get rid of its current use.

Tested on i686-pc-linux-gnu/GCC3.1/DWARF-2 (and seems obviously
correct by inspection, assuming that you agree that its goal is
valid).  OK to commit?

David Carlton
carlton@math.stanford.edu

2003-01-20  David Carlton  <carlton@math.stanford.edu>

	* symtab.h (SYMBOL_LINKAGE_NAME): Delete.
	* printcmd.c (build_address_symbolic): Replace uses of
	SYMBOL_LINKAGE_NAME by equivalent uses of SYMBOL_SOURCE_NAME,
	SYMBOL_NAME, and asm_demangle.
	Update copyright.

Index: symtab.h
===================================================================
RCS file: /cvs/src/src/gdb/symtab.h,v
retrieving revision 1.55
diff -u -p -r1.55 symtab.h
--- symtab.h	19 Jan 2003 04:06:46 -0000	1.55
+++ symtab.h	21 Jan 2003 00:18:36 -0000
@@ -172,17 +172,6 @@ extern char *symbol_demangled_name (stru
    ? SYMBOL_DEMANGLED_NAME (symbol)					\
    : SYMBOL_NAME (symbol))
 
-/* Macro that returns the "natural assembly name" of a symbol.  In C++ this is
-   the "mangled" form of the name if demangle is off, or if demangle is on and
-   asm_demangle is off.  Otherwise if asm_demangle is on it is the "demangled"
-   form.  In other languages this is just the symbol name.  The result should
-   never be NULL. */
-
-#define SYMBOL_LINKAGE_NAME(symbol)					\
-  (demangle && asm_demangle && SYMBOL_DEMANGLED_NAME (symbol) != NULL	\
-   ? SYMBOL_DEMANGLED_NAME (symbol)					\
-   : SYMBOL_NAME (symbol))
-
 /* Macro that tests a symbol for a match against a specified name string.
    First test the unencoded name, then looks for and test a C++ encoded
    name if it exists.  Note that whitespace is ignored while attempting to
Index: printcmd.c
===================================================================
RCS file: /cvs/src/src/gdb/printcmd.c,v
retrieving revision 1.50
diff -u -p -r1.50 printcmd.c
--- printcmd.c	21 Nov 2002 18:54:44 -0000	1.50
+++ printcmd.c	21 Jan 2003 00:56:47 -0000
@@ -1,7 +1,7 @@
 /* Print values for GNU debugger GDB.
 
    Copyright 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994,
-   1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002 Free Software
+   1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003 Free Software
    Foundation, Inc.
 
    This file is part of GDB.
@@ -639,10 +639,10 @@ build_address_symbolic (CORE_ADDR addr, 
   if (symbol)
     {
       name_location = BLOCK_START (SYMBOL_BLOCK_VALUE (symbol));
-      if (do_demangle)
+      if (do_demangle || asm_demangle)
 	name_temp = SYMBOL_SOURCE_NAME (symbol);
       else
-	name_temp = SYMBOL_LINKAGE_NAME (symbol);
+	name_temp = SYMBOL_NAME (symbol);
     }
 
   if (msymbol != NULL)
@@ -654,10 +654,10 @@ build_address_symbolic (CORE_ADDR addr, 
 	  symbol = 0;
 	  symtab = 0;
 	  name_location = SYMBOL_VALUE_ADDRESS (msymbol);
-	  if (do_demangle)
+	  if (do_demangle || asm_demangle)
 	    name_temp = SYMBOL_SOURCE_NAME (msymbol);
 	  else
-	    name_temp = SYMBOL_LINKAGE_NAME (msymbol);
+	    name_temp = SYMBOL_NAME (msymbol);
 	}
     }
   if (symbol == NULL && msymbol == NULL)


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [rfa] delete macro SYMBOL_LINKAGE_NAME
  2003-01-21  0:58 [rfa] delete macro SYMBOL_LINKAGE_NAME David Carlton
@ 2003-02-03 18:30 ` Elena Zannoni
  2003-02-03 18:41   ` David Carlton
  0 siblings, 1 reply; 5+ messages in thread
From: Elena Zannoni @ 2003-02-03 18:30 UTC (permalink / raw)
  To: David Carlton; +Cc: gdb-patches, Elena Zannoni, Jim Blandy

David Carlton writes:
 > This is the first part of my plan to clean up symbol accessors.  It
 > deletes the macro SYMBOL_LINKAGE_NAME: that macro is only used in two
 > places in one function, and is easy to replace by an equivalent use of
 > asm_demangle, SYMBOL_SOURCE_NAME, and SYMBOL_NAME.  Given that I'd
 > like to use the name SYMBOL_LINKAGE_NAME for something else, I'd like
 > to get rid of its current use.
 > 

can you expand a bit?

 > Tested on i686-pc-linux-gnu/GCC3.1/DWARF-2 (and seems obviously
 > correct by inspection, assuming that you agree that its goal is
 > valid).  OK to commit?
 > 

Ok in theory, but I don't understand something, see below.


 > David Carlton
 > carlton@math.stanford.edu
 > 
 > 2003-01-20  David Carlton  <carlton@math.stanford.edu>
 > 
 > 	* symtab.h (SYMBOL_LINKAGE_NAME): Delete.
 > 	* printcmd.c (build_address_symbolic): Replace uses of
 > 	SYMBOL_LINKAGE_NAME by equivalent uses of SYMBOL_SOURCE_NAME,
 > 	SYMBOL_NAME, and asm_demangle.
 > 	Update copyright.
 > 
 > Index: symtab.h
 > ===================================================================
 > RCS file: /cvs/src/src/gdb/symtab.h,v
 > retrieving revision 1.55
 > diff -u -p -r1.55 symtab.h
 > --- symtab.h	19 Jan 2003 04:06:46 -0000	1.55
 > +++ symtab.h	21 Jan 2003 00:18:36 -0000
 > @@ -172,17 +172,6 @@ extern char *symbol_demangled_name (stru
 >     ? SYMBOL_DEMANGLED_NAME (symbol)					\
 >     : SYMBOL_NAME (symbol))
 >  
 > -/* Macro that returns the "natural assembly name" of a symbol.  In C++ this is
 > -   the "mangled" form of the name if demangle is off, or if demangle is on and
 > -   asm_demangle is off.  Otherwise if asm_demangle is on it is the "demangled"
 > -   form.  In other languages this is just the symbol name.  The result should
 > -   never be NULL. */
 > -
 > -#define SYMBOL_LINKAGE_NAME(symbol)					\
 > -  (demangle && asm_demangle && SYMBOL_DEMANGLED_NAME (symbol) != NULL	\
 > -   ? SYMBOL_DEMANGLED_NAME (symbol)					\
 > -   : SYMBOL_NAME (symbol))
 > -
 >  /* Macro that tests a symbol for a match against a specified name string.
 >     First test the unencoded name, then looks for and test a C++ encoded
 >     name if it exists.  Note that whitespace is ignored while attempting to
 > Index: printcmd.c
 > ===================================================================
 > RCS file: /cvs/src/src/gdb/printcmd.c,v
 > retrieving revision 1.50
 > diff -u -p -r1.50 printcmd.c
 > --- printcmd.c	21 Nov 2002 18:54:44 -0000	1.50
 > +++ printcmd.c	21 Jan 2003 00:56:47 -0000
 > @@ -1,7 +1,7 @@
 >  /* Print values for GNU debugger GDB.
 >  
 >     Copyright 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994,
 > -   1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002 Free Software
 > +   1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003 Free Software
 >     Foundation, Inc.
 >  
 >     This file is part of GDB.
 > @@ -639,10 +639,10 @@ build_address_symbolic (CORE_ADDR addr, 
 >    if (symbol)
 >      {
 >        name_location = BLOCK_START (SYMBOL_BLOCK_VALUE (symbol));
 > -      if (do_demangle)
 > +      if (do_demangle || asm_demangle)

why this change? I must be missing something.

 >  	name_temp = SYMBOL_SOURCE_NAME (symbol);
 >        else
 > -	name_temp = SYMBOL_LINKAGE_NAME (symbol);
 > +	name_temp = SYMBOL_NAME (symbol);
 >      }
 >  

this one is ok.


 >    if (msymbol != NULL)
 > @@ -654,10 +654,10 @@ build_address_symbolic (CORE_ADDR addr, 
 >  	  symbol = 0;
 >  	  symtab = 0;
 >  	  name_location = SYMBOL_VALUE_ADDRESS (msymbol);
 > -	  if (do_demangle)
 > +	  if (do_demangle || asm_demangle)
 >  	    name_temp = SYMBOL_SOURCE_NAME (msymbol);
 >  	  else
 > -	    name_temp = SYMBOL_LINKAGE_NAME (msymbol);
 > +	    name_temp = SYMBOL_NAME (msymbol);
 >  	}
 >      }
 >    if (symbol == NULL && msymbol == NULL)


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [rfa] delete macro SYMBOL_LINKAGE_NAME
  2003-02-03 18:30 ` Elena Zannoni
@ 2003-02-03 18:41   ` David Carlton
  2003-02-04 17:00     ` Elena Zannoni
  0 siblings, 1 reply; 5+ messages in thread
From: David Carlton @ 2003-02-03 18:41 UTC (permalink / raw)
  To: Elena Zannoni; +Cc: gdb-patches, Jim Blandy

On Mon, 3 Feb 2003 13:30:24 -0500, Elena Zannoni <ezannoni@redhat.com> said:
> David Carlton writes:

>> This is the first part of my plan to clean up symbol accessors.  It
>> deletes the macro SYMBOL_LINKAGE_NAME: that macro is only used in
>> two places in one function, and is easy to replace by an equivalent
>> use of asm_demangle, SYMBOL_SOURCE_NAME, and SYMBOL_NAME.  Given
>> that I'd like to use the name SYMBOL_LINKAGE_NAME for something
>> else, I'd like to get rid of its current use.

> can you expand a bit?

As I posted in
<http://sources.redhat.com/ml/gdb/2003-01/msg00188.html>, I really
think that it's important to clean up GDB's use of various names.  I
want to make it as easy as possible for people to get at either the
source code names of symbols or the linkage names of symbols, and to
make it clear when they mean the one or the other.  For the linkage
names, the best macro name that I've come up with is
SYMBOL_LINKAGE_NAME: so a not-to-distant step in this process will be
to introduce a macro SYMBOL_LINKAGE_NAME whose definition is exactly
the same as the definition of SYMBOL_NAME, but with the extra semantic
benefit that users of that macro will promise that they've actually
thought about the situation and decided that they really want the
linkage name instead of the source code name.

But to do that, I have to get rid of the existing macro
SYMBOL_LINKAGE_NAME.  (Or else think up another name, but here getting
rid of the existing macro seems preferable.)

I'm certainly open to different names for these macros, if you'd
prefer something else.  (Though I do think that getting rid of the
current SYMBOL_LINKAGE_NAME wouldn't be a bad idea, given how little
it's used.)

>> if (symbol)
>> {
>> name_location = BLOCK_START (SYMBOL_BLOCK_VALUE (symbol));
>> -      if (do_demangle)
>> +      if (do_demangle || asm_demangle)

> why this change? I must be missing something.

>> name_temp = SYMBOL_SOURCE_NAME (symbol);
>> else
>> -	name_temp = SYMBOL_LINKAGE_NAME (symbol);
>> +	name_temp = SYMBOL_NAME (symbol);
>> }

> this one is ok.

The current SYMBOL_LINKAGE_NAME (that I'm getting rid of) is
equivalent, I think, to

asm_demangle ? SYMBOL_SOURCE_NAME : SYMBOL_NAME.

So the old code

  if (do_demangle)
    name_temp = SYMBOL_SOURCE_NAME (symbol);
  else
    name_temp = SYMBOL_LINKAGE_NAME (symbol);

becomes

  if (do_demangle)
    name_temp = SYMBOL_SOURCE_NAME (symbol);
  else
    {
      if (asm_demangle)
        name_temp = SYMBOL_SOURCE_NAME (symbol);
      else
        name_temp = SYMBOL_NAME (symbol);
    }

And then I combined the first two if statements into an or statement.

David Carlton
carlton@math.stanford.edu


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [rfa] delete macro SYMBOL_LINKAGE_NAME
  2003-02-03 18:41   ` David Carlton
@ 2003-02-04 17:00     ` Elena Zannoni
  2003-02-04 21:38       ` David Carlton
  0 siblings, 1 reply; 5+ messages in thread
From: Elena Zannoni @ 2003-02-04 17:00 UTC (permalink / raw)
  To: David Carlton; +Cc: Elena Zannoni, gdb-patches, Jim Blandy

David Carlton writes:
 > On Mon, 3 Feb 2003 13:30:24 -0500, Elena Zannoni <ezannoni@redhat.com> said:
 > > David Carlton writes:
 > 
 > >> This is the first part of my plan to clean up symbol accessors.  It
 > >> deletes the macro SYMBOL_LINKAGE_NAME: that macro is only used in
 > >> two places in one function, and is easy to replace by an equivalent
 > >> use of asm_demangle, SYMBOL_SOURCE_NAME, and SYMBOL_NAME.  Given
 > >> that I'd like to use the name SYMBOL_LINKAGE_NAME for something
 > >> else, I'd like to get rid of its current use.
 > 
 > > can you expand a bit?
 > 
 > As I posted in
 > <http://sources.redhat.com/ml/gdb/2003-01/msg00188.html>, I really

Whoops, another mail I overlooked. I just re-read it, yes, I think
your plan makes sense.


 > think that it's important to clean up GDB's use of various names.  I
 > want to make it as easy as possible for people to get at either the
 > source code names of symbols or the linkage names of symbols, and to
 > make it clear when they mean the one or the other.  For the linkage
 > names, the best macro name that I've come up with is
 > SYMBOL_LINKAGE_NAME: so a not-to-distant step in this process will be
 > to introduce a macro SYMBOL_LINKAGE_NAME whose definition is exactly
 > the same as the definition of SYMBOL_NAME, but with the extra semantic
 > benefit that users of that macro will promise that they've actually
 > thought about the situation and decided that they really want the
 > linkage name instead of the source code name.
 > 
 > But to do that, I have to get rid of the existing macro
 > SYMBOL_LINKAGE_NAME.  (Or else think up another name, but here getting
 > rid of the existing macro seems preferable.)
 > 
 > I'm certainly open to different names for these macros, if you'd
 > prefer something else.  (Though I do think that getting rid of the
 > current SYMBOL_LINKAGE_NAME wouldn't be a bad idea, given how little
 > it's used.)
 > 

The one I wasn't sure about was the SYMBOL_PRINT_NAME. But i haven't
thought through the whole issue.

 > >> if (symbol)
 > >> {
 > >> name_location = BLOCK_START (SYMBOL_BLOCK_VALUE (symbol));
 > >> -      if (do_demangle)
 > >> +      if (do_demangle || asm_demangle)
 > 
 > > why this change? I must be missing something.
 > 
 > >> name_temp = SYMBOL_SOURCE_NAME (symbol);
 > >> else
 > >> -	name_temp = SYMBOL_LINKAGE_NAME (symbol);
 > >> +	name_temp = SYMBOL_NAME (symbol);
 > >> }
 > 
 > > this one is ok.
 > 
 > The current SYMBOL_LINKAGE_NAME (that I'm getting rid of) is
 > equivalent, I think, to
 > 
 > asm_demangle ? SYMBOL_SOURCE_NAME : SYMBOL_NAME.
 > 
 > So the old code
 > 
 >   if (do_demangle)
 >     name_temp = SYMBOL_SOURCE_NAME (symbol);
 >   else
 >     name_temp = SYMBOL_LINKAGE_NAME (symbol);
 > 
 > becomes
 > 
 >   if (do_demangle)
 >     name_temp = SYMBOL_SOURCE_NAME (symbol);
 >   else
 >     {
 >       if (asm_demangle)

Ah, never mind, I did some quick grepping and I concluded, erroneously, that 
do_demangle == demangle, but that's not always the case.

yes, this is fine.

elena


 >         name_temp = SYMBOL_SOURCE_NAME (symbol);
 >       else
 >         name_temp = SYMBOL_NAME (symbol);
 >     }
 > 
 > And then I combined the first two if statements into an or statement.
 > 
 > David Carlton
 > carlton@math.stanford.edu


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [rfa] delete macro SYMBOL_LINKAGE_NAME
  2003-02-04 17:00     ` Elena Zannoni
@ 2003-02-04 21:38       ` David Carlton
  0 siblings, 0 replies; 5+ messages in thread
From: David Carlton @ 2003-02-04 21:38 UTC (permalink / raw)
  To: Elena Zannoni; +Cc: gdb-patches, Jim Blandy

On Tue, 4 Feb 2003 12:04:33 -0500, Elena Zannoni <ezannoni@redhat.com> said:
> David Carlton writes:

>> As I posted in
>> <http://sources.redhat.com/ml/gdb/2003-01/msg00188.html>, I really

> Whoops, another mail I overlooked. I just re-read it, yes, I think
> your plan makes sense.

Great, then I'll keep on pressing forward with that.

> The one I wasn't sure about was the SYMBOL_PRINT_NAME. But i haven't
> thought through the whole issue.

Okay, we can talk about that in a patch or two from now; I'm certainly
open to argument on that one.

> yes, this is fine.

Thanks, committed.

David Carlton
carlton@math.stanford.edu


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2003-02-04 21:38 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-01-21  0:58 [rfa] delete macro SYMBOL_LINKAGE_NAME David Carlton
2003-02-03 18:30 ` Elena Zannoni
2003-02-03 18:41   ` David Carlton
2003-02-04 17:00     ` Elena Zannoni
2003-02-04 21:38       ` David Carlton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox