I have this C file (sample.c):
#include <stdio.h>
#define M 42
#define ADD(x) (M + x)
int main ()
{
printf("%d
", M);
printf("%d
", ADD(2));
return 0;
}
which I compile with:
$ gcc -O0 -Wall -g3 sample.c -o sample
then debug with
$ gdb ./sample
GNU gdb (Gentoo 7.3.1 p2) 7.3.1
Copyright (C) 2011 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-pc-linux-gnu".
For bug reporting instructions, please see:
<http://bugs.gentoo.org/>...
Reading symbols from /tmp/sample...done.
(gdb) macro list
(gdb) macro expand ADD(2)
expands to: ADD(2)
(gdb) print M
No symbol "M" in current context.
(gdb) q
This used to work. I need this to work because I am using libraries which #define names for hardware peripherals and memory addresses.
This seems to be in direct contradiction of the behavior that is shown on the Sourceware gdb site.
What am I doing wrong?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…