Reputation: 2579
I have a code snippet similar to this :
int test( /* some arguments */)
{
ret = func(/* some arguments */)
if (ret < 0)
{
/* do this */
}
/* do this */
return ret;
}
the function func
is returning -1 for some erroneous condition inside the function. This erroneous condition occurs once in 100 times the test
function is called - so I put breakpoint in if (ret < 0)
line. Now I want to debug what's going on inside the function func()
. How do I do it when the breakpoint is hit in test
function at the said line.
Upvotes: 0
Views: 176
Reputation: 16582
Is the behaviour deterministic? If so, breakpoint hit-counters are good for this. You can set a very large count breakpoint somewhere before the error is generated, break also on the error being returned, look at the counter, and then change the count to break at count-1. Then you can then debug the error as it occurs, and the breakpoint can be anywhere in the code, not just at the exact point or error.
Conditional breakpoints are underused...
Upvotes: 0
Reputation: 31952
I would put a break point at
return -1;
within the function itself. In the way you are doing, the stack frame of the function would have been destroyed already. You COULD run the function again with the same arguements if you can move the code pointer, but if the function has side effects, it may not react the same way. I am not sure how to do it though, perhaps it needs the jump command.
Upvotes: 2