set break at oﬀset lines from current stop set breakpoint at address addr set breakpoint at next instruction break conditionally on nonzero expr new conditional expression on breakpoint n; make unconditional if no expr temporary break; disable when reached break on all functions matching regex set a watchpoint for expression expr break at event, which may be catch, throw, exec, fork, vfork, load, or unload. show deﬁned breakpoints show deﬁned watchpoints delete breakpoints at next instruction delete breakpoints at entry to fun() delete breakpoints on source line delete breakpoints [or breakpoint n] disable breakpoints [or breakpoint n] enable breakpoints [or breakpoint n] enable breakpoints [or breakpoint n]; disable again when reached enable breakpoints [or breakpoint n]; delete when reached ignore breakpoint n, count times execute GDB command-list every time breakpoint n is reached. [silent suppresses default display] end of command-list

execute until another line reached; repeat count times if speciﬁed step by machine instructions rather than source lines execute next line, including any function calls next machine instruction rather than source line run until next instruction (or location) run until selected stack frame returns pop selected stack frame without executing [setting return value] resume execution with signal s (none if 0) resume execution at speciﬁed line number or address evaluate expr without displaying it; use for altering program variables

Starting GDB
gdb gdb program gdb program core gdb --help
start GDB, with no debugging ﬁles begin debugging program debug coredump core produced by program describe command line options

Executing your Program
run arglist run run
start your program with arglist start your program with current argument list start your program with input, output redirected kill running program use dev as stdin and stdout for next run specify arglist for next run specify empty argument list display argument list show all environment variables show value of environment variable var set environment variable var remove var from environment

Controlling GDB
set param value show param
set one of GDB’s internal parameters display current setting of parameter Parameters understood by set and show: complaint limit number of messages on unusual symbols confirm on/oﬀ enable or disable cautionary queries editing on/oﬀ control readline command-line editing height lpp number of lines before pause in display language lang Language for GDB expressions (auto, c or modula-2) listsize n number of lines shown by list prompt str use str as GDB prompt radix base octal, decimal, or hex number representation verbose on/oﬀ control messages when loading symbols width cpl number of characters before line folded write on/oﬀ Allow or forbid patching binary, core ﬁles (when reopened with exec or core) history . . . groups with the following options:

Source Files
dir names dir show dir list list list lines
add directory names to front of source path clear source path show current source path show next ten lines of source show previous ten lines display source surrounding lines, speciﬁed as: line number [in named ﬁle] beginning of function [in named ﬁle] oﬀ lines after last printed oﬀ lines previous to last printed line containing address from line f to line l show starting, ending addresses of compiled code for source line num show name of current source ﬁle list all source ﬁles in use search following source lines for regex search preceding source lines for regex

disable/enable readline history expansion ﬁle for recording GDB command history number of commands kept in history list control use of external ﬁle for command history groups with the following options:

GDB License
show copying show warranty
Display GNU General Public License There is NO WARRANTY for GDB. Display full no-warranty statement.

end

Signals
handle signal act print noprint stop nostop pass nopass info signals
specify GDB actions for signal: announce signal be silent for signal halt execution on signal do not halt execution allow your program to handle signal do not allow your program to see signal show table of signals, GDB action for each

use ﬁle for both symbols and executable; with no arg, discard both read ﬁle as coredump; or discard use ﬁle as executable only; or discard use symbol table from ﬁle; or discard dynamically link ﬁle and add its symbols read additional symbols from ﬁle, dynamically loaded at addr display working ﬁles and targets in use add dirs to front of path searched for executable and symbol ﬁles display executable and symbol ﬁle path list names of shared libraries currently loaded

Copyright

c 1991, ’92, ’93, ’98 Free Software Foundation, Inc. Roland H. Pesch

The author assumes no responsibility for any errors on this card. This card may be freely distributed under the terms of the GNU General Public License. Please contribute to development of this card by annotating it. Improvements can be sent to bug-gdb@gnu.org. GDB itself is free software; you are welcome to distribute copies of it under the terms of the GNU General Public License. There is absolutely no warranty for GDB.