Get to one of the tricks of GDB debugging program under Linux today and share it with you! Usually we use the GCC programming, the program debugging, the observation program jumps and so on is not so intuitive. It's all in the interface!
But if we add the executable file generated by the-G command when we compile the connection, with Gdb-tui-q p2psrv (the command to debug), you can enter a similar visual debugging interface.
After believing that some basic GDB operations should be clear to everyone.
BackTrace: View function calls and parameters at all levels
Finish: run continuously until the current function returns, and then stop waiting for the command
frame (or F) Framing number: Select Stack Frame
info (or i) Locals: View the value of the current stack frame local variable
list (or L): lists the source code, followed by the last position, column 10 row at a time
List function Name: List The source code of a function
Next (N): Executes the next line of statements
Print (or P): Prints the value of the expression, which can be modified by the expression to modify the value of the variable or call the function
Quit (or Q): Exit GDB Debug Environment
Set VAR: Modifying the value of a variable
Start: Begin executing the program, stop waiting for the command before the first sentence of the main function
Step; Execute the next sentence and enter the function if there is a function call
You can try it now!
| Command |
Description |
| BackTrace (or BT) |
View function calls and parameters at all levels |
| Finish |
Run continuously until the current function returns, and then stop waiting for the command |
| FRAME (or F) Framing number |
Select Stack Frame |
| info (or i) locals |
View the value of the current stack frame local variable |
| List (or L) |
List the source code, followed by the last position, column 10 row at a time |
| List line number |
List source code starting from the first few lines |
| List function name |
List the source code for a function |
| Next (or N) |
Executes the next line of statements |
| Print (or P) |
Prints the value of an expression, through which the value of the variable can be modified or the function is called |
| Quit (or Q) |
Exiting the gdb debugging environment |
| Set Var |
Modifying the value of a variable |
| Start |
Start executing the program, stop main waiting for the command in front of the first line of the function statement |
| Step (or S) |
Executes the next line of statements and enters into the function if there is a function call |
Visual debugging of GDB in Linux