Conditional breakpoint in gdb
First you have to setup a break point.
(gdb) b 'server::Checks::chkCleardigits(ost::Script::Line*, ost::ScriptImage*)'
don't forget the leading ' before server, so that gdb can complete the whole function prototype for you.
Check breakpoint info
(gdb) info b
Num Type Disp Enb Address What
1 breakpoint keep y 0x080565f4 in server::Checks::chkCleardigits(ost::Script::Line*, ost::ScriptImage*)
at checks.cpp:624
breakpoint already hit 1 time
Run the program, and then you find that there are so many calls to this function. However, you are only interested in one particular call. And most importantly, you know a condition which is unique to this call, line->argc>1
Set condition:
(gdb) condition 1 line->argc>1
(gdb) info b
Num Type Disp Enb Address What
1 breakpoint keep y 0x080565f4 in server::Checks::chkCleardigits(ost::Script::Line*, ost::ScriptImage*)
at checks.cpp:624
stop only if line->argc > 1
breakpoint already hit 1 time
Run, break and check
(gdb) r
Breakpoint 1, server::Checks::chkCleardigits (this=0x8063640, line=0x807cec1, img=0x806e748) at checks.cpp:624
624 if(getMember(line))
(gdb) p line->argc
$17 = 2
(gdb) p line->args[0]
$18 = 0x807ceb5 "=timeout"
(gdb) p line->args[1]
$19 = 0x807cebe "10"
(gdb) p line->args[2]
$20 = 0x0
To remove the condition on this breakpoint, just run
(gdb) condition 1
Updates: fixed a typo
(gdb) b 'server::Checks::chkCleardigits(ost::Script::Line*, ost::ScriptImage*)'
don't forget the leading ' before server, so that gdb can complete the whole function prototype for you.
Check breakpoint info
(gdb) info b
Num Type Disp Enb Address What
1 breakpoint keep y 0x080565f4 in server::Checks::chkCleardigits(ost::Script::Line*, ost::ScriptImage*)
at checks.cpp:624
breakpoint already hit 1 time
Run the program, and then you find that there are so many calls to this function. However, you are only interested in one particular call. And most importantly, you know a condition which is unique to this call, line->argc>1
Set condition:
(gdb) condition 1 line->argc>1
(gdb) info b
Num Type Disp Enb Address What
1 breakpoint keep y 0x080565f4 in server::Checks::chkCleardigits(ost::Script::Line*, ost::ScriptImage*)
at checks.cpp:624
stop only if line->argc > 1
breakpoint already hit 1 time
Run, break and check
(gdb) r
Breakpoint 1, server::Checks::chkCleardigits (this=0x8063640, line=0x807cec1, img=0x806e748) at checks.cpp:624
624 if(getMember(line))
(gdb) p line->argc
$17 = 2
(gdb) p line->args[0]
$18 = 0x807ceb5 "=timeout"
(gdb) p line->args[1]
$19 = 0x807cebe "10"
(gdb) p line->args[2]
$20 = 0x0
To remove the condition on this breakpoint, just run
(gdb) condition 1
Updates: fixed a typo
Comments