C语言 如何在 GDB 中打印 #defined 常量?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2934006/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How do I print a #defined constant in GDB?
提问by Charles Ma
As per subject.
按题目。
I have some constants hash defined like so:
我有一些常量哈希定义如下:
#define CONST 40
I've set a breakpoint in my program. How do I print the value of that constant? (I know I can just look at the source code, but I want to be sure of it)
我在我的程序中设置了一个断点。如何打印该常量的值?(我知道我可以看看源代码,但我想确定一下)
回答by
help macro
You must compile with the -g3 flag for it to work and start your program before the macros are loaded.
您必须使用 -g3 标志进行编译才能使其工作并在加载宏之前启动您的程序。
In your case:
在你的情况下:
info macro CONST
or
或者
macro expand CONST
More info: http://sourceware.org/gdb/current/onlinedocs/gdb/Macros.html
更多信息:http: //sourceware.org/gdb/current/onlinedocs/gdb/Macros.html

