I have a code full of functions like:
bool f_i()
{
if (!f_0()) {
return false;
}
if (!f_1()) {
return false;
}
// ...
if (!f_n()) {
return false;
}
return true;
}
// etc...
On some step of execution some callee can return false
, and false
propagates through all the callers. It is hard to write error messages at the moment (code is rapidly changed). During debugging it is excessive to have error mesages before every return false;
.
Is it possible to set conditional (condition: say, function return false
) breakpoint on return
statment globally, using GDB
?
On some step of execution some callee can return false
As I understand, you want to find the first function which returned false
inside f_i()
. You can use reverse debugging for this.
You can:
finish current frame execution
(gdb) fin
step backwards, if return value is false
(gdb) reverse-step
if you need, you can continue to go backwards, deeper into false
propagation calls
(gdb) reverse-fin
(gdb) reverse-step