Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Jan Kratochvil <jan.kratochvil@redhat.com>
To: Tom Tromey <tromey@redhat.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [2/3] RFC: merge symbol "ops" and "aclass" fields
Date: Sun, 03 Feb 2013 09:06:00 -0000	[thread overview]
Message-ID: <20130203090618.GC16948@host2.jankratochvil.net> (raw)
In-Reply-To: <8738y1hzzz.fsf@fleche.redhat.com>

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 *);


  reply	other threads:[~2013-02-03  9:06 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-16 16:09 Tom Tromey
2013-02-03  9:06 ` Jan Kratochvil [this message]
2013-02-06 15:40   ` Tom Tromey
2013-02-06 15:52     ` Jan Kratochvil
2013-02-07 18:24       ` Jan Kratochvil
2013-02-03  9:20 ` Jan Kratochvil
2013-02-04 16:44   ` Tom Tromey
2013-03-14 20:29 ` Tom Tromey
2013-03-20 18:33   ` Tom Tromey

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20130203090618.GC16948@host2.jankratochvil.net \
    --to=jan.kratochvil@redhat.com \
    --cc=gdb-patches@sourceware.org \
    --cc=tromey@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox