The -ggdb3
option should be giving you macro debugging information. But this is a different kind of debugging information (it has to be different - it tells the debugger how to expand the macro, possibly including arguments and the #
and ##
operators) so you can't see it with nm
.
If your goal is to have something that shows up in nm
, then I guess you can't use a macro. But that's a silly goal; you should want to have something that actually works in a debugger, right? Try print symC
in gdb
and see if it works.
Since macros can be redefined, gdb
requires the program to be stopped at a location where the macro existed so it can find the correct definition. In this program:
#include <stdio.h>
int main(void)
{
#define X 1
printf("%d\n", X);
#undef X
printf("---\n");
#define X 2
printf("%d\n", X);
}
If you break on the first printf
and print X
you'll get the 1; next
to the second printf
and gdb
will tell you that there is no X
; next
again and it will show the 2.
Also the gdb
command info macro foo
can be useful, if foo
is a macro that takes arguments and you want to see its definition rather than expand it with a specific set of arguments. And if a macro expands to something that's not an expression, gdb
can't print
it so info macro
is the only thing you can do with it.
For better inspection of the raw debugging information, try objdump -W
instead of nm
.