I stumbled upon the auto-display functionality of gdb, which is pretty powerful and convenient. After calling
(gdb) display/i $pc
(gdb) display $rax
the watched values are displayed automatically after every step:
(gdb) si
0x0804805e in print_loop_start ()
2: $rax = 0
1: x/i $pc
=> 0x804805e <print_loop_start+6>: mov 0x4(%ebp,%eax,4),%ecx
But how can I "unwatch" the value in $rax, if it is no longer of interest?
Enables automatic displaying of certain expressions each time GDB stops at a breakpoint or after a step.
To add an expression or address to the automatic display list, use the display command. To disable or enable an item in the automatic display list, use the disable display or the enable display command.
Gdb help for display says:
"Use
undisplay
to cancel display requests previously made."
So if you do display a
, then display b
, and display c
gdb will give numbers to this requests (which you can see by issuing replay with no arguments). Then you can use this numbers with undisplay
.
Example:
(gdb) display a
1: a = 32767
(gdb) display b
2: b = 0
(gdb) display c
3: c = 0
(gdb) undisplay 2
(gdb) step
6 b = 2;
1: a = 1
3: c = 0
Details in gdb documentation.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With