For GDB to display debugging information, the compile-time GCC should be added to the-G option, no-G will not see the function name, variable name, instead of the memory address of the runtime. Gcc-g (GDB) l corresponds to list, displaying 10 lines of source (GDB) L 10 Displays the 10 line source (GDB) carriage return at the 10th Behavior Center to repeat the last command (GDB) b 16 set breakpoint at line 16th (GDB) b func at function func entrance set breakpoint (GDB) Info B View breakpoint information to display breakpoint number (GDB) r Run Program (GDB) n Stepping (GDB) C continue Execution (GDB) p i print variable i value (gdb) bt view function stack (GDB) s enter function inside Execution (GDB) Finish jump out function continue execution (GDB) Q exit gdb (GDB) Help View Aid (GDB) set AR GS specifies runtime parameters such as set args 1 2 (gdb) Clear 10 clears 10th line Breakpoint (GDB) Delete clears all breakpoints (GDB) Delete 1 Clear number A breakpoint of 1, you can first view the breakpoint number by Info B (gdb) Disable deactivate, but do not delete breakpoint (GDB) enable a breakpoint (GDB) show args View run parameters (GDB) b 30 if num = = 1 Conditional breakpoint, conditional statement can be expanded with {}, or not (GDB) watch I set the Observer, when the variable i is changed to stop to that line (GDB) Awatch I set the Observer, when the variable i is accessed, is changed to stop The line (GDB) Rwatch sets the observer, and when the variable i is accessed stops to the row (GDB) display I prints the value of the variable I each time it executes to a breakpoint
GDB Common Debug Commands