Use GDB to debug code (2-Example)

<1> Using GDB to Debug a Program

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

猜你喜欢

转载自www.cnblogs.com/JasperZhao/p/12914074.html