|
| 1 | +# GDB - List of Commands |
| 2 | + |
| 3 | +## Basic Commands |
| 4 | + |
| 5 | +| Command | Short version | Description | |
| 6 | +| ------- | ------------- | ----------- | |
| 7 | +| run | r | The run command causes execution of the program to start from the beginning | |
| 8 | +| quit | q | Exit GDB debugger | |
| 9 | +| breakpoint *location* | b *location* | The breakpoint command sets a breakpoint in a certain location. (line, function, etc) | |
| 10 | +| print *expression* | p *expression* | This will print the value of the given expression. | |
| 11 | +| continue | c | Continues execution following a breakpoint, until the next breakpoint or the termination of the program. | |
| 12 | +| step | s | Executes a single line after a breakpoint. | |
| 13 | +| next | n | Executes a single line. If this line is a subprogram call, executes and returns from the call. | |
| 14 | +| list | l | Lists a few lines around the current source location. | |
| 15 | +| backtrace | bt | Displays a backtrace of the call chain. | |
| 16 | + |
| 17 | +## Execution control |
| 18 | + |
| 19 | +| Command | Short version | Description | |
| 20 | +| ------- | ------------- | ----------- | |
| 21 | +| run | r | Start program execution | |
| 22 | +| run *command-line-arguments* | r *command-line-arguments* | Start program execution | |
| 23 | +| run < *stdin-file* > *stdout-file* | r < *stdin-file* > *stdout-file* | Start program execution with IO redirection | |
| 24 | +| continue | c | Continues program execution until encounters a breakpoint | |
| 25 | +| kill | | Kills the current process | |
| 26 | +| quit | q | Exit GDB debugger | |
| 27 | + |
| 28 | +## Breakpoint management |
| 29 | + |
| 30 | +| Command | Description | |
| 31 | +| ------- | ----------- | |
| 32 | +| break function-name | Set a breakpoint at specified function | |
| 33 | +| break line-number | Set a breakpoint at specified line number | |
| 34 | +| break ClassName::functionName | Set a breakpoint at specified class function | |
| 35 | +| break +offset | Set a breakpoint specified number of lines forward from the current position | |
| 36 | +| break -offset | Set a breakpoint specified number of lines back from the current position | |
| 37 | +| break filename:function | Set a breakpoint at specified function inside a file | |
| 38 | +| break filename:line-number | Set a breakpoint at specified line number of a file | |
| 39 | +| break *address | Set a breakpoint at specified instruction address | |
| 40 | +| break line-number if condition | Set a breakpoint if the condition is met | |
| 41 | +| break line thread thread-number | Set a breakpoint in the thread specified by the line number | |
| 42 | +| tbreak | Set a temporary break (break once only) | |
| 43 | +| watch condition | Suspend execution when the condition is met | |
| 44 | +| clear | Delete breakpoints | |
| 45 | +| clear function | Delete all breakpoints in function | |
| 46 | +| clear *line-number* | Delete breakpoints at specified line number | |
| 47 | +| delete | Delete all breakpoints, watchpoints, or catchpoints | |
| 48 | +| delete *breakpoint-number* | Delete the breakpoint specified | |
| 49 | +| delete *breakpoint-number*-*breakpoint-number* | Delete the breakpoints inside the specified range. ex: delete 1-4 | |
| 50 | +| disable *breakpoint-number* | Disable the breakpoint specified | |
| 51 | +| disable *breakpoint-number*-*breakpoint-number* | Disable the breakpoints inside the specified range, ex: disable 1-4 | |
| 52 | +| enable *breakpoint-number* | Enable the breakpoint specified | |
| 53 | +| enable *breakpoint-number*-*breakpoint-number* | Enable the breakpoints inside the specified range, ex: enable 1-4 |
| 54 | + |
| 55 | +## Analyse stack |
| 56 | + |
| 57 | +| Command | Short version | Description | |
| 58 | +| ------- | ------------- | ----------- | |
| 59 | +| backtrace | bt | Print stack backtrace | |
| 60 | +| backtrace full | | Print values of local variables | |
| 61 | +| frame | f | Show current stack frame |
| 62 | +| frame number | f number | Show the specified frame number | |
| 63 | +| up | | Move up a single frame | |
| 64 | +| down | | Move down a single frame | |
| 65 | +| up number | | Move up the specified number of frames in the stack | |
| 66 | +| down number | | Move down the specified number of frames in the stack | |
| 67 | +| info frame | | List address, language, address of arguments/local variables and which registers were saved in a frame. |
| 68 | +| info args | | Info arguments of the selected frame | |
| 69 | +| info locals | | Info arguments of the selected local variables | |
| 70 | +| info catch | | Info arguments of the selected exception handlers | |
0 commit comments