Here is an example with str_list which is a linked list having a corresponding pretty printer: -var-create - * str_list ^done,name="var1",numchild="3",value="0x9ae2c90",type="GList *",thread-id="1",has_more="0" (gdb) -enable-pretty-printing ^done (gdb) -var-create - * str_list ^done,name="var2",numchild="0",value="{...}",type="GList *",thread-id="1",displayhint="array",dynamic="1",has_more="1" (gdb) -var-evaluate-expression var2 ^done,value="{...}" (gdb) -var-evaluate-expression var1 ^done,value="0x9ae2c90" (gdb) -var-set-visualizer var2 None ^done (gdb) -var-evaluate-expression var2 ^done,value="{...}" (gdb) I expect to get value="0x9ae2c90" instead of value="{...}" as the pretty printer has been removed. Note that -var-list-children and -var-update returns the right value, the same than for var1, without the pretty printer. I can restore the pretty printer, using -var-set-visualizer var2 gdb.default_visualizer. I'm run this test with gdb version 7.0.50.20091001-cvs
I didn't set up a test case for a pointer pretty-printer, but I wonder if invoking -var-update first would help. I see this code in c-varobj.c: /* If the specified format is the current one, we can reuse print_value. */ if (format == var->format) return var->print_value; else return varobj_value_get_print_value (var->value.get (), format, var); So I suspect what's happening is that resetting the visualizer does not change the print_value, and so then gdb thinks it can just reuse the existing one.
I have a somewhat hacky patch for this.
The master branch has been updated by Tom Tromey <tromey@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=d1369de649a9d19abae1012ef805aaa674314c0c commit d1369de649a9d19abae1012ef805aaa674314c0c Author: Tom Tromey <tromey@adacore.com> Date: Thu Aug 31 13:58:49 2023 -0600 Fix bug in -var-evaluate-expression This bug points out that if one uses -var-set-visualizer with "None" -- to disable a pretty-printer for a varobj -- then -var-evaluate-expression will still use pretty-printing. This is a combination of bugs. First, setting the visualizer does not update the display text; and second, computing the display text should use "raw" when Python is available but no visualizer is desired. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=11738 Reviewed-by: Keith Seitz <keiths@redhat.com>
Fixed.