Currently `info variables` command does not print ones declared with `#define`. I mean, it kinda makes sense if you take the meaning of "variable" as of a mutable identifier. However this is not the meaning gdb uses because the command prints enum fields just fine, which are not mutable either. So this is a bug. # Steps to reproduce (in terms of terminal commands) $ cat test2.c #define MY_MACRO 7 int main() {} $ gcc test2.c -o a -g3 -O0 $ gdb ./a Reading symbols from ./a... gdb λ br main Breakpoint 1 at 0x1122: file test2.c, line 3. gdb λ r Starting program: /tmp/a Breakpoint 1, main () at test2.c:3 3 int main() {} gdb λ p MY_MACRO $1 = 7 gdb λ info variables MY_MACRO All variables matching regular expression "MY_MACRO": gdb λ ## Expected `info variables` would print `#define MY_MACRO 7` ## Actual `info variables` did not print anything about MY_MACRO.
gdb will show this with "info macro". Macros aren't really variables, and often there are many more in scope than you might think -- enough that they would overwhelm the output relating to real variables, which is probably what most users want.
(In reply to Tom Tromey from comment #1) > gdb will show this with "info macro". Macros aren't really variables You probably imply that macros can accept arguments, which makes them not to be variables. Well… probably that's fair too. Feel free to close report if you don't think it's actionable. >, and often there are many more in scope than you might think -- enough that > they would overwhelm the output relating to real variables, which is probably > what most users want. I don't think such problem is a thing. If you execute `info variables` with the original testcase which does not even contain includes, you will get so overwhelming amount of output that terminal scrollback won't have enough space. That's why `i variables` supports regexps, to reduce the output.
(In reply to Hi-Angel from comment #2) > (In reply to Tom Tromey from comment #1) > > gdb will show this with "info macro". Macros aren't really variables > > You probably imply that macros can accept arguments, which makes them not to > be > variables. They also have different scoping and can expand to anything, which isn't actually all that uncommon. > I don't think such problem is a thing. If you execute `info variables` with > the original > testcase which does not even contain includes, you will get so overwhelming > amount of output that terminal scrollback won't have enough space. Try it on a real program, like say any random function in gdb itself, and you'll see what I mean.