1. There are two ways to release background
programs, debug mode and release mode . For
binary programs from Linux gcc/g++, the default is release mode.
To use gdb to debug, you must add the -g option when generating binary programs from source code.
programs, debug mode and release mode . For
binary programs from Linux gcc/g++, the default is release mode.
To use gdb to debug, you must add the -g option when generating binary programs from source code.
2. Start using
gdb binFile to exit: ctrl+d or quit debugging command:
list/l Line number: display the binFile source code, then the last position goes to the following, each column 10 lines
list/l function name: list a certain The source code of the function
r or run: run the program
n or next: single execution
s or step: enter the function call
break (b) Line number: set a breakpoint
break at a certain line function name: set a breakpoint
info break at the beginning of a function : View breakpoint information
finish: Execute until the current function returns, then stop and wait for the command
print(p): Print the value of the expression, through the expression, you can modify the value of the variable or call the function
p Variable: Print the value of the variable
set var: Modify The value of the variable
continue (or c): executes the program continuously instead of stepping from the current position
run (or r) executes the program continuously instead of stepping from the beginning
gdb binFile to exit: ctrl+d or quit debugging command:
list/l Line number: display the binFile source code, then the last position goes to the following, each column 10 lines
list/l function name: list a certain The source code of the function
r or run: run the program
n or next: single execution
s or step: enter the function call
break (b) Line number: set a breakpoint
break at a certain line function name: set a breakpoint
info break at the beginning of a function : View breakpoint information
finish: Execute until the current function returns, then stop and wait for the command
print(p): Print the value of the expression, through the expression, you can modify the value of the variable or call the function
p Variable: Print the value of the variable
set var: Modify The value of the variable
continue (or c): executes the program continuously instead of stepping from the current position
run (or r) executes the program continuously instead of stepping from the beginning
delete breakpoints: delete all breakpoints
delete breakpoints n: delete the breakpoint number n
disable breakpoints: disable breakpoints
enable breakpoints: enable breakpoint
info (or i) breakpoints: view which breakpoints are currently set
display variable name: track view A variable, display its value every time you stop
undisplay: cancel the trace of those variables previously set
until X line number: jump to X line
breakrace: view all levels of function calls and parameters
info (or i) locals: view the current The value of the stack frame local variable
quit: Exit gdb
The following briefly demonstrates some common options:
delete breakpoints n: delete the breakpoint number n
disable breakpoints: disable breakpoints
enable breakpoints: enable breakpoint
info (or i) breakpoints: view which breakpoints are currently set
display variable name: track view A variable, display its value every time you stop
undisplay: cancel the trace of those variables previously set
until X line number: jump to X line
breakrace: view all levels of function calls and parameters
info (or i) locals: view the current The value of the stack frame local variable
quit: Exit gdb
The following briefly demonstrates some common options: