gdb optimized out错误解决

来源:互联网 发布:linux系统支持的游戏 编辑:程序博客网 时间:2024/05/01 16:26

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.