[24/30] Use read_var_value in read_frame_arg and read_frame_local

Message ID 20231029-split-objfile-2023-bound-sym-october-v1-24-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-aarch64 success Testing passed
linaro-tcwg-bot/tcwg_gdb_check--master-arm success Testing passed

Commit Message

Tom Tromey Oct. 29, 2023, 11:23 p.m. UTC
  This changes read_frame_arg and read_frame_local to take a
block_symbol and to use the new read_var_value overload.k
---
 gdb/frame.h                 |  6 +++---
 gdb/mi/mi-cmd-stack.c       | 20 ++++++++++----------
 gdb/python/py-framefilter.c |  8 ++++----
 gdb/stack.c                 | 27 ++++++++++++++-------------
 4 files changed, 31 insertions(+), 30 deletions(-)
  

Patch

diff --git a/gdb/frame.h b/gdb/frame.h
index 0f1640c4a68..7c664c7cea8 100644
--- a/gdb/frame.h
+++ b/gdb/frame.h
@@ -931,7 +931,7 @@  extern frame_print_options user_frame_print_options;
 struct frame_arg
 {
   /* Symbol for this parameter used for example for its name.  */
-  struct symbol *sym = nullptr;
+  block_symbol sym = {};
 
   /* Value of the parameter.  It is NULL if ERROR is not NULL; if both VAL and
      ERROR are NULL this parameter's value should not be printed.  */
@@ -954,10 +954,10 @@  struct frame_arg
 };
 
 extern void read_frame_arg (const frame_print_options &fp_opts,
-			    symbol *sym, frame_info_ptr frame,
+			    block_symbol sym, frame_info_ptr frame,
 			    struct frame_arg *argp,
 			    struct frame_arg *entryargp);
