$ cat test.c enum E { Val1, Val2 }; int main() { enum E e = Val1; return e; } ... Temporary breakpoint 1, main () at test.c:6 6 enum E e = Val1; (gdb) n 7 return e; (gdb) p e $1 = Val1 (gdb) p Val1 $2 = Val1 (gdb) p (int)Val1 $3 = 0 When I print a variable, printing the symbolic name for its value is right, but when I print the symbolic name, gdb should print its numeric value instead (or in addition). There's an easy workaround, of course, but gdb should DTRT in the first place.
Lacking any consensus on the utility, implementation, or display format for this enhancement, and the evolving mutually exclusive requirements, there's no way to make this enhancement work.
For those not following the discussion, Chris attempted two separate patches: http://sourceware.org/ml/gdb-patches/2010-02/msg00179.html http://sourceware.org/ml/gdb-patches/2010-02/msg00279.html
Thanks, Chris, for your work on this. I guess such a simple change was just asking to be bikeshedded into oblivion.
You can also use "p /d" as a work around. It is less typing than "p (int)" (gdb) p /d Val1 $4 = 0
Or: (gdb) p Val1+0 Which I find even easier to type, as what I actually usually do is: (gdb) p Val1 $1 = Val1 <up>+0<enter> $2 = 0
Or use the fact that the expression defaults to $. (gdb) p Val1 $1 = Val1 (gdb) p/d $2 = 0