Re: evaluating #defines in gdb?

From: Mark Devlin (markd@eskimo.com)
Date: 11/03/95


On Fri, 3 Nov 1995, Mark Coletti wrote:

> Trey T. Morita pounded furiously on the keyboard:
> 
> > On Thu, 2 Nov 1995, Mark Devlin wrote:
> > > gdb (and other source-level debuggers) get the info about variables from 
> > > the symbol table in the executable.  When you compile with debug info, 
> 
> 	[snip!]
> 
> > Thanks for the info Mark, but the part that got clipped (the original 
> > mail by me) was using an example of GET_STR(ch) which is in actuality . . 
> 
> > #define GET_STR(ch)     ((ch)->aff_abils.str)
> 
> > There's no real way to sub a const declaration for this, now, is there?
> 
> 	Well, it's not a total loss if you're using gcc and gdb;
> apparently gcc supports a -ggdb# where # specifies the level of
> debugging information you want added to the generated binaries.  The
> highest level, 3, _supposedly_ groks macro definitions, too.  But,
> I've never tried this, so I don't know how well this works, if it does
> at all.  YMMV!  =8-)

Ok, just tried this with gcc 2.7.0 and gdb 4.14:
Mark's suggestion of -ggdb3 didn't recognize any symbol for a macro 
definition I used.
However, an inline-function version of the macro worked fine, use the 
'call' command in gdb to call the function.  It will be inlined for most 
uses, so there's no overhead.  Also, gives you type safety, almost
always a good thing.

An example (with the variables possibly screwed up):
inline int GET_STR(const struct char_data *ch)
{
	return ch->aff_abils.str;
}

Now, I only use gcc and gdb, so I can't make any comments about the rest 
of the world.  Hope this is still of some use.

 
- Mark
markd@eskimo.com



This archive was generated by hypermail 2b30 : 12/07/00 PST