Running
|
Start GDB (with optional core dump) |
|
Start GDB and pass arguments |
|
Start GDB and attach to process |
|
Set arguments to pass to program to be debugged |
|
Run the program to be debugged |
|
Kill the running program |
Breakpoints
|
Set a new breakpoint |
|
Remove a breakpoint |
|
Delete all breakpoints |
|
Enable a disabled breakpoint |
|
Disable a breakpoint |
Watchpoints
|
Set a new watchpoint |
|
Delete a watchpoint |
|
Enable a disabled watchpoint |
|
Disable a watchpoint |
Where
|
Break/watch the named function |
|
Break/watch the line number in the current source file |
|
Break/watch the line number in the named source file |
Conditions
|
Break/watch at the given location if the condition is met. Condition may be almost any C expression that evaluates to |
|
Set/change the condition of an existing break or watchpoint |
Examining the Stack
|
Show call stack |
|
Show call stack, also print the local variables in each frame |
|
Select the stack frame to operate on |
Stepping
|
Go to next instruction (source line), diving into function |
|
Go to next instruction (source line) but do not dive into function |
|
Continue until the current function returns |
|
Continue normal execution |
Variables and Memory
|
Print content of variable/memory location/register |
|
Like |
|
Remove the |
|
Enable or disable the |
|
Print memory
Unit is one of: |
Format
|
Pointer |
|
Read as integer, print as character |
|
Integer, signed decimal |
|
Floating point number |
|
Integer, print as octal |
|
Try to treat as C string |
|
Integer, print as binary (t = 'two') |
|
Integer, unsigned decimal |
|
Integer, print as hexadecimal |
What
|
Almost any C expression, including function calls (must be prefixed with a cast to tell GDB the return value type) |
|
Content of the variable defined in the name file (static variables) |
|
Content of the variable defined in the name function (if on the stack) |
|
Content at address, interpreted as being of the C type |
|
Content of named register. Interesting registers are |
Threads
|
Choose thread to operate on |
Manipulate the Program
|
Change the content of a variable to the given value |
|
Force the current function to return immediately, passing the given value |
Sources
|
Add directory to the list of directories that is searched for sources |
|
Shows the current or given source context. The filename may be omitted. If last is omitted the context starting at start is printed instead of centered around it |
|
Set how many lines to show in |
Signals
|
Set how to handle signals Options are: |
Information
|
Disassemble the current function or given location |
|
Print the arguments to the function of the current stack frame |
|
Print information about the breakpoints and watchpoints |
|
Print information about the |
|
Print the local variables in the currently selected stack frame |
|
List loaded shared libraries |
|
List all signals and how they are currently handled |
|
List all threads |
|
Print all directories in which GDB searches for source files |
|
Print how many are shown in the |
|
Print type of named variable |
Notes
- Based on the cheat sheet from Marc's realm
- Converted by Li Xinyang