gcc build with -O0 results in corrupted -debuginfo package
anprice at redhat.com
Fri Apr 25 20:11:50 UTC 2014
On 25/04/14 20:10, Simo Sorce wrote:
> On Fri, 2014-04-25 at 14:03 -0400, Adam Jackson wrote:
>> On Fri, 2014-04-25 at 18:10 +0200, Kevin Kofler wrote:
>>> Petr Spacek wrote:
>>>> I'm going to reproduce and debug issue in named. Do you see any specific
>>>> reason why I should use -O2 for serious debugging/development sessions?
>>> IMHO, you should always debug with optimization enabled.
> Kevin, have you ever debugged with -O2 ?
> It's more than reasonable to want -O0.
> At -O2 some code becomes really annoying to follow because gcc will
> optimize away way too much of it into registers (and gdb will not print
> you the values you need to see) or will make stepping a nightmare with
> gdb jumping in an out of the function as it gets inlined and then some
> stuff moved "out of the original function" and things like that.
> I've been more than once in gdb with -O2, it is *not* pretty, nor
> debug symbols at -O2 are mostly useful to get backtraces, but if you
> need to really step through with gdb in some complicated, highly
> optimizable code, often it does not cut it, you have to rebuild with -O0
> to regain debuggability and sanity.
-Og (new in gcc 4.8) is meant to enable only optimizations which won't
confuse gdb but I've not found a need to optimize my code just a little
bit while debugging yet, so -O0 is still my --enable-debug flag.
More information about the devel