Use GDB to debug code (2-Example)

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

posted @ 2020-05-19 00:48  Jasper2003  阅读(142)  评论(0编辑  收藏  举报