Use GDB to debug code (2Example)

Example 0 :Debug Scheduler.c

Example 1 : Debug LAB5  

<1> Using GDB to Debug Lab5

bash$ gdb Lab5

<2&5> Specify a condition in the program and apply it to any breakpoint.
Let’s stop a loop at the 99th iteration

(gdb) b 112 if i == 99

<3> Delete breakpoint1

(gdb) delete 1

<4> Print values of variables

(gdb) print i

<2&5> Set breakpoint at specified location.

(gdb) break [LOCATION] [if CONDITION]

where
CONDITION is a boolean expression.

<6> Continue running the code

(gdb) continue // read and skip function
(gdb) step // read line by line

原文地址:https://www.cnblogs.com/JasperZhao/p/12914074.html