본문 바로가기

Software/Tools

gdb debugging

To use gdb, first compile sources with -g option
>g++ -g ab.out  main.cpp a.cpp b.cpp

Execute the program
> gdb ab.out

To see source
>list

To set break point
>b line number
or
>break line number

to start program
>run

use watch to see a variable continually,
>watch variable name

to see two variable with a condition
when i==j is equal then gdb will stop
>watch i==j

just check current variable
>print variable

on going display a variable
>display variable

go step in side
>step
or
>s

to go next step
>next
or
>n

to resume after check break point
>continue