GDB is a debugger that uses a command-line interface. It allows us to run the program up to a certain point, then stop and print out the values of selected variables at that point, or after every line step through the program. It also allows us to print the values of each variable after executing each line.
The commands that are most frequently used in GDB are listed in the table below:
Command | Description |
| Puts a breakpoint at the beginning of the program |
| This command puts a break at the current line |
| This command puts a break at the Nth line |
| This command puts a breakpoint at the beginning of the function func. |
| This command deletes the breakpoint number M. |
| This command runs the program until a breakpoint/error. |
| kk |
| This command list breakpoints. |
| This command funs until the current function is executed. |
| This command runs the next line of the program |
| This command runs the next M lines of the program. |
| This command prints the value currently stored in the variable val. |
| This command goes up a level in the stack |
| This command goes down a level in the stack |
| This command quits GDB. |
| This command display a summary of all threads currently in your program. |
| This command print the names along with values of all registers except floating-point registers |
| This command uses the specified format to display the memory contents at a given address. |
| This command allows you to move from one stack frame to another, and to print the stack frame you select. arg can either the stack frame number or frame's address. If no argument is passed, frame prints the current stack frame. |
Note: More information about GDB can be found here.
Free Resources