[Back to Tutorials]

RMS's gdb Debugger Tutorial

"Don't worry if it doesn't work right. If everything did, you'd be out of a job."
Unknown

gdb Debugger Frequently Asked Questions

 

Table of Contents

  1. How do I use the gdb debugger?

    How do I...
    1. compile with debugging symbols?
    2. run programs with the debugger?
    3. restart a program running in the debugger?
    4. exit the debugger?
    5. get help on debugger commands?

  2. How do I watch the execution of my program?

    How do I...
    1. stop execution
    2. continue execution
    3. see where my program stopped?
    4. step through my code line-by-line?
    5. examine variables?
    6. modify variables?
    7. call functions linked into my program?
    8. return from a function?

  3. How do I use the call stack?

    How do I...
    1. get a backtrace?
    2. change stack frames?
    3. examine stack frames?

  4. How do I use breakpoints?

    How do I...
    1. set a breakpoint on a line?
    2. set a breakpoint on a C function?
    3. set a breakpoint on a C++ function?
    4. set a temporary breakpoint?
    5. get a list of breakpoints?
    6. disable breakpoints?
    7. skip breakpoints?

  5. How do I use watchpoints?

    How do I...
    1. set a write watchpoint for a variable?
    2. set a read watchpoint for a variable?
    3. set a read/write watchpoint for a variable?
    4. disable watchpoints?

  6. Advanced gdb Features

    How do I...
    1. How do I examine memory?
    2. How do I see what is in the processor registers?
    3. How do I debug with a core file?
    4. How do I step through my code at the instruction level?
    5. How do I see the assembly code my program is running?

  7. Example Debugging Sessions

    1. Infinite Loop Example
    2. Segmentation Fault Example

  8. gdb Links

 





Questions? Comments? Flames? email rms@unknownroad.com