[2/3] RFC: merge symbol "ops" and "aclass" fields

Jan Kratochvil jan.kratochvil@redhat.com
Sun Feb 3 09:06:00 GMT 2013


Hi Tom,

that *datum* support I find overengineered, isn't enough the simplification
below?

Included is also unrelated substitution:
+#define SYMBOL_IMPL(symbol)            (symbol_impls[(symbol)->aclass_index])


Thanks,
Jan


diff --git a/gdb/dwarf2loc.c b/gdb/dwarf2loc.c
index 0e4e490..6047f09 100644
--- a/gdb/dwarf2loc.c
+++ b/gdb/dwarf2loc.c
@@ -363,14 +363,14 @@ dwarf_expr_frame_base_1 (struct symbol *framefunc, CORE_ADDR pc,
 {
   if (SYMBOL_LOCATION_BATON (framefunc) == NULL)
     *length = 0;
-  else if (SYMBOL_READER_DATUM (framefunc) == &dwarf2_loclist_funcs)
+  else if (SYMBOL_ACLASS_INDEX (framefunc) == dwarf2_loclist_block_index)
     {
       struct dwarf2_loclist_baton *symbaton;
 
       symbaton = SYMBOL_LOCATION_BATON (framefunc);
       *start = dwarf2_find_location_expression (symbaton, length, pc);
     }
-  else
+  else if (SYMBOL_ACLASS_INDEX (framefunc) == dwarf2_locexpr_block_index)
     {
       struct dwarf2_locexpr_baton *symbaton;
 
@@ -383,6 +383,8 @@ dwarf_expr_frame_base_1 (struct symbol *framefunc, CORE_ADDR pc,
       else
 	*length = 0;
     }
+  else
+    internal_error (__FILE__, __LINE__, _("invalid function aclass index"));
 
   if (*length == 0)
     error (_("Could not find the frame base for \"%s\"."),
diff --git a/gdb/dwarf2loc.h b/gdb/dwarf2loc.h
index 36641b3..9060a65 100644
--- a/gdb/dwarf2loc.h
+++ b/gdb/dwarf2loc.h
@@ -133,6 +133,10 @@ struct dwarf2_loclist_baton
 extern const struct symbol_computed_ops dwarf2_locexpr_funcs;
 extern const struct symbol_computed_ops dwarf2_loclist_funcs;
 
+/* Two variables from dwarf2read.c.  */
+extern int dwarf2_locexpr_block_index;
+extern int dwarf2_loclist_block_index;
+
 /* Compile a DWARF location expression to an agent expression.
    
    EXPR is the agent expression we are building.
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index 387060e..a442e58 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -95,8 +95,8 @@ static const struct objfile_data *dwarf2_objfile_data_key;
 
 static int dwarf2_locexpr_index;
 static int dwarf2_loclist_index;
-static int dwarf2_locexpr_block_index;
-static int dwarf2_loclist_block_index;
+int dwarf2_locexpr_block_index;
+int dwarf2_loclist_block_index;
 
 struct dwarf2_section_info
 {
@@ -20704,10 +20704,6 @@ Usage: save gdb-index DIRECTORY"),
   dwarf2_loclist_index = register_symbol_computed_impl (LOC_COMPUTED,
 							&dwarf2_loclist_funcs);
 
-  /* In these two calls, the _funcs vectors aren't actually used; they
-     are just sentinels for other checks.  */
-  dwarf2_locexpr_block_index
-    = register_symbol_datum_impl (LOC_BLOCK, &dwarf2_locexpr_funcs);
-  dwarf2_loclist_block_index
-    = register_symbol_datum_impl (LOC_BLOCK, &dwarf2_loclist_funcs);
+  dwarf2_locexpr_block_index = register_symbol_alias_impl (LOC_BLOCK);
+  dwarf2_loclist_block_index = register_symbol_alias_impl (LOC_BLOCK);
 }
diff --git a/gdb/symtab.c b/gdb/symtab.c
index 56fb52d..ade5576 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -5095,20 +5095,17 @@ register_symbol_computed_impl (enum address_class aclass,
   return result;
 }
 
-/* Register a "datum" symbol type.  ACLASS can be anything.  DATUM is
-   a bit of per-symbol-reader data to store with this index.  This
-   returns the new index, which should be used as the aclass_index
-   field for symbols of this type.  */
+/* Register a symbol type to be recognized by its index.  ACLASS can be
+   anything.  This returns the new index, which should be used as the
+   aclass_index field for symbols of this type.  */
 
 int
-register_symbol_datum_impl (enum address_class aclass, const void *datum)
+register_symbol_alias_impl (enum address_class aclass)
 {
   int result = next_aclass_value++;
 
-  gdb_assert (aclass >= 0 && aclass < LOC_FINAL_VALUE);
   gdb_assert (result < MAX_SYMBOL_IMPLS);
   symbol_impl[result].aclass = aclass;
-  symbol_impl[result].reader_datum = datum;
 
   return result;
 }
diff --git a/gdb/symtab.h b/gdb/symtab.h
index f8ab97b..2ded0fc 100644
--- a/gdb/symtab.h
+++ b/gdb/symtab.h
@@ -605,9 +605,6 @@ struct symbol_impl
 
   /* Used with LOC_REGISTER and LOC_REGPARM_ADDR.  */
   const struct symbol_register_ops *ops_register;
-
-  /* Used to store a per-symbol-reader datum.  */
-  const void *reader_datum;
 };
 
 /* The number of bits we reserve in a symbol for the aclass index.
@@ -689,8 +686,9 @@ struct symbol
 extern const struct symbol_impl *symbol_impls;
 
 #define SYMBOL_DOMAIN(symbol)	(symbol)->domain
+#define SYMBOL_IMPL(symbol)		(symbol_impls[(symbol)->aclass_index])
 #define SYMBOL_ACLASS_INDEX(symbol)	(symbol)->aclass_index
-#define SYMBOL_CLASS(symbol)	((symbol_impls[(symbol)->aclass_index]).aclass)
+#define SYMBOL_CLASS(symbol)		(SYMBOL_IMPL (symbol).aclass)
 #define SYMBOL_IS_ARGUMENT(symbol)	(symbol)->is_argument
 #define SYMBOL_INLINED(symbol)		(symbol)->is_inlined
 #define SYMBOL_IS_CPLUS_TEMPLATE_FUNCTION(symbol) \
@@ -698,18 +696,14 @@ extern const struct symbol_impl *symbol_impls;
 #define SYMBOL_TYPE(symbol)		(symbol)->type
 #define SYMBOL_LINE(symbol)		(symbol)->line
 #define SYMBOL_SYMTAB(symbol)		(symbol)->symtab
-#define SYMBOL_COMPUTED_OPS(symbol) \
-  ((symbol_impls[(symbol)->aclass_index]).ops_computed)
-#define SYMBOL_REGISTER_OPS(symbol) \
-  ((symbol_impls[(symbol)->aclass_index]).ops_register)
-#define SYMBOL_READER_DATUM(symbol) \
-  ((symbol_impls[(symbol)->aclass_index]).reader_datum)
+#define SYMBOL_COMPUTED_OPS(symbol)	(SYMBOL_IMPL (symbol).ops_computed)
+#define SYMBOL_REGISTER_OPS(symbol)	(SYMBOL_IMPL (symbol).ops_register)
 #define SYMBOL_LOCATION_BATON(symbol)   (symbol)->aux_value
 
 extern int register_symbol_computed_impl (enum address_class,
 					  const struct symbol_computed_ops *);
 
-extern int register_symbol_datum_impl (enum address_class, const void *);
+extern int register_symbol_alias_impl (enum address_class);
 
 extern int register_symbol_register_impl (enum address_class,
 					  const struct symbol_register_ops *);



More information about the Gdb-patches mailing list