Re: Customizing optimization for debug builds

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

 



On 2/4/21 11:11 AM, Paul Smith wrote:
The thing that really makes me
want to punch my monitor is when a variable that contains critical info
I need is optimized out.  I don't know if it's just my code or what but
it seems to happen to me A LOT that the info I need is only available
in some register somewhere that I can't easily figure out how to
retrieve, because the variable was optimized away.

Drives me crazy, too, but that's what optimization does. As I posted previously, I can't use -O0 and/or no optimization, so I long ago made my peace with it. I frequently have to sprinkle my code with:

#ifdef DEBUG
volatile
#endif
unsigned some_variable;

And of course that can cause problems when "some_variable" is passed to:

void some_function(unsigned value) ...

and passing a volatile unsigned instead is an error. So then it's:

unsigned some_variable;
some_variable = ...
volatile unsigned copy_of_variable = some_variable;
some_function(some_variable);

ad nauseum. A real P.I.T.A.


I wonder if anyone has any thoughts about specific -fno-* settings I
can add alongside -Og which will preserve either all, or most, or even
just more, of the local variables rather than optimizing them away.

That would be nice (I'd need it with -O1) but I wouldn't hold my breath. It's likely way too deep in the many optimization passes to specifically turn it off for this use-case.

But I'd be pleasantly surprised to be informed otherwise.



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux