gdb take care of c macros

The Annoying C-Preprocessor Macros

gcc -gdwarf-2 -g3
Breakpoint 1, main () at c_preprocessor_macros.c:14
14		int state = STATE_BAD;
(gdb) p STATE_BAD
$1 = 1
(gdb) info macro STATE_BAD
Defined at /home/choo/work/lin-club/gdb_-_customize_it/gdb_source_examples/c_preprocessor_macros.c:4
#define STATE_BAD 1
Breakpoint 2, main () at c_preprocessor_macros.c:19
19		int person2_qualities = FLAG_SMART | FLAG_TALL | FLAG_HEAVY;
(gdb) macro expand  FLAG_SMART | FLAG_TALL | FLAG_HEAVY
expands to: 2 | 4 | 8


gcc option
-gdwarf-version

-g3
Level 3 includes extra information, such as all the macro
           definitions present in the program.  Some debuggers support macro
           expansion when you use -g3.


原文地址:https://www.cnblogs.com/kwingmei/p/3224466.html