next up previous


Options de compilation

In order to debug a program effectively, you need to ask for debugging
information when you compile it.  This information in the object file
describes the data type of each variable or function and the correspondence
between source line numbers and addresses in the executable code.

To request debugging information, specify the `-g' option when you run
the compiler.

The Unix C compiler is unable to handle the `-g' and `-O' options
together.  This means that you cannot ask for optimization if you ask for
debugger information.

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 the program is
correct, but therés no sense in pushing your luck.

If you are using the GNU C compiler, the GNU assembler and the GNU linker,
you can choose between two formats of debugging information: the standard
Unix format, which is what you get with `-g', and GDB's own format,
which you request by using `-gg' instead of `-g'.  This stores
debugging information in the executable file in a format much like that
which is used inside GDB.  This has these advantages and disadvantages:

   * GDB can read `-gg' format more than twice as fast as Unix
     `-g' format.
     
   * The `-gg' format uses much more disk space than Unix format.
     
   * The Unix debuggers can understand only Unix format, so you cannot use
     Unix source-level debuggers if you compile with `-gg'.  (The
     `adb' debugger works with either format; it does not use this
     information in any case.)