[25/30] Change print_variable_and_value to take a block_symbol

Message ID 20231029-split-objfile-2023-bound-sym-october-v1-25-612531df2734@tromey.com
State New
Headers
Series Baby step for objfile splitting |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_gdb_build--master-aarch64 success Testing passed
linaro-tcwg-bot/tcwg_gdb_build--master-arm success Testing passed
linaro-tcwg-bot/tcwg_gdb_check--master-arm success Testing passed
linaro-tcwg-bot/tcwg_gdb_check--master-aarch64 success Testing passed

Commit Message

Tom Tromey Oct. 29, 2023, 11:23 p.m. UTC
  This changes print_variable_and_value to accept a block_symbol and to
use the new read_var_value overload.
---
 gdb/printcmd.c | 9 +++------
 gdb/stack.c    | 6 +++++-
 gdb/value.h    | 2 +-
 3 files changed, 9 insertions(+), 8 deletions(-)
  

Patch

diff --git a/gdb/printcmd.c b/gdb/printcmd.c
index cb7023b1880..886361dff89 100644
--- a/gdb/printcmd.c
+++ b/gdb/printcmd.c
@@ -2398,10 +2398,11 @@  clear_dangling_display_expressions (struct objfile *objfile)
    This function invalidates FRAME.  */
 
 void
-print_variable_and_value (const char *name, struct symbol *var,
+print_variable_and_value (const char *name, block_symbol bvar,
 			  frame_info_ptr frame,
 			  struct ui_file *stream, int indent)
 {
+  symbol *var = bvar.symbol;
 
   if (!name)
     name = var->print_name ();
@@ -2414,11 +2415,7 @@  print_variable_and_value (const char *name, struct symbol *var,
       struct value *val;
       struct value_print_options opts;
 
-      /* READ_VAR_VALUE needs a block in order to deal with non-local
-	 references (i.e. to handle nested functions).  In this context, we
-	 print variables that are local to this frame, so we can avoid passing
-	 a block to it.  */
-      val = read_var_value (var, NULL, frame);
+      val = read_var_value (bvar, frame);
       get_user_print_options (&opts);
       opts.deref_ref = true;
       common_val_print_checked (val, stream, indent, &opts, current_language);
diff --git a/gdb/stack.c b/gdb/stack.c
index 0bf2b19fad7..6916df77929 100644
--- a/gdb/stack.c
+++ b/gdb/stack.c
@@ -2268,6 +2268,7 @@  struct print_variable_and_value_data
   int num_tabs;
   struct ui_file *stream;
   int values_printed;
+  const struct block *block;
 
   void operator() (const char *print_name, struct symbol *sym);
 };
@@ -2296,7 +2297,8 @@  print_variable_and_value_data::operator() (const char *print_name,
       return;
     }
 
-  print_variable_and_value (print_name, sym, frame, stream, num_tabs);
+  print_variable_and_value (print_name, { sym, block }, frame,
+			    stream, num_tabs);
 
   /* print_variable_and_value invalidates FRAME.  */
   frame = NULL;
@@ -2363,6 +2365,7 @@  print_frame_local_vars (frame_info_ptr frame,
   cb_data.num_tabs = 4 * num_tabs;
   cb_data.stream = stream;
   cb_data.values_printed = 0;
+  cb_data.block = block;
 
   /* Temporarily change the selected frame to the given FRAME.
      This allows routines that rely on the selected frame instead
@@ -2529,6 +2532,7 @@  print_frame_arg_vars (frame_info_ptr frame,
   cb_data.num_tabs = 0;
   cb_data.stream = stream;
   cb_data.values_printed = 0;
+  cb_data.block = func->value_block ();
 
   iterate_over_block_arg_vars (func->value_block (), cb_data);
 
diff --git a/gdb/value.h b/gdb/value.h
index 7cb830110fc..81c53536416 100644
--- a/gdb/value.h
+++ b/gdb/value.h
@@ -1534,7 +1534,7 @@  extern int val_print_string (struct type *elttype, const char *encoding,
 			     const struct value_print_options *options);
 
 extern void print_variable_and_value (const char *name,
-				      struct symbol *var,
+				      block_symbol var,
 				      frame_info_ptr frame,
 				      struct ui_file *stream,
 				      int indent);