开发者

Using -g and -O2 options in gcc

开发者 https://www.devze.com 2023-02-04 01:29 出处:网络
Does anybody experience mixing -g (debugging symbols) and -O2 (best safe optimization) with gcc开发者_开发百科 compiler?

Does anybody experience mixing -g (debugging symbols) and -O2 (best safe optimization) with gcc开发者_开发百科 compiler?

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 >>

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.


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. In embedded environment it is a big trade-off.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号