Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GDB: How to remove a variable from the auto display

Tags:

gdb

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?

like image 717
ead Avatar asked Jul 01 '16 18:07

ead


People also ask

Which command enables automatic displaying the current contents of certain variables each time GDB stops at a breakpoint?

Enables automatic displaying of certain expressions each time GDB stops at a breakpoint or after a step.

How do you stop a variable showing in GDB?

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.


1 Answers

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.

like image 98
dbrank0 Avatar answered Oct 07 '22 12:10

dbrank0