Use common_val_print_checked in print_variable_and_value
authorTom Tromey <tromey@adacore.com>
Thu, 15 Apr 2021 16:14:11 +0000 (10:14 -0600)
committerTom Tromey <tromey@adacore.com>
Thu, 15 Apr 2021 16:14:11 +0000 (10:14 -0600)
GDB was crashing in "bt full" for a large Ada program.  I tracked this
down to a combination of bugs.

The first bug, fixed here, is that print_variable_and_value calls
common_val_print.  Normally only the value-printing implementation
should call this; from the top level, common_val_print_checked is
preferred, because it correctly handles values that are wholly
optimized out.

I wasn't able to write a test case for this.

gdb/ChangeLog
2021-04-15  Tom Tromey  <tromey@adacore.com>

* printcmd.c (print_variable_and_value): Use
common_val_print_checked.

gdb/ChangeLog
gdb/printcmd.c

index 22a79c2f88c98a6cc3fe374b244ba37fe0acd6c1..54a035c51bbf92095fe896d6ca6b3390c081606a 100644 (file)
@@ -1,3 +1,8 @@
+2021-04-15  Tom Tromey  <tromey@adacore.com>
+
+       * printcmd.c (print_variable_and_value): Use
+       common_val_print_checked.
+
 2021-04-15  Tom Tromey  <tromey@adacore.com>
 
        * rust-exp.y (rust_parser::convert_ast_to_expression): Update.
index c82f709136f9909c48954e85c6d528e93f34862d..a4f62f207d003267ffeb987d036d2b5fe7beb3f4 100644 (file)
@@ -2387,7 +2387,7 @@ print_variable_and_value (const char *name, struct symbol *var,
       val = read_var_value (var, NULL, frame);
       get_user_print_options (&opts);
       opts.deref_ref = 1;
-      common_val_print (val, stream, indent, &opts, current_language);
+      common_val_print_checked (val, stream, indent, &opts, current_language);
 
       /* common_val_print invalidates FRAME when a pretty printer calls inferior
         function.  */