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: Joerg Wunsch
Subject: Re: [avr-gcc-list] Debug with AVRStudio4?
Date: Wed, 7 Sep 2005 16:39:34 +0200 (MET DST)

Russell Shaw <address@hidden> wrote:

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

Sure.  Get used to it...

> With -O0, the bar follows every source line as you'd imagine.

Sure.  No optimization.  Completely different code written by the
compiler.  Not just "a bit different", it's completely different.

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

Yes, but how would you do that on a completely different problem?

Simple example: you forgot to mark a variable "volatile" that is
modified by an interrupt routine.  Sure, your imagination of the
program logic would work fine, and the debugger seems to support this.
Yet, it's still your code that is at fault, and only the optimizer
will show you that.  There can be more sophisticated examples found
like this one.  Lastly, once your skill level of ``mortal C'' is good
enough, I'd say you most of the time won't make much of those simple
mistakes anymore that could easily be found with optimization turned
off.

I rather live with the debugger's code pointer jumping around, than
wasting my time in debugging something that's not gonna be ``The Real
Thing'', only in order to find that I'll eventually have to debug it
again once optimization was enabled.

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

In 99.99 % it'll be the latter, only 0.01 % account on true optimizer
bugs.  It's by several orders of magnitude more likely that you
trigger an Internal Compiler Error (ICE) in GCC than an optimizer bug.

-- 
J"org Wunsch                                           Unix support engineer
address@hidden        http://www.interface-systems.de/~j/




reply via email to

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