Mail Archives: djgpp/2000/06/20/08:30:46
Damian Yerrick <Bullcr_pd_yerrick AT hotmail DOT comremovebullcr_p> wrote:
> There is generally one main reason to turn off optimization in GCC:
> when debugging your executable in GDB. Optimization rearranges
> instructions to better fit in a Pentium's pipeline; this throws GDB
> off balance.
Not really true.
It's actually one of the major advantages of GCC/GDB over some of the
old system vendors' compilers/debuggers they were originally meant to
replace that you *can* debug even a fully optimized program.
Debugging can become harder, and there may be surprises, sure:
variables may have been optimized away by GCC, so their contents can't
be printed in gdb. Execution flow may jump back and forth across
several lines of source code. Short function may get inlined away, so
you can't set a breakpoint to them, any more. But nothing of that
means you *can't* debug an optimized program. You just have to live
with some drawbacks.
--
Hans-Bernhard Broeker (broeker AT physik DOT rwth-aachen DOT de)
Even if all the snow were burnt, ashes would remain.
- Raw text -