This is the mail archive of the archer-commits@sourceware.org mailing list for the Archer project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[SCM] archer-tromey-optional-psymtab: Add pre-expansion hook, and change dwarf reader to use it. This is preparation for moving to .debug_pub{names,types}, where finding a symbol's tag is a pain.


The branch, archer-tromey-optional-psymtab has been updated
       via  aa6c81f2709d781f7f14a0c6a9684cd9b322480b (commit)
      from  e3fa2dd94f8b3ece2c5cc55c66a162a748e42e3d (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email.

- Log -----------------------------------------------------------------
commit aa6c81f2709d781f7f14a0c6a9684cd9b322480b
Author: Tom Tromey <tromey@redhat.com>
Date:   Mon Dec 14 14:02:40 2009 -0700

    Add pre-expansion hook, and change dwarf reader to use it.
    This is preparation for moving to .debug_pub{names,types},
    where finding a symbol's tag is a pain.

-----------------------------------------------------------------------

Summary of changes:
 gdb/dwarf2read.c |  105 +++++++++++++++++++++++------------------------------
 gdb/psymtab.c    |   10 +++++
 gdb/symfile.h    |   10 +++++
 gdb/symtab.c     |   52 ++++++++++++++++++---------
 4 files changed, 101 insertions(+), 76 deletions(-)

First 500 lines of diff:
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index c31d330..5ef9504 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -1675,13 +1675,6 @@ struct index_entry
      data, or on the objfile's obstack.  It is in canonical form.  */
   const char *name;
 
-  /* The tag indicating what kind of entry this is.  */
-  ENUM_BITFIELD (dwarf_tag) tag : 16;
-
-  /* The CU's language.  We store it here because it fits in a
-     hole in the struct.  */
-  ENUM_BITFIELD (language) language : 8;
-
   /* The CU holding this entry.  */
   struct dwarf2_per_cu_data *cu;
 
@@ -1930,8 +1923,6 @@ dwarf2_read_gnu_index (struct objfile *objfile)
 
 	  entry = xmalloc (sizeof (struct index_entry));
 	  entry->name = name;
-	  entry->tag = (enum dwarf_tag) tag;
-	  entry->language = lang;
 	  entry->cu = cu;
 
  	  search_head.hash = htab_hash_string (name);
@@ -2357,46 +2348,38 @@ dw2_tag_domain (unsigned long tag)
     }
 }
 
-static struct dwarf2_per_cu_data *
-dw2_lookup_symbol_internal (struct objfile *objfile, int block_index,
-			    const char *name, const char *linkage_name,
-			    domain_enum domain)
+static struct symtab *
+dw2_lookup_symbol (struct objfile *objfile, int block_index,
+		   const char *name, const char *linkage_name,
+		   domain_enum domain)
 {
-  struct index_entry_head search_head, *head;
-  struct index_entry *entry, lookup;
-  int len = strlen (name);
+  /* We do all the work in the pre_expand_symtabs_matching hook
+     instead.  */
+  return NULL;
+}
 
+static void
+dw2_pre_expand_symtabs_matching (struct objfile *objfile,
+				 int kind, const char *name,
+				 const char *linkage_name,
+				 domain_enum domain)
+{
   dw2_setup (objfile);
 
-  if (!dwarf2_per_objfile->index_table)
-    return NULL;
-
-  search_head.hash = htab_hash_string (name);
-  search_head.entry = &lookup;
-  lookup.name = name;
-  head = htab_find (dwarf2_per_objfile->index_table, &search_head);
-
-  /* FIXME: we ignore linkage_name.  */
-  for (entry = head ? head->entry : NULL; entry; entry = entry->next)
+  if (dwarf2_per_objfile->index_table)
     {
-      if (symbol_matches_domain (entry->language,
-				 dw2_tag_domain (entry->tag),
-				 domain))
-	return entry->cu;
-    }
+      struct index_entry_head search_head, *head;
+      struct index_entry *entry, lookup;
 
-  return NULL;
-}
+      search_head.hash = htab_hash_string (name);
+      search_head.entry = &lookup;
+      lookup.name = name;
+      head = htab_find (dwarf2_per_objfile->index_table, &search_head);
 
