I am using totalview as a linux C++ debugger. Functions in our code often look something like this
double foo() {
int a = 2;
int b = 3;
return bar(a,b);
}
where some preliminary work is done and than a more or less complex function bar
is called a the return statement.
This is hard to debug with totalview, since the interesting return value can not be observed easily. Totalview can not evaluate the expressing bar(a,b)
. I can rewrite the code as
double foo() {
int a = 2;
int b = 3;
const auto retVal = bar(a,b);
return retVal;
}
Now, I can place a breakpoint at the return value and observe the in- and output of my function bar
.
How can I do this without introducing a new (useless) variable?