Command | Description |
---|---|
gdb <program> |
Start GDB with the specified program. |
gdb -q |
Start quietly (no intro). |
run [args] |
Run program with optional args. |
start |
Run until main() and break. |
attach <pid> |
Attach to a running process. |
detach |
Detach from process. |
quit |
Exit GDB. |
Command | Description |
---|---|
break <function> |
Break at function. |
break <file:line> |
Break at file:line. |
break *<address> |
Break at memory address. |
info breakpoints |
List breakpoints. |
delete <n> |
Delete breakpoint n. |
disable <n> |
Disable breakpoint n. |
enable <n> |
Enable breakpoint n. |
condition <n> <expr> |
Breakpoint n triggers only if expr is true. |
Command | Description |
---|---|
next / n |
Step over (don’t enter functions). |
step / s |
Step into function. |
finish |
Run until current function returns. |
continue / c |
Resume execution. |
until <line> |
Continue until line reached. |
Command | Description |
---|---|
print <expr> |
Print expression. |
display <expr> |
Auto-print expr each stop. |
undisplay <n> |
Remove auto-print n. |
backtrace / bt |
Show call stack. |
frame <n> |
Switch to frame n. |
info locals |
Show local variables. |
info args |
Show function arguments. |
x/<nfu> <addr> |
Examine memory (n=repeat count, f=format, u=unit size). Example: x/16xb $sp . |
Command | Description |
---|---|
set var <expr>=<val> |
Change variable value. |
return <expr> |
Force current function to return expr. |
jump <line> |
Jump to line. |
Command | Description |
---|---|
kill |
Stop program. |
signal <sig> |
Send signal to program. |
handle <sig> <action> |
Control how GDB handles signals. |
Command | Description |
---|---|
info registers |
Show CPU registers. |
info threads |
List threads. |
thread <n> |
Switch to thread n. |
watch <expr> |
Break when expr changes. |
help |
Show help. |
apropos <keyword> |
Search help topics. |
Tip: Use tab completion and help <command>
inside GDB for details.