-static struct symtab *
-dw2_lookup_symbol (struct objfile *objfile, int block_index,
-		   const char *name, const char *linkage_name,
-		   domain_enum domain)
-{
-  struct dwarf2_per_cu_data *cu;
-  cu = dw2_lookup_symbol_internal (objfile, block_index, name,
-				   linkage_name, domain);
-  return cu ? dw2_instantiate_symtab (objfile, cu) : NULL;
+      /* FIXME: we ignore linkage_name.  */
+      for (entry = head ? head->entry : NULL; entry; entry = entry->next)
+	dw2_instantiate_symtab (objfile, entry->cu);
+    }
 }
 
 static void
@@ -2506,12 +2489,27 @@ static char *
 dw2_find_symbol_file (struct objfile *objfile, const char *name)
 {
   struct dwarf2_per_cu_data *cu;
+  struct index_entry_head search_head, *head;
+  struct index_entry *entry, lookup;
 
-  cu = dw2_lookup_symbol_internal (objfile, GLOBAL_BLOCK, name, NULL,
-				   VAR_DOMAIN);
-  if (!cu)
+  dw2_setup (objfile);
+
+  if (!dwarf2_per_objfile->index_table)
     return NULL;
 
+  search_head.hash = htab_hash_string (name);
+  search_head.entry = &lookup;
+  lookup.name = name;
+  head = htab_find (dwarf2_per_objfile->index_table, &search_head);
+
+  /* FIXME: this just looks at the very first one named NAME -- but
+     actually we are looking for a function.  find_main_filename
+     should be rewritten so that it doesn't require a custom hook.  It
+     could just use the ordinary symbol tables.  */
+  if (!head)
+    return NULL;
+  cu = head->entry->cu;
+
   dw2_require_line_header (objfile, cu);
   if (!cu->v.quick->lines)
     {
@@ -2539,7 +2537,6 @@ struct name_matcher_data
 {
   struct objfile *objfile;
   int (*name_matcher) (const char *, void *);
-  domain_enum kind;
   void *data;
 };
 
@@ -2553,9 +2550,6 @@ dw2_call_name_matcher (void **slot, void *d)
 
   for (entry = head->entry; entry; entry = entry->next)
     {
-      int found_kind;
-      enum address_class klass;
-
       if (entry->cu->v.quick->symtab || !entry->cu->v.quick->mark)
 	continue;
 
@@ -2567,15 +2561,7 @@ dw2_call_name_matcher (void **slot, void *d)
       if (len == -1)
 	len = strlen (entry->name);
 
-      klass = dw2_tag_class (entry->tag);
-      if ((data->kind == VARIABLES_DOMAIN
-	   && klass != LOC_TYPEDEF
-	   && klass != LOC_BLOCK)
-	  || (data->kind == FUNCTIONS_DOMAIN
-	      && klass == LOC_BLOCK)
-	  || (data->kind == TYPES_DOMAIN
-	      && klass == LOC_TYPEDEF))
-	dw2_instantiate_symtab (data->objfile, entry->cu);
+      dw2_instantiate_symtab (data->objfile, entry->cu);
     }
 
   return 1;
@@ -2619,9 +2605,9 @@ dw2_expand_symtabs_matching (struct objfile *objfile,
 	}
     }
 
+  /* Note that we just ignore KIND.  */
   match_data.objfile = objfile;
   match_data.name_matcher = name_matcher;
-  match_data.kind = kind;
   match_data.data = data;
 
   htab_traverse_noresize (dwarf2_per_objfile->index_table,
@@ -2737,6 +2723,7 @@ const struct quick_symbol_functions dwarf2_gnu_index_functions =
   dw2_forget_cached_source_info,
   dw2_lookup_symtab,
   dw2_lookup_symbol,
+  dw2_pre_expand_symtabs_matching,
   dw2_print_stats,
   dw2_dump,
   dw2_relocate,
diff --git a/gdb/psymtab.c b/gdb/psymtab.c
index 8a1bab0..75957a2 100644
--- a/gdb/psymtab.c
+++ b/gdb/psymtab.c
@@ -430,6 +430,15 @@ lookup_symbol_aux_psymtabs (struct objfile *objfile,
   return NULL;
 }
 
+static void
+pre_expand_symtabs_matching_psymtabs (struct objfile *objfile,
+				      int kind, const char *name,
+				      const char *linkage_name,
+				      domain_enum domain)
+{
+  /* Nothing.  */
+}
+
 /* Look, in partial_symtab PST, for symbol whose natural name is NAME.
    If LINKAGE_NAME is non-NULL, check in addition that the symbol's
    linkage name matches it.  Check the global symbols if GLOBAL, the
@@ -1268,6 +1277,7 @@ const struct quick_symbol_functions psym_functions =
   forget_cached_source_info_partial,
   lookup_symtab_via_partial_symtab,
   lookup_symbol_aux_psymtabs,
+  pre_expand_symtabs_matching_psymtabs,
   print_psymtab_stats_for_objfile,
   dump_psymtabs_for_objfile,
   relocate_psymtabs,
diff --git a/gdb/symfile.h b/gdb/symfile.h
index 040f51d..922fde4 100644
--- a/gdb/symfile.h
+++ b/gdb/symfile.h
@@ -174,6 +174,16 @@ struct quick_symbol_functions
 				   const char *linkage_name,
 				   domain_enum domain);
 
+  /* This is called to expand symbol tables before looking up a
+     symbol.  A backend can choose to implement this and then have its
+     `lookup_symbol' hook always return NULL, or the reverse.  (It
+     doesn't make sense to implement both.)  The arguments are as for
+     `lookup_symbol'.  */
+  void (*pre_expand_symtabs_matching) (struct objfile *objfile,
+				       int kind, const char *name,
+				       const char *linkage_name,
+				       domain_enum domain);
+
   /* Print statistics about any indices loaded for OBJFILE.  The
      statistics should be printed to gdb_stdout.  This is used for
      "maint print statistics".  */
diff --git a/gdb/symtab.c b/gdb/symtab.c
index 6739dd9..7f5c98b 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -1173,16 +1173,25 @@ lookup_symbol_aux_symtabs (int block_index,
   const struct block *block;
   struct symtab *s;
 
-  ALL_PRIMARY_SYMTABS (objfile, s)
+  ALL_OBJFILES (objfile)
   {
-    bv = BLOCKVECTOR (s);
-    block = BLOCKVECTOR_BLOCK (bv, block_index);
-    sym = lookup_block_symbol (block, name, linkage_name, domain);
-    if (sym)
-      {
-	block_found = block;
-	return fixup_symbol_section (sym, objfile);
-      }
+    objfile->sf->qf->pre_expand_symtabs_matching (objfile,
+						  block_index,
+						  name, linkage_name,
+						  domain);
+
+    ALL_OBJFILE_SYMTABS (objfile, s)
+      if (s->primary)
+	{
+	  bv = BLOCKVECTOR (s);
+	  block = BLOCKVECTOR_BLOCK (bv, block_index);
+	  sym = lookup_block_symbol (block, name, linkage_name, domain);
+	  if (sym)
+	    {
+	      block_found = block;
+	      return fixup_symbol_section (sym, objfile);
+	    }
+	}
   }
 
   return NULL;
@@ -1428,15 +1437,24 @@ basic_lookup_transparent_type (const char *name)
      of the desired name as a global, then do psymtab-to-symtab
      conversion on the fly and return the found symbol.  */
 
-  ALL_PRIMARY_SYMTABS (objfile, s)
+  ALL_OBJFILES (objfile)
   {
-    bv = BLOCKVECTOR (s);
-    block = BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK);
-    sym = lookup_block_symbol (block, name, NULL, STRUCT_DOMAIN);
-    if (sym && !TYPE_IS_OPAQUE (SYMBOL_TYPE (sym)))
-      {
-	return SYMBOL_TYPE (sym);
-      }
+    objfile->sf->qf->pre_expand_symtabs_matching (objfile,
+						  GLOBAL_BLOCK,
+						  name, NULL,
+						  STRUCT_DOMAIN);
+
+    ALL_OBJFILE_SYMTABS (objfile, s)
+      if (s->primary)
+	{
+	  bv = BLOCKVECTOR (s);
+	  block = BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK);
+	  sym = lookup_block_symbol (block, name, NULL, STRUCT_DOMAIN);
+	  if (sym && !TYPE_IS_OPAQUE (SYMBOL_TYPE (sym)))
+	    {
+	      return SYMBOL_TYPE (sym);
+	    }
+	}
   }
 
   ALL_OBJFILES (objfile)


hooks/post-receive
--
Repository for Project Archer.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]