-extern void read_frame_local (struct symbol *sym, frame_info_ptr frame,
+extern void read_frame_local (block_symbol sym, frame_info_ptr frame,
 			      struct frame_arg *argp);
 
 extern void info_args_command (const char *, int);
diff --git a/gdb/mi/mi-cmd-stack.c b/gdb/mi/mi-cmd-stack.c
index e473be7d465..9a53bac92e7 100644
--- a/gdb/mi/mi-cmd-stack.c
+++ b/gdb/mi/mi-cmd-stack.c
@@ -521,18 +521,18 @@  list_arg_or_local (const struct frame_arg *arg, enum what_to_list what,
 
   string_file stb;
 
-  stb.puts (arg->sym->print_name ());
+  stb.puts (arg->sym.symbol->print_name ());
   if (arg->entry_kind == print_entry_values_only)
     stb.puts ("@entry");
   uiout->field_stream ("name", stb);
 
-  if (what == all && arg->sym->is_argument ())
+  if (what == all && arg->sym.symbol->is_argument ())
     uiout->field_signed ("arg", 1);
 
   if (values == PRINT_SIMPLE_VALUES)
     {
-      check_typedef (arg->sym->type ());
-      type_print (arg->sym->type (), "", &stb, -1);
+      check_typedef (arg->sym.symbol->type ());
+      type_print (arg->sym.symbol->type (), "", &stb, -1);
       uiout->field_stream ("type", stb);
     }
 
@@ -549,7 +549,7 @@  list_arg_or_local (const struct frame_arg *arg, enum what_to_list what,
 	      get_no_prettyformat_print_options (&opts);
 	      opts.deref_ref = true;
 	      common_val_print (arg->val, &stb, 0, &opts,
-				language_def (arg->sym->language ()));
+				language_def (arg->sym.symbol->language ()));
 	    }
 	  catch (const gdb_exception_error &except)
 	    {
@@ -632,15 +632,15 @@  list_args_or_locals (const frame_print_options &fp_opts,
 	    }
 	  if (print_me)
 	    {
-	      struct symbol *sym2;
+	      block_symbol sym2;
 	      struct frame_arg arg, entryarg;
 
 	      if (sym->is_argument ())
 		sym2 = lookup_symbol_search_name (sym->search_name (),
-						  block, VAR_DOMAIN).symbol;
+						  block, VAR_DOMAIN);
 	      else
-		sym2 = sym;
-	      gdb_assert (sym2 != NULL);
+		sym2 = { sym, block };
+	      gdb_assert (sym2.symbol != nullptr);
 
 	      arg.sym = sym2;
 	      arg.entry_kind = print_entry_values_no;
@@ -650,7 +650,7 @@  list_args_or_locals (const frame_print_options &fp_opts,
 	      switch (values)
 		{
 		case PRINT_SIMPLE_VALUES:
-		  if (!mi_simple_type_p (sym2->type ()))
+		  if (!mi_simple_type_p (sym2.symbol->type ()))
 		    break;
 		  /* FALLTHROUGH */
 
diff --git a/gdb/python/py-framefilter.c b/gdb/python/py-framefilter.c
index 07b30a587b1..b214e82628f 100644
--- a/gdb/python/py-framefilter.c
+++ b/gdb/python/py-framefilter.c
@@ -312,7 +312,7 @@  py_print_single_arg (struct ui_out *out,
     {
       if (fa->val == NULL && fa->error == NULL)
 	return;
-      language = language_def (fa->sym->language ());
+      language = language_def (fa->sym.symbol->language ());
       val = fa->val;
     }
   else
@@ -340,12 +340,12 @@  py_print_single_arg (struct ui_out *out,
     {
       string_file stb;
 
-      gdb_puts (fa->sym->print_name (), &stb);
+      gdb_puts (fa->sym.symbol->print_name (), &stb);
       if (fa->entry_kind == print_entry_values_compact)
 	{
 	  stb.puts ("=");
 
-	  gdb_puts (fa->sym->print_name (), &stb);
+	  gdb_puts (fa->sym.symbol->print_name (), &stb);
 	}
       if (fa->entry_kind == print_entry_values_only
 	  || fa->entry_kind == print_entry_values_compact)
@@ -472,7 +472,7 @@  enumerate_args (PyObject *iter,
 	    }
 
 	  read_frame_arg (user_frame_print_options,
-			  sym, frame, &arg, &entryarg);
+			  bsym, frame, &arg, &entryarg);
 
 	  /* The object has not provided a value, so this is a frame
 	     argument to be read by GDB.  In this case we have to
diff --git a/gdb/stack.c b/gdb/stack.c
index 0fba09a044c..0bf2b19fad7 100644
--- a/gdb/stack.c
+++ b/gdb/stack.c
@@ -428,14 +428,14 @@  print_frame_arg (const frame_print_options &fp_opts,
 
   annotate_arg_emitter arg_emitter;
   ui_out_emit_tuple tuple_emitter (uiout, NULL);
-  gdb_puts (arg->sym->print_name (), &stb);
+  gdb_puts (arg->sym.symbol->print_name (), &stb);
   if (arg->entry_kind == print_entry_values_compact)
     {
       /* It is OK to provide invalid MI-like stream as with
 	 PRINT_ENTRY_VALUE_COMPACT we never use MI.  */
       stb.puts ("=");
 
-      gdb_puts (arg->sym->print_name (), &stb);
+      gdb_puts (arg->sym.symbol->print_name (), &stb);
     }
   if (arg->entry_kind == print_entry_values_only
       || arg->entry_kind == print_entry_values_compact)
@@ -472,7 +472,7 @@  print_frame_arg (const frame_print_options &fp_opts,
 	      /* Use the appropriate language to display our symbol, unless the
 		 user forced the language to a specific language.  */
 	      if (language_mode == language_mode_auto)
-		language = language_def (arg->sym->language ());
+		language = language_def (arg->sym.symbol->language ());
 	      else
 		language = current_language;
 
@@ -503,7 +503,7 @@  print_frame_arg (const frame_print_options &fp_opts,
    exception.  */
 
 void
-read_frame_local (struct symbol *sym, frame_info_ptr frame,
+read_frame_local (block_symbol sym, frame_info_ptr frame,
 		  struct frame_arg *argp)
 {
   argp->sym = sym;
@@ -512,7 +512,7 @@  read_frame_local (struct symbol *sym, frame_info_ptr frame,
 
   try
     {
-      argp->val = read_var_value (sym, NULL, frame);
+      argp->val = read_var_value (sym, frame);
     }
   catch (const gdb_exception_error &except)
     {
@@ -525,7 +525,7 @@  read_frame_local (struct symbol *sym, frame_info_ptr frame,
 
 void
 read_frame_arg (const frame_print_options &fp_opts,
-		symbol *sym, frame_info_ptr frame,
+		block_symbol bsym, frame_info_ptr frame,
 		struct frame_arg *argp, struct frame_arg *entryargp)
 {
   struct value *val = NULL, *entryval = NULL;
@@ -537,7 +537,7 @@  read_frame_arg (const frame_print_options &fp_opts,
     {
       try
 	{
-	  val = read_var_value (sym, NULL, frame);
+	  val = read_var_value (bsym, frame);
 	}
       catch (const gdb_exception_error &except)
 	{
@@ -546,6 +546,7 @@  read_frame_arg (const frame_print_options &fp_opts,
 	}
     }
 
+  symbol *sym = bsym.symbol;
   if (SYMBOL_COMPUTED_OPS (sym) != NULL
       && SYMBOL_COMPUTED_OPS (sym)->read_variable_at_entry != NULL
       && fp_opts.print_entry_values != print_entry_values_no
@@ -661,7 +662,7 @@  read_frame_arg (const frame_print_options &fp_opts,
 
 	  try
 	    {
-	      val = read_var_value (sym, NULL, frame);
+	      val = read_var_value (bsym, frame);
 	    }
 	  catch (const gdb_exception_error &except)
 	    {
@@ -687,7 +688,7 @@  read_frame_arg (const frame_print_options &fp_opts,
       val_error = NULL;
     }
 
-  argp->sym = sym;
+  argp->sym = bsym;
   argp->val = val;
   argp->error.reset (val_error ? xstrdup (val_error) : NULL);
   if (!val && !val_error)
@@ -702,7 +703,7 @@  read_frame_arg (const frame_print_options &fp_opts,
   else
     argp->entry_kind = print_entry_values_no;
 
-  entryargp->sym = sym;
+  entryargp->sym = bsym;
   entryargp->val = entryval;
   entryargp->error.reset (entryval_error ? xstrdup (entryval_error) : NULL);
   if (!entryval && !entryval_error)
@@ -871,13 +872,13 @@  print_frame_args (const frame_print_options &fp_opts,
 
 	  if (!print_args)
 	    {
-	      arg.sym = sym;
+	      arg.sym = { sym, b };
 	      arg.entry_kind = print_entry_values_no;
-	      entryarg.sym = sym;
+	      entryarg.sym = { sym, b };
 	      entryarg.entry_kind = print_entry_values_no;
 	    }
 	  else
-	    read_frame_arg (fp_opts, sym, frame, &arg, &entryarg);
+	    read_frame_arg (fp_opts, { sym, b }, frame, &arg, &entryarg);
 
 	  if (arg.entry_kind != print_entry_values_only)
 	    print_frame_arg (fp_opts, &arg);