This is the mail archive of the gdb@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

expanding c-macros in gdb


Hello,

we are using gcc/gdb for development in C. The C code uses some
macros for accessing data, for example:

  #define REFP_XYZ(i) xyz_ptr->s_xyz.r_xyz[i].xyz
  ...
  if (REFP_XYZ(a).abc != 0) ...
  ...

Is there a way to make gdb understand that the command
print REFP_XYZ(a).abc is the same as print xyz_ptr->s_xyz.r_xyz[i].xyz.abc?

I have read in the gcc manual that compiling with -g3 stores information
about
all defined macros, so that "Some debuggers support macro expansion when you
use `-g3'."
This does not seem to work with gdb (gcc 2.95.2, gdb 5.0, on HP-UX 10.20).

Then I thought about defining a macro printmac in gdb, but I have not found
a way to
do the expansion. What I'm thinking about is to call a shell- or sed-skript
that does
the expansion and pass the result on to the print command, something like
this
(transform is the name of a sed-script, that does the actual expansion):

  define printmac(arg)
  print `echo $arg | sed -f transform` 

Is something like this possible in gdb? Can I use a hook?

Thanks in advance,

Axel Howind


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]