The following tables of commands should be enough to get you started.
| Starting and Stopping | ||
| Command | Description | Example |
| run | Run the program from scratch | run |
| step | Step on one source statement. If it calls a function step into the function | step |
| next | Step on one source statement. If it calls a function step over the function | next |
| cont | Resume program execution (after Ctrl-C or breakpoint) | cont |
| Ctrl-C | Interrupt a running program | Ctrl-C |
| quit | Exit gdb | quit |
| Breakpoints i.e. Places where debugger will suspend execution | ||
| Command | Description | Example |
| break main | Break when main program starts | break main |
| break function | Break when function entered | break Animal::Talk |
| break file:line | Break when source line reached | break Animal.cxx:7 |
| break line | Break when line in current source reached | break 7 |
| info break | List current breakpoints | info break |
| delete n | Delete breakpoint n (omit n for all) | delete 3 |
| disable n | Disable breakpoint n (omit n for all) | delete 3 |
| enable n | Enable breakpoint n (omit n for all) | delete 3 |
| Examining the current execution point | ||
| Command | Description | Example |
| info stack | List the stack i.e. list of active callers from current point back to main program | info stack |
| up | Move up the stack to the caller of the current function | up |
| down | Move down the stack to the callee of the current function | down |
| list | List a few source lines round the current instruction | list |
| list n | List a few source lines round source line n | list 20 |
| list - | List the previous few source lines | list - |
| Examining and modifying variables | ||
| Command | Description | Example |
| print expr | Print the value of an expression. Normally the expression is just the name of a variable | print fSound |
| print *var | Print the value pointed to by variable | print *this |
| setvar = expr | Set variable equal to expression | set fAge = 57 |