Next: Compiling with Debugging Information
Up: Getting Started
Previous: Automating the Process with
Contents
Debugging with GNU Debugger (GDB)
- The debugger is the program that you use to figure out why your program is not behaving the way you think it should. You can use GDB to step through your code, set breakpoints, and examine the value of local variables.
- The -g option can be qualified with a 1, 2, or 3 to specify how much debugging information to include.
- The default level is 2 (-g2), which includes extensive symbol tables, line numbers, and information about local and external variables.
- Level 3 debugging information includes all of the level 2 information and all of the macro definitions present.
- Level 1 generates just enough information to create backtracks and stack dumps. It does not generate debugging information for local variables or line numbers.
- Additional debugging options include the -p and -pg options, which embed profiling information into the binary.
- This information is useful for tracking down performance
bottlenecks in your code.
- -p adds profiling symbols that the prof program can read,
- -pg adds symbols that the GNU project's prof incarnation, gprof, can interpret.
- The -a option generates counts of how many times blocks of code (such as functions) are entered.
- -save-temps saves the intermediate files, such as the object and assembler files, generated during compilation.
Subsections
Next: Compiling with Debugging Information
Up: Getting Started
Previous: Automating the Process with
Contents
Cem Ozdogan
2007-05-16