Gdb debugging note: Must I add the Gcc compilation option? G. exit GDB: quit or Ctrl & amp; 43; D. the debugging process is as follows: 1.
Gdb debugging
Note:-g must be added to the Gcc compilation options.
Exit GDB: quit or Ctrl + d
Debugging process:
1. View files
Command:(Gdb) l
2. set breakpoints
Command:(Gdb) B row number
Note: up to 17th rows are stopped, and 17 rows are not executed.
3. view the breakpoint info B
4. run code r
Command:(Gdb) r
(You can also specify the row to start running, and add the row number after r)
5. View variable value p
Command:(Gdb) p variable name
6. set monitoring point: watch z (variable name)
It can also be a complex expression.
7. one-step operation
Command:(Gdb) n(Process by process)
8. step by step, it will enter the function
Command:(Gdb) s
9. conditional breakpoint
Change normal breakpoint to conditional breakpoint: condition
For example:Condition 1 I = 10
The checkpoint 1 is paused only when the condition I = 1 is met.
10. resume program running c
Command:(Gdb) c
(The program will run. if there is no breakpoint, the remaining part will be run. if there is a breakpoint, it will run to the next breakpoint)
11. remove breakpoints
Clear line_number
Clear filename: line_number
12. help
12.1 help find the category
12.2help from the list