next up previous
Next: Running GDB Up: Debugging with GNU Debugger Previous: Debugging with GNU Debugger


Compiling with Debugging Information

To use GDB, you will have to compile with debugging information enabled. Do this by adding the -g switch on the compilation command line. If you are using a Makefile as described previously, you can just set CFLAGS equal to -g when you run make, as shown here:
% make CFLAGS=-g
When you compile with -g, the compiler includes extra information in the object files and executables. The debugger uses this information to figure out which addresses correspond to which lines in which source files, how to print out local variables, and so forth.

Cem Ozdogan 2007-02-19