(ddd.info)Compiling for Debugging
4.1 Compiling for Debugging
===========================
In order to debug a program effectively, you need to generate debugging
information when you compile it. This debugging information is stored
in the object file; it describes the data type of each variable or
function and the correspondence between source line numbers and
addresses in the executable code.(1)
To request debugging information, specify the `-g' option when you
run the compiler.
Many C compilers are unable to handle the `-g' and `-O' options
together. Using those compilers, you cannot generate optimized
executables containing debugging information.
GCC, the GNU C compiler, supports `-g' with or without `-O', making
it possible to debug optimized code. We recommend that you _always_
use `-g' whenever you compile a program. You may think your program is
correct, but there is no sense in pushing your luck.
When you debug a program compiled with `-g -O', remember that the
optimizer is rearranging your code; the debugger shows you what is
really there. Do not be too surprised when the execution path does not
exactly match your source file! An extreme example: if you define a
variable, but never use it, DDD never sees that variable--because the
compiler optimizes it out of existence.
---------- Footnotes ----------
(1) If you use DDD to debug Perl, Python or Bash scripts, then this
section does not apply.
automatically generated by info2www version 1.2.2.9