GDB Operation Basic Command 1 open file and exit operation
Shell input GDB filename: Open a single file
GDB filename-q: Open a single file and block out GdB's own instructions
GDB input Quit (q), exit debugging
2 GDB Command
| Command |
Abbreviation |
Explain |
| File filename |
|
Open File under GdB |
| List |
L |
Displays the code, which displays 10 rows by default. Enter ENTER to display the next 10 lines The list can include additional parameters, such as: List 5,10 shows the code from line 5th to line 10th; The list func shows the code around the Func function, and the display range is related to the list parameter; List test.c:5,10 Displays the code for the source file test.c lines 5th through 10th, Typically used to debug a program with multiple source files. |
| Shell Clear |
|
Empty the shell, clear the screen |
| Break Linenumber/funname |
B |
Break 6: Make a breakpoint on line 6th, or break a point on a function Conditional breakpoint: Break 6 if n = = 0, triggers a breakpoint when the variable n==0 |
| Info |
I |
Info Breakpoints (i B): Show All Breakpoints Info Source View Current Program Info Stack View stack information Info args View current parameter values Info reg outputs The current value of all registers The use of the info frame output stack frame Info b n where n is the specified breakpoint number, displays the state information of the specified breakpoint, and displays information for all breakpoints when no parameter n is added |
| Disable Breaknumber |
|
Disable 1: Make breakpoint 1 unable to be triggered |
| Clear Breaknumber |
|
Clear 1: Delete N-line breakpoints |
| Delete Breaknumber |
|
Delete N Breakpoint, delete all breakpoints by default |
| Run |
R |
Execute the program |
| Next |
N |
The next statement does not enter the function |
| Continue |
C |
Continue execution |
| Step |
S |
Stepping will enter the function body |
| Print variable name or expression |
|
Print the variable or the value of the expression |
| Whatis variable name or expression |
|
Displays the data type of the variable or expression |
| Set variable variable = value |
|
Assign a value to the corresponding variable |
| Watch variable |
|
Sets the watch variable, which triggers when the value of the variable changes |
| Finish |
|
Jump out of the current function |
|
|
|
|
|
|
GDB Operation Basic Command