avr-gcc-list
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [avr-gcc-list] Debug with AVRStudio4?


From: Russell Shaw
Subject: Re: [avr-gcc-list] Debug with AVRStudio4?
Date: Wed, 07 Sep 2005 23:56:19 +1000
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.10) Gecko/20050802 Debian/1.7.10-1

Joerg Wunsch wrote:
Torleif Sandnes <address@hidden> wrote:

Your problem may be that you are compiling with optimization on.
Try to use -O0 instead of -Os, -O1 or whatever you are using.

But of course, he'll debug an entirely different program then.

My own experience says that it's best to get used to the artefacts
caused by debugging optimized code, as a good number of programming
errors will only be found once the optimizer is turned on (as the
compiler will then aggressively impose all its rules onto the source
program).

I'd have to disagree;)
When you use gdb on code that has been optimized with -O2, the source
highlighter bar jumps all over the place making it hard to follow the
code. With -O0, the bar follows every source line as you'd imagine.

The purpose of the debugger is to verify that ones own imagination
of the program logic agrees with what you have created in reality.

With optimization on, optimizer bugs combined with your own bugs
plus a highlighter that is chasing code that has been optimized
out, is a sure way to confusion.

With a program verified with -O0, if it behaves differently
with -O2, you *know* there's an optimizer issue, or your code
needs to be modified to account for the effects of optimization.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]