For a rather obscure reason, I have to compile at least
part of my application with at least some level of
optimization -- a certain behavior I rely on is only
enabled by the optimizer. I'm concerned about the effect
that optimization may have on debuggability.
1) Looking over the options, it appears that the least-
disruptive optimization is probably -Og, global
optimization. According to the documentation, this
option enables common subexpression elimination,
variable and expression enregistering, and
loop-invariant removal. Is this, in fact, the option
that will result in the least degradation of debugging?
2) I'm guessing that the impact of using this option
would primarily be felt in the movement of loop-invariant
code -- for example, in single-stepping into a loop, you
might find the cursor in the middle of the loop, then
back at the top as you step into code that was moved, or
a breakpoint in a loop might be hit once instead of each
time through the loop. Is there anything else I should
watch out for? For example, will I get the wrong answer
displaying the value of a variable that's in a register?
Is there anything I can do to mitigate these effects?
Thanks for any comments or suggestions.
-- William M. Miller