Re: Debug optimized code

Walter Banks <walter@bytecraft.com>
Wed, 17 Sep 2008 09:28:14 -0400

          From comp.compilers

Related articles
Debug optimized code linuxkaffee_@_gmx.net (Stephan Ceram) (2008-09-16)
Re: Debug optimized code rajaram.officemails@gmail.com (RR) (2008-09-17)
Re: Debug optimized code cr88192@hotmail.com (cr88192) (2008-09-17)
Re: Debug optimized code walter@bytecraft.com (Walter Banks) (2008-09-17)
Re: Debug optimized code rcmetzger@grandecom.net (rcmetzger) (2008-09-17)
Re: Debug optimized code sh006d3592@blueyonder.co.uk (Stephen Horne) (2008-09-18)
Re: Debug optimized code barry.j.kelly@gmail.com (Barry Kelly) (2008-09-19)
Re: Debug optimized code gneuner2@comcast.net (George Neuner) (2008-09-20)
Re: Debug optimized code DrDiettrich1@aol.com (Hans-Peter Diettrich) (2008-09-21)
Re: Debug optimized code sh006d3592@blueyonder.co.uk (Stephen Horne) (2008-09-22)
[4 later articles]
| List of all articles for this month |

From: Walter Banks <walter@bytecraft.com>
Newsgroups: comp.compilers
Date: Wed, 17 Sep 2008 09:28:14 -0400
Organization: Compilers Central
References: 08-09-076
Keywords: debug, optimize
Posted-Date: 17 Sep 2008 17:55:09 EDT

Stephan Ceram wrote:


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


Stephan,


This is an incredibly important topic.


Earlier in the week I was talking to a developer about optimization
and it became clear that the reason he wanted optimization off in the
tools he was using was in the tools he was familiar with was so the
source level debugging information reflected the application. In an
example he showed me with higher levels of optimization the compiler
temporarily used a register as a variable but the debugging
information showed the variable as located in the RAM address it was
assigned to.


The developer explained that he debugged the application with their
tools with optimization off and re-compiled and shipped.


This is scary for two reasons, there is an assumption that the
compiled code and application timing will function the same
independent of optimization level. Secondly, code was being shipped
without rigorous testing.


The problem is in the compiler not the source level debugging format.
In the example above there is is no problem describing that a variable
is in a specific register for a specific execution range.


The compiler technology to do this has been available for 15 years or
so. In the last few days this is the third reference to the problem I
have seen.


A short survey here might help point to what compilers (open source or
commercial) generate source level debugging information that tracks
the optimizations used to generated code.


Regards




--
Walter Banks
Byte Craft Limited
Tel. (519) 888-6911
http://www.bytecraft.com
walter@bytecraft.com


Post a followup to this message

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