Linux Debugger GdB
First, GDB introduction
The debugger in the GNU toolset is GDB, the program is an interactive tool that works in character mode.
In addition to GDB, Linux is more well-known under the debugger and Xxgdb, DDD, kgdb, UPS.
second, the use of GDB
GDB is a powerful debugger that completes the following debugging tasks:
1. Set breakpoints
Break line number//run to a line stop
Break function name//stop when run to specified function function
Break line number/function name if condition//Match if condition statement, run to specified location stop
2, the value of the monitor variable
Print variable name/expression
Whatis variable name/function name//display data type
PType variable name/function name//display data type and definition
3. Single step execution of the program
4, Show/Modify the value of the variable
5. Display/Modify Registers
6, view the stack of the program
7. Remote Debugging
Q exit
List shows the code following the current line
Parameters:
+ Shows the code following the current line number
-Displays the code before the current line number
N shows the code around the first few lines
The function name shows the internal code of the function name
First,last shows code between the last
, last chevalier code between the current line and the last
Set Listsize count sets the number of lines of code to display at one time
Show Listsize shows the number of rows displayed at one time
first to add debugging information before use: Gcc–g test.c–o test
after: GDB test
and then you can debug it by command.
Eg:
Debugging Information: