Reputation: 3235
I know this could be a pipe dream, just throw it here.
So here is the code:
int f()
{
int i = 0;
int j = 0;
for (; i < 10 && j < 100; ++i, j = i * 2) {
i = f2();
}
}
So when it comes to function f(), I can run "disp i j" and then after each single line step over, the values of i and j print out. It works fine.
But is there a global setting or some trick so that, I do not need to type the "display" command, all local variables are automatically printed AND they are printed only when their values are updated.
Another words, at the line i = f2()
, the value of j does not print.
Upvotes: 0
Views: 342
Reputation: 992
You can set the watchponits on i
and j
. Like this
(gdb) watch i
It will automatically print the value of i
whenever value of i
changes
You can also print the value based upon some condition using if<condition>
. Like this
(gdb) watch i if j==4
For me there is no issue in printing the value of j
at
i = f2();
line.
Upvotes: 1