Académique Documents
Professionnel Documents
Culture Documents
break [file:]line set breakpoint at line number [in file] continue [count] continue running; if count specified, ignore
Essential Commands b [file:]line eg: break main.c:37 c [count] this breakpoint next count times
gdb program [core] debug program [using coredump core] break [file:]func set breakpoint at func [in file] step [count] execute until another line reached; repeat
b [file:]function set breakpoint at function [in file] break +offset set break at offset lines from current stop s [count] count times if specified
break -offset stepi [count]
run [arglist] start your program [with arglist] step by machine instructions rather than
break *addr set breakpoint at address addr si [count] source lines
bt backtrace: display program stack
break set breakpoint at next instruction
p expr display the value of an expression next [count] execute next line, including any function
break . . . if expr break conditionally on nonzero expr
c continue running your program n [count] calls
next line, stepping over function calls cond n [expr] new conditional expression on breakpoint n;
n nexti [count] next machine instruction rather than source
make unconditional if no expr
s next line, stepping into function calls ni [count] line
tbreak . . . temporary break; disable when reached
rbreak regex break on all functions matching regex until [location] run until next instruction (or location)
Starting GDB watch expr set a watchpoint for expression expr finish run until selected stack frame returns
gdb start GDB, with no debugging files return [expr] pop selected stack frame without executing
catch event break at event, which may be catch,
gdb program begin debugging program throw, exec, fork, vfork, load, or
[setting return value]
gdb program core debug coredump core produced by program unload. signal num resume execution with signal s (none if 0)
gdb --help describe command line options jump line resume execution at specified line number or
info break show defined breakpoints jump *address address
info watch show defined watchpoints set var=expr evaluate expr without displaying it; use for
Stopping GDB altering program variables
quit exit GDB; also q or EOF (eg C-d) clear delete breakpoints at next instruction
INTERRUPT (eg C-c) terminate current command, or clear [file:]fun delete breakpoints at entry to fun()
send to running process clear [file:]line delete breakpoints on source line
Display
print [/f ] [expr] show value of expr [or last value $]
delete [n] delete breakpoints [or breakpoint n] p [/f ] [expr] according to format f:
Getting Help x hexadecimal
disable [n] disable breakpoints [or breakpoint n]
help list classes of commands d signed decimal
help class one-line descriptions for commands in class enable [n] enable breakpoints [or breakpoint n] u unsigned decimal
help command describe command enable once [n] enable breakpoints [or breakpoint n]; disable o octal
again when reached t binary
Executing your Program enable del [n] enable breakpoints [or breakpoint n]; delete a address, absolute and relative
when reached c character
run arglist start your program with arglist f floating point
run start your program with current argument list ignore n count ignore breakpoint n, count times
call [/f ] expr like print but does not display void
run . . . <inf >outf start your program with input, output commands n execute GDB command-list every time
redirected x [/Nuf ] expr examine memory at address expr; optional
[silent] breakpoint n is reached. [silent format spec follows slash
kill kill running program command-list suppresses default display] N count of how many units to display
end end of command-list u unit size; one of
tty dev use dev as stdin and stdout for next run
set args arglist specify arglist for next run b individual bytes
Program Stack h halfwords (two bytes)
set args specify empty argument list
backtrace [n] print trace of all frames in stack; or of n w words (four bytes)
show args display argument list
bt [n] frames—innermost if n>0, outermost if g giant words (eight bytes)
n<0 f printing format. Any print format, or
show env show all environment variables
show env var show value of environment variable var frame [n] select frame number n or frame at address n; s null-terminated string
set env var string set environment variable var if no n, display current frame
i machine instructions
unset env var remove var from environment up n select frame n frames up disassem [addr] display memory as machine instructions
down n select frame n frames down
info frame [addr] describe selected frame, or frame at addr
Shell Commands info args arguments of selected frame Automatic Display
cd dir change working directory to dir info locals local variables of selected frame display [/f ] expr show value of expr each time program stops
pwd Print working directory info reg [rn]. . . register values [for regs rn] in selected [according to format f ]
make . . . call “make” info all-reg [rn] frame; all-reg includes floating point display display all enabled expressions on list
shell cmd execute arbitrary shell command string undisplay n remove number(s) n from list of
automatically displayed expressions
disable disp n disable display for expression(s) number n
enable disp n enable display for expression(s) number n
[] surround optional arguments ... show one or more arguments info display numbered list of display expressions