This is a reduced example of the structure of my code:
void increment(int j);
int main()
{
int i = 0;
while(1) {
i = increment(i);
}
return 0;
Alternatively to @Matt answer, and if you use GDB 7.4, you can use FinishBreakpoints, with something like (untested -- I'm not sure that comments are accepted here):
(gdb) python #first defined the class
class MyFinishBreakpoint (gdb.FinishBreakpoint):
def stop (self):
print "%s" % gdb.parse_and_eval("i")
return False # don't want to stop
end
(gdb) break doSomething
(gdb) commands
# then set the FinishBreakpoint silently
silent
py MyFinishBreakpoint()
continue
(and a link to the documentation)