简体   繁体   English

在gcc中使用-g和-O2选项

[英]Using -g and -O2 options in gcc

Does anybody experience mixing -g (debugging symbols) and -O2 (best safe optimization) with gcc compiler? 有没有人经历混合-g(调试符号)和-O2(最佳安全优化)与gcc编译器?
I have to debug crashes of a release program distributed to final users that could send me back the core file. 我必须调试分发给最终用户的发布程序的崩溃,这些程序可能会将我发回给核心文件。
I've always used to call: 我一直习惯称:

gdb << myprogram >> << core file >> gdb << myprogram >> << core file >>

and see where the trouble is. 并看看问题出在哪里。 Now I can just see the call-trace but having no debugging symbols I'm quite in trouble. 现在我可以看到调用跟踪但没有调试符号我遇到了麻烦。

Any idea? 任何的想法?

It works fine. 它工作正常。

Or well, due to the optimization sometimes the source you're stepping through with the debugger doesn't match up exactly with the source, but IMHO despite this having the debug symbols makes debugging much easier. 或者,由于优化,有时您使用调试器的源代码与源完全不匹配,但IMHO尽管具有调试符号使调试更容易。

We use both together in production environment, which makes debugging a lot easier if the customer have only seen a crash once. 我们在生产环境中一起使用它们,如果客户只看到一次崩溃,这使得调试变得更容易。 It gives you a pretty good idea where the problem is (not if it was a memory corruption). 它可以让你很好地了解问题所在(不是内存损坏)。

In theory adding -g shouldn't really affect the performance, although the executable gets large. 理论上,尽管可执行文件变大,但添加-g不应该真正影响性能。 In embedded environment it is a big trade-off. 在嵌入式环境中,这是一个很大的权衡。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM