[08/30] Use block_symbol::address in ax-gdb.c

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

Commit Message

Tom Tromey Oct. 29, 2023, 11:23 p.m. UTC
  This changes ax-gdb.c to use block_symbol::address.
---
 gdb/ax-gdb.c     | 28 +++++++++++++++-------------
 gdb/ax-gdb.h     |  2 +-
 gdb/tracepoint.c |  2 +-
 3 files changed, 17 insertions(+), 15 deletions(-)
  

Patch

diff --git a/gdb/ax-gdb.c b/gdb/ax-gdb.c
index a679c864915..dc3ac14078f 100644
--- a/gdb/ax-gdb.c
+++ b/gdb/ax-gdb.c
@@ -86,7 +86,7 @@  static void gen_frame_locals_address (struct agent_expr *);
 static void gen_offset (struct agent_expr *ax, int offset);
 static void gen_sym_offset (struct agent_expr *, struct symbol *);
 static void gen_var_ref (struct agent_expr *ax, struct axs_value *value,
-			 struct symbol *var);
+			 block_symbol var);
 
 
 static void gen_int_literal (struct agent_expr *ax,
@@ -515,8 +515,10 @@  gen_sym_offset (struct agent_expr *ax, struct symbol *var)
    symbol VAR.  Set VALUE to describe the result.  */
 
 static void
-gen_var_ref (struct agent_expr *ax, struct axs_value *value, struct symbol *var)
+gen_var_ref (struct agent_expr *ax, struct axs_value *value, block_symbol bvar)
 {
+  symbol *var = bvar.symbol;
+
   /* Dereference any typedefs.  */
   value->type = check_typedef (var->type ());
   value->optimized_out = 0;
@@ -536,7 +538,7 @@  gen_var_ref (struct agent_expr *ax, struct axs_value *value, struct symbol *var)
       break;
 
     case LOC_LABEL:		/* A goto label, being used as a value.  */
-      ax_const_l (ax, (LONGEST) var->value_address ());
+      ax_const_l (ax, (LONGEST) bvar.address ());
       value->kind = axs_rvalue;
       break;
 
@@ -547,7 +549,7 @@  gen_var_ref (struct agent_expr *ax, struct axs_value *value, struct symbol *var)
       /* Variable at a fixed location in memory.  Easy.  */
     case LOC_STATIC:
       /* Push the address of the variable.  */
-      ax_const_l (ax, var->value_address ());
+      ax_const_l (ax, bvar.address ());
       value->kind = axs_lvalue_memory;
       break;
 
@@ -1457,9 +1459,9 @@  gen_static_field (struct agent_expr *ax, struct axs_value *value,
   else
     {
       const char *phys_name = type->field (fieldno).loc_physname ();
-      struct symbol *sym = lookup_symbol (phys_name, 0, VAR_DOMAIN, 0).symbol;
+      block_symbol sym = lookup_symbol (phys_name, 0, VAR_DOMAIN, 0);
 
-      if (sym)
+      if (sym.symbol != nullptr)
 	{
 	  gen_var_ref (ax, value, sym);
   
@@ -1553,7 +1555,7 @@  gen_maybe_namespace_elt (struct agent_expr *ax, struct axs_value *value,
   if (sym.symbol == NULL)
     return 0;
 
-  gen_var_ref (ax, value, sym.symbol);
+  gen_var_ref (ax, value, sym);
 
   if (value->optimized_out)
     error (_("`%s' has been optimized out, cannot use"),
@@ -1896,7 +1898,7 @@  op_this_operation::do_generate_ax (struct expression *exp,
 				   struct axs_value *value,
 				   struct type *cast_type)
 {
-  struct symbol *sym, *func;
+  struct symbol *func;
   const struct block *b;
   const struct language_defn *lang;
 
@@ -1904,15 +1906,15 @@  op_this_operation::do_generate_ax (struct expression *exp,
   func = b->linkage_function ();
   lang = language_def (func->language ());
 
-  sym = lookup_language_this (lang, b).symbol;
-  if (!sym)
+  block_symbol sym = lookup_language_this (lang, b);
+  if (sym.symbol == nullptr)
     error (_("no `%s' found"), lang->name_of_this ());
 
   gen_var_ref (ax, value, sym);
 
   if (value->optimized_out)
     error (_("`%s' has been optimized out, cannot use"),
-	   sym->print_name ());
+	   sym.symbol->print_name ());
 }
 
 void
@@ -2003,7 +2005,7 @@  var_value_operation::do_generate_ax (struct expression *exp,
 				     struct axs_value *value,
 				     struct type *cast_type)
 {
-  gen_var_ref (ax, value, std::get<0> (m_storage).symbol);
+  gen_var_ref (ax, value, std::get<0> (m_storage));
 
   if (value->optimized_out)
     error (_("`%s' has been optimized out, cannot use"),
@@ -2330,7 +2332,7 @@  gen_expr_unop (struct expression *exp,
 
 agent_expr_up
 gen_trace_for_var (CORE_ADDR scope, struct gdbarch *gdbarch,
-		   struct symbol *var, int trace_string)
+		   block_symbol var, int trace_string)
 {
   agent_expr_up ax (new agent_expr (gdbarch, scope));
   struct axs_value value;
diff --git a/gdb/ax-gdb.h b/gdb/ax-gdb.h
index 4f73385208c..8376d7ee29e 100644
--- a/gdb/ax-gdb.h
+++ b/gdb/ax-gdb.h
@@ -106,7 +106,7 @@  extern agent_expr_up gen_trace_for_expr (CORE_ADDR, struct expression *,
 					 int);
 
 extern agent_expr_up gen_trace_for_var (CORE_ADDR, struct gdbarch *,
-					struct symbol *, int);
+					block_symbol, int);
 
 extern agent_expr_up gen_trace_for_return_address (CORE_ADDR,
 						   struct gdbarch *,
diff --git a/gdb/tracepoint.c b/gdb/tracepoint.c
index 6d017179283..80239200984 100644
--- a/gdb/tracepoint.c
+++ b/gdb/tracepoint.c
@@ -1010,7 +1010,7 @@  collection_list::collect_symbol (block_symbol bsym,
   if (treat_as_expr)
     {
       agent_expr_up aexpr = gen_trace_for_var (scope, gdbarch,
-					       sym, trace_string);
+					       bsym, trace_string);
 
       /* It can happen that the symbol is recorded as a computed
 	 location, but it's been optimized away and doesn't actually