转自:http://blog.youkuaiyun.com/cws1214/article/details/12023093
when linux gdb debug, print a variable, such as i, by command p i;
The gdb output value optimized out.
The solution for the problem is off the compile optimation option -Ox, x note digital, such 2, 3, 4 etc
The better way is that changing -Ox to -O0.
The -O0 denotes there is no optimization. It will avoid gdb mislead source code line issue.
GDB调试与编译优化
本文介绍在使用GDB进行Linux程序调试时遇到的问题及解决办法。当使用较高优化等级(如-O2、-O3等)编译程序时,可能会导致GDB无法正确显示变量值或误导源代码行。解决此问题的最佳方式是将编译选项改为-O0,即禁用所有优化,以确保调试信息的准确性。
2862

被折叠的 条评论
为什么被折叠?



