gcc/gdb: DWARF/macro

怎么才能让core文件带有宏定义,

需要使用 gcc -g3 -gdwarf-4 -ggdb func.c
这里使用了dwarf格式的调试信息,同时将调试信息的级别设置为了3级;
然后再使用gdb 看 coredump文件,就可以看到所用的宏定义;
(gdb) info macros
Defined at /root/mzhan017/test/func.c:21
#define A 3

gdb里的说明

gdb knows about preprocessor macros and can show you their expansion (see Chapter 12
[Macros], page 189). Most compilers do not include information about preprocessor macros
in the debugging information if you specify the -g flag alone. Version 3.1 and later of gcc,
the gnu C compiler, provides macro information if you are using the DWARF debugging
format, and specify the option -g3.
See Section “Options for Debugging Your Program or GCC” in Using the gnu Compiler

猜你喜欢

转载自blog.csdn.net/qq_36428903/article/details/125092497