Re: Debug optimized code

"cr88192" <>
Wed, 17 Sep 2008 22:12:44 +1000

          From comp.compilers

Related articles
Debug optimized code (Stephan Ceram) (2008-09-16)
Re: Debug optimized code (RR) (2008-09-17)
Re: Debug optimized code (cr88192) (2008-09-17)
Re: Debug optimized code (Walter Banks) (2008-09-17)
Re: Debug optimized code (rcmetzger) (2008-09-17)
Re: Debug optimized code (Stephen Horne) (2008-09-18)
Re: Debug optimized code (Barry Kelly) (2008-09-19)
Re: Debug optimized code (George Neuner) (2008-09-20)
Re: Debug optimized code (Hans-Peter Diettrich) (2008-09-21)
[5 later articles]
| List of all articles for this month |

From: "cr88192" <>
Newsgroups: comp.compilers
Date: Wed, 17 Sep 2008 22:12:44 +1000
Organization: Saipan Datacom
References: 08-09-076
Keywords: debug, comment
Posted-Date: 17 Sep 2008 17:53:54 EDT

"Stephan Ceram" <> wrote in message
> I've a question about compilers' symbolic debugging information (like
> DWARF2) and compiler optimizations. Should the code be always compiled
> without any optimizations, i.e. -O0, to get accurate debug information
> where all source code line number are correct or would I also get accurate
> results for higher optimization levels? Usually, at least -O1 does
> not modify the code too much, so I would assume that this optimization
> level could be applied for a successful debugging afterwards.
> What are you experiences?

Well, in general, if one is using debugging, they don't want any
optimization, and if they want optimization, they can't really use

One can try, but the usual experience is that of the debugger not
giving very good results. however, what exactly happens is likely to
depend very much on the specific compiler and version.

Now, usually one does not give any '-O' options, instead they may give
'-g' or '-pg' (profiling), and leave it up to the compiler to set up
any optimizations (even '-O0' may possibly do something weird, or by
default the compiler may leave on some optimizations which do not
effect debugging, with '-O0' forcing it to not even use these, ...).

or such...
[I debug optimized code all the time, when the "final" version of something
turns out to have a few more bugs. -John]

Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.