ead
ead

Reputation: 34347

GDB: How to remove a variable from the auto display

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?

Upvotes: 22

Views: 19803

Answers (2)

Gem Taylor
Gem Taylor

Reputation: 5613

Note that you can also temporarily hide a disp output using:

disable display dnums…

And re-enable with:

enable display dnums…

Upvotes: 2

dbrank0
dbrank0

Reputation: 9476

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.

Upvotes: 35

Related Questions