Home

GDB debugger

Starting the debugger

First, you’ll need to compile your program with “debug symbols” using the -g switch:

g++ -Wall -g -o myprog myprog.cpp

Then, start GDB on your program:

gdb ./myprog

Now you can use the commands listed below.

Getting help

Breakpoints

Running

Hit Ctrl-Z to stop a running program and go back to the gdb prompt.

Variable inspection

Type inspection

Function inspection

Stack traces

Inspecting code

Miscellaneous

CSCI 221 material by Joshua Eckroth is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License. Source code for this website available at GitHub.