gdb command:
- Prerequisite: The executable file must contain debugging information gcc -g
- gdb file name - start gdb debugger
- View Code command
current file:
List line number (function name)
the specified file:
List the file name: line number (function name) - Set breakpoints
current file:
b line number (function name)
the specified file:
b File name: line number (function name)
set conditional breakpoints:
b line number if value == 23
View breakpoint information:
info b
remove breakpoints
d breakpoint number - Start Debugging
perform only one line of code: start
continue to stop at the breakpoint: continue - c
stops directly at the breakpoint: run - r - Stepping
into the body of the function: step - s
out of the function body: finish (if the loop at the breakpoint, a breakpoint needs to be deleted)
does not enter the body of the function: next - n - Tracking variable
automatic printing variable information: display variable name
Cancellation variable track: undisplay Number
Gets Number: info display
manually print variable values: print - p
Acquisition variable corresponding type: ptype
- Out of the loop: u
- Quit gdb: quit