CS60 handout, Fall 98

List of classes of commands:
running -- Running the program
stack -- Examining the stack
data -- Examining data
breakpoints -- Making program stop at certain points
files -- Specifying and examining files
status -- Status inquiries
support -- Support facilities
user-defined -- User-defined commands
aliases -- Aliases of other commands
obscure -- Obscure features
internals -- Maintenance commands

Type "help" followed by a class name for a list of commands in that class.
Type "help" followed by command name for full documentation.
Command name abbreviations are allowed if unambiguous.

running:

List of commands:

show args -- Show arguments to give program being debugged when it is started
info handle -- What debugger does when program gets various signals
kill -- Kill execution of program being debugged
target -- Connect to a target machine or process
handle -- Specify how to handle a signal
run -- Start debugged program
continue -- Continue program being debugged
jump -- Continue program being debugged at specified line or address
until -- Execute until the program reaches a source line greater than the current
step -- Step program until it reaches a different source line
next -- Step program
finish -- Execute until selected stack frame returns
nexti -- Step one instruction
stepi -- Step one instruction exactly
signal -- Continue program giving it signal number SIGNUMBER
detach -- Detach a process or file previously attached
attach -- Attach to a process or file outside of GDB
unset environment -- Cancel environment variable VAR for the program
tty -- Set terminal for future runs of program being debugged
set environment -- Set environment variable value to give the program
set args -- Set arguments to give program being debugged when it is started
thread -- Use this command to switch between threads
thread apply -- Apply a command to a list of threads
apply all -- Apply a command to all threads

stack:

Examining the stack.
The stack is made up of stack frames. Gdb assigns numbers to stack frames counting from zero for the innermost (currently executing) frame.

At any time gdb identifies one frame as the "selected" frame. Variable lookups are done with respect to the selected frame. When the program being debugged stops, gdb selects the innermost frame. The commands below can be used to select other frames by number or address.

List of commands:

bt -- Print backtrace of all stack frames
backtrace -- Print backtrace of all stack frames
select-frame -- Select a stack frame without printing anything
frame -- Select and print a stack frame
down -- Select and print stack frame called by this one
up -- Select and print stack frame that called this one
return -- Make selected stack frame return to its caller

breakpoints:

Making program stop at certain points.

List of commands:

awatch -- Set a watchpoint for an expression
rwatch -- Set a read watchpoint for an expression
watch -- Set a watchpoint for an expression
catch -- Set breakpoints to catch exceptions that are raised
break -- Set breakpoint at specified line or function
clear -- Clear breakpoint at specified line or function
delete -- Delete some breakpoints or auto-display expressions
disable -- Disable some breakpoints
enable -- Enable some breakpoints
thbreak -- Set a temporary hardware assisted breakpoint
hbreak -- Set a hardware assisted breakpoint
tbreak -- Set a temporary breakpoint
condition -- Specify breakpoint number N to break only if COND is true
commands -- Set commands to be executed when a breakpoint is hit
ignore -- Set ignore-count of breakpoint number N to COUNT

data:

Examining data.

List of commands:

whatis -- Print data type of expression EXP
ptype -- Print definition of type TYPE
inspect -- Same as "print" command
print -- Print value of expression EXP
call -- Call a function in the program
set -- Evaluate expression EXP and assign result to variable VAR
set variable -- Evaluate expression EXP and assign result to variable VAR
output -- Like "print" but don't put in value history and don't print newline
printf -- Printf "printf format string"
display -- Print value of expression EXP each time the program stops
undisplay -- Cancel some expressions to be displayed when program stops
disassemble -- Disassemble a specified section of memory
x -- Examine memory: x/FMT ADDRESS
delete display -- Cancel some expressions to be displayed when program stops
disable display -- Disable some expressions to be displayed when program stops
enable display -- Enable some expressions to be displayed when program stops