GDB debugging usage record

GDB tutorial summary

You need to add the -g parameter when compiling and generating gcc, so that you can use gdb
gcc main.cpp -o main -g
and then
gdb main (the name of the generated executable program)
enters gdb debugging and
enter r to start debugging the program.
Enter b 7 (line number) to breakpoint on the seventh line of the current file.
Output c to continue running the program

Summary of gdb commands

break Add a breakpoint, abbreviated as p
print, print print, abbreviated as p
run, run a program, abbreviated as r
continue, continue to run, abbreviated as c
quit, exit gdb, abbreviated as q
list: view the original code (list-n, start to view the code from line n. list+ Function name: view the specific function), abbreviation l
next: single step debugging (step by step, function directly executed), abbreviation n
step: single step debugging (step by statement: jump into the execution of a custom function), abbreviation s
backtrace: view function The stack frame and hierarchical relationship of the call, abbreviated bt
frame: switch the stack frame of the function, abbreviated f
info: view the value of the local variable inside the function, abbreviated i

Guess you like

Origin blog.csdn.net/weixin_39308337/article/details/109457877