...
Command | Example/Short Form | Purpose |
---|---|---|
help help cmd | h h b | Prints GDB command help Prints help for the specific command |
run | r | Begins the program and runs until next breakpoint or program end |
continue | c | Continues the program until next breakpoint or program end |
step | s | Single-step code, descending into functions |
next | n | Single-step code without descending into functions |
finish | fin | Run until the function/loop/etc. is complete |
backtrace | bt | Print the stacktrace |
up | Go up one context level in the stack | |
down | Go down one context level in the stack | |
print variable | p/x foo | Prints the specified variable - this command is very powerful and can be used with arbitrary memory addresses |
break function break file:line break location if expr | b prv_func b module.c:50 b module.c:50 if x > 20 | Set a breakpoint at the specified function Set a breakpoint at the specified line in the specified file Set a breakpoint that will only stop if the expression is true |
info break | i b | Lists breakpoints |
delete delete #breakpoint | d d 1 | Delete all breakpoints Delete the specified breakpoint |
Example
Note |
---|
This example is currently incorrect - the program will function correctly. |
Let's create a simple program to test GDB with. To start, you should be in our development environment.
...