This section summarizes the GDB commands by task. Esoteric commands, such as those used by GDB's maintainers, or to cross-debug remote systems connected via serial port or a network, have been omitted.
awatch | Set an expression watchpoint. |
break | Set a breakpoint at a line or function. |
catch | Set a catchpoint to catch an event. |
clear | Clear a given breakpoint. |
commands | Specify commands to run when a breakpoint is reached. |
condition | Supply a condition to a particular breakpoint. |
delete | Delete one more breakpoints or auto-display expressions. |
disable | Disable one or more breakpoints. |
enable | Enable one or more breakpoints. |
hbreak | Set a hardware assisted breakpoint. |
ignore | Set the ignore-count of a particular breakpoint. |
rbreak | Set a breakpoint for all functions matching a regular expression. |
rwatch | Set a read watchpoint for an expression. |
tbreak | Set a temporary breakpoint. |
tcatch | Set a temporary catchpoint. |
thbreak | Set a temporary hardware assisted breakpoint. |
watch | Set an expression watchpoint. |
call | Call a function in the program. |
delete display | Cancel one or more expressions that have been set to display when the program stops. |
delete mem | Delete a memory region. |
disable display | Disable one or more expressions that have been set to display when the program stops. |
disable mem | Disable a memory region. |
disassemble | Disassemble a section of memory. |
display | Print the value of an expression each time the program stops. |
enable display | Enable one or more expressions that have been set to display when the program stops. |
enable mem | Enable a memory region. |
inspect | Same as print. |
mem | Define attributes for a memory region. |
output | Similar to print, but doesn't save the value in history and doesn't print a newline. For scripting. |
print | Print the value of an expression. |
print-object | Cause an Objective C object to print information about itself. |
printf | Print values like the printf command. |
ptype | Print the definition of a given type. |
set | Evaluate an expression and save the result in a program variable. |
set variable | Same as set, avoids conflict with GDB variables. |
undisplay | Cancel one or more expressions that have been set to display when the program stops. |
whatis | Print the data type of an expression. |
x | Examine memory: x/fmt address. See the entry for x in the later section "Alphabetical Summary of GDB Commands." |
add-symbol-file
Add symbols from a dynamically loaded file to GDB's symbol table.
add-symbol-file-from-memory
Load the symbols from a dynamically loaded object file in the debuggee's memory.
cd
Set the current directory for GDB and the debuggee.
core-file
Specify a file to use as the core dump for memory and register contents.
directory
Add a directory to the beginning of the source file search path.
edit
Edit a file or function.
exec-file
Specify a file to use as the executable.
file
Specify the filename of the program to be debugged.
forward-search
Search forward in the current source file for a regular expression, starting at the last line listed.
generate-core-file
Create a core file from the current state of the debuggee.
list
List a function or line.
nosharedlibrary
Unload all shared object library symbols.
path
Add one or more directories to the object file search path.
pwd
Print the current directory.
reverse-search
Search backward in the current source file for a regular expression, starting at the last line listed.
search
Same as forward-search.
section
Change the base address of a particular section in the exec file.
sharedlibrary
Load shared object library symbols for files matching a regular expression.
symbol-file
Load symbol table information from a specified executable file.
advance | Continue the program up to the given location. |
attach | Attach to a process or file outside of GDB. |
continue | Continue the program being debugged. |
detach | Detach a previously attached process or file. |
finish | Execute until selected stack frame returns. |
handle | Specify how to handle a signal. |
interrupt | Interrupt the execution of the debugged program. |
jump | Continue program being debugged at specified line or address. |
kill | Kill the program being debugged. |
next | Execute the program's next statement. |
nexti | Execute the program's next instruction. |
run | Start the debugged program. |
signal | Continue the program, giving it a specified signal. |
start | Run the debugged program until the beginning of the main procedure. Useful for C++ where constructors run before main( ). |
step | Step the program until it reaches a different source line. Descends into called functions. |
stepi | Step exactly one instruction. |
thread | Switch between threads. |
tHRead apply | Apply a command to a list of threads. |
tHRead apply all | Apply a command to all threads. |
tty | Set the terminal for future runs of the debuggee. |
unset environment | Remove a variable from the debuggee's environment. |
until | Execute until the program reaches a source line greater than the current one. |
apropos | Search for commands matching a regular expression. |
complete | List the command completions for the rest of the line. |
define | Define a new command. |
document | Document a user-defined command. |
dont-repeat | Don't repeat this command. For use in user-defined commands. |
down-silently | Same as the down command, but doesn't print messages. |
echo | Print a constant string. |
else | Provide a list of alternative commands for use with if. |
end | End a list of commands or actions. |
help | Print list of commands. |
if | Execute nested commands once if the conditional expression is nonzero. |
make | Run the make program using the rest of the line as arguments. |
quit | Exit GDB. |
shell | Execute the rest of the line as a shell command. |
source | Read commands from a named file. |
up-silently | Same as the up command, but doesn't print messages. |
while | Execute nested commands while the conditional expression is nonzero. |
GDB offers a bewilderingly large number of commands, but most users can get by with just a small handful. Table 17-1 lists the ones that you are likely to use most often.