eclipse gdb 使用 -O2 标志步进到上一行
使用带有 -g 和 -O2 标志的 gdb 偶尔跳过到上一行。删除 -O2 标志,它会按预期工作。谁能解释为什么会发生这种情况?
我是 eclipse CDT 中的 gdb 新手,并通过“标准创建进程启动器”在 C++ 代码上使用它。
这是预期的行为还是有保留优化的解决方案?
Step over occationally steps to previous line using gdb with both -g and -O2 flags. Remove the -O2 flags and it works as expected. Can anyone explain why that happens ?
I'm new to gdb in eclipse CDT and use it on C++ code with "Standard create process launcher".
Is this expected behaviour or is there a solution leaving optimization in ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这是预期的。编译器可以随意在更高的优化级别上重新排序代码。手册页甚至说:
这个目标在更高的层面上不得不被搁置。
It's expected. The compiler will feel free to re-order code on higher optimization levels. The man page even says that:
That goal has to fall by the wayside at higher levels.
优化有时可能会以意想不到的方式重新排列您的代码。优化代码中的调试信息将遵循这些重新安排。
Optimization may re-arrange your code in sometimes unexpected ways. The debug information in the optimized code will have followed those re-arrangements around.
不要求代码完全按照您编写的顺序执行,只是结果(“可观察的行为”)与执行时的结果相同。
§1.9:
There are no requirements that the code is executed exactly in the order you have written it, just that the result, "the observable behavior", is the same as-if it did.
§1.9: