HP WDB v6.3 Base Reference Card (August 2012)
Note: This reference card contains frequently used basic commands with brief
explanation. For more information, see the Debugging with GDB Manual.
For any suggestions or help, write to: wdb-help@cup.hp.com
Conventions followed in this card
Convention Description
[ ]
User input required; May be optional.
BOLD
Strings written in bold characters are commands.
“a/b” or a|b”
Either “a” or “b” can be used.
Starting GDB
gdb [
options
] [
file
] General syntax to invoke GDB.
gdb [
file
] Invoke GDB with or without exec-file file.
gdb [
file
] [core] Debug core-file core produced by exec-
file file.
gdb [
file
] [
pid
] Debug already running exec-file file with
process-id pid.
gdb --help Describe various command line options
with brief explanation.
Stopping GDB
quit or exit or (ctrl + d) Exit gdb.
(ctrl + c) Terminate currently executing command.
Essential Commands
break or b Set a breakpoint at specified location
(line/func/addr).
run or r Start the execution of program to be
debugged.
Backtrace, bt, or where Display the program stack.
print or p Print the value of given expression.
continue or c Continue the execution of program.
next or n Continue to next source line (without
stepping into function call).
step or s Continue to next source line (step into
function call if present).
Getting Help
help Display list of all classes of commands.
help [
class
] Display commands in class.
help [
cm d
] Describe command cmd with usage.
Shell Commands
cd [dir], pwd, make Shell commands supported in GDB.
shell
cm d
Execute shell command cmd in GDB.
Breakpoints and Watchpoints
break Set breakpoint on next executable source line.
break [
file:
][
lin e
] Set breakpoint on line number line [in file].
break [
file:
][
fu nc
] Set breakpoint on function func [in file].
break [
+/-
] [
offset
] Set breakpoint at offset lines below/above
current line.
break [*
addr
] Set breakpoint at address addr.
break … if [
ex pr
] Set breakpoint only when expr is nonzero.
cond [
n
] [
ex pr
] Break at breakpoint no. n only if expr is
nonzero.
tbreak [
argslist
] Set temporary breakpoint; gets deleted when hit
once. argslist is similar to that of break.
hbreak [
argslist
] Set a hardware assisted breakpoint. argslist is
similar to that of break.
xbreak [
file
:] [
fu nc
] Set a Set breakpoint at exit of procedure func
[in file].
rbreak [
regex
] Set breakpoint on all functions matching regex.
watch [
ex pr
] Set a watchpoint for expression expr.
watch_target [
ex pr
] Set a watchpoint on the target memory location
of an expression expr.
catch [
ev en t
] Set breakpoint to catch events such as signals
exceptions, process, thread, library events etc.
clear [
*addr
] Clear breakpoint placed at address addr.
clear [
file:
] [
fu nc
|
lin e
] Delete the breakpoint at the beginning of
function func [in file] or on a source line [in
file].
delete [
n1
] [
n2
] … Delete all or those specified breakpoints.
disable [
n1
] [
n2
] … Disable all or those specified breakpoints.
enable [
n1
] [
n2
] … Enable all or those specified breakpoints.
enable once [
n1
] [
n2
] … Enable all or those specified breakpoints;
disable when hit once.
enable del [
n1
] [
n2
] … Enable all or those specified breakpoints; delete
when hit once.
ignore [
n cou nt
] Ignore breakpoint n for count times.
commands [
n
] Set commands which execute whenever nth
silent breakpoint is reached. Silent (opt): suppresses
[
cm d- list
] default display. cmd-list: commands one per
end line. end: to put an end to the list.
info break [
n
] or Show status of all or nth user-settable
info watch [
n
] breakpoint.
Executing Program
set args [
arglist
] Set argument(s) arglist of program for
future run.
run [
arglist
] Start execution of program with already set arg-
list or new arg-list arglist.
run … [
<in f
] [
>out f
] Start execution with input and/or output
redirected.
kill Kill execution of program being debugged.
attach [
pid
] Attach with pid to debug program.
detach Release process from GDB control.
tty [dev] Use terminal dev as standard I/O for future
run.
show args Show the argument(s) passed to the program.
show
env v ars
Show all environment variables used by GDB.
set env [
v ar
] [
strin g
] Set value GDB environment variable var to
string.
show environment Show value of all [or var] environment
[
v ar
] variable(s).
unset environment Remove variable var from the environment
[
v ar
] variable list.
Execution Control
continue [
cou n t
] Continue execution [ignore the breakpoints
next count times].
step [
cou n t
] Execute next line excluding function calls;
repeat count times if specified.
stepi [count] or Step by machine instructions source lines;
si [count] repeat count times if specified.
next [
cou n t
] Execute next line including function calls;
repeat count times if specified
nexti [
cou n t
] or Step one instruction; repeat count times if
ni [
cou n t
] specified.
until [
location
] Continue executing program until either the
specified location is reached, or the current
stack frame returns.
finish Execute program until selected stack frame
returns.
return [
ex pr
] Return from the selected stack frame [setting
return value to expr].
signal [
s
] Resume execution where your program
stopped, but immediately provide the signal s.
go [
lin e
|
address
] Continue executing program; when specified
stop at [line or address].
set var=[
ex pr
] Evaluate expr and assign it to variable var.
Program Stack
backtrace [
fu ll
] [+/-
n
] Print all or n stack frames of current stack trace;
(innermost n frames or outermost –n frames).
full: display local variables also.
frame [
n
] Display current frame or select frame number
n or frame at address n.
up [
n
] Select frame n frames up.
down [
n
] Select frame n frames down.
info frame [
addr
] Describe selected frame, or frame at addr.
info
args
Display the arguments passed to the selected
frame of current stack.
HP WDB Version 6.3
Base Reference Card
http://www.hp.com/go/wdb