move the demangled_names_hash into the per-BFD
authorTom Tromey <tromey@redhat.com>
Mon, 7 Oct 2013 19:40:38 +0000 (19:40 +0000)
committerTom Tromey <tromey@redhat.com>
Mon, 7 Oct 2013 19:40:38 +0000 (19:40 +0000)
This moves the demangled_names_hash from the objfile into the per-BFD
object.  This is part of the objfile splitting project.

The demangled names hash is independent of the program space.  And, it
is needed by the symbol tables.  Both of these things indicate that it
must be pushed into the per-BFD object, which this patch does.

Built and regtested on x86-64 Fedora 18.

* objfiles.c (free_objfile_per_bfd_storage): Delete the
demangled_names_hash.
(free_objfile): Don't delete the demangled_names_hash.
* objfiles.h (struct objfile_per_bfd_storage)
<demangled_names_hash>: New field.
(struct objfile) <demangled_names_hash>: Move to
objfile_per_bfd_storage.
* symfile.c (reread_symbols): Don't delete the
demangled_names_hash.
* symtab.c (create_demangled_names_hash): Update.
(symbol_set_names): Update.

gdb/ChangeLog
gdb/objfiles.c
gdb/objfiles.h
gdb/symfile.c
gdb/symtab.c

index 5a10cbaa39ceb18fef44621755eaa16ccf21d922..a0c0b97cbe40f9e9b256b7f60f2eda8692942804 100644 (file)
@@ -1,3 +1,17 @@
+2013-10-07  Tom Tromey  <tromey@redhat.com>
+
+       * objfiles.c (free_objfile_per_bfd_storage): Delete the
+       demangled_names_hash.
+       (free_objfile): Don't delete the demangled_names_hash.
+       * objfiles.h (struct objfile_per_bfd_storage)
+       <demangled_names_hash>: New field.
+       (struct objfile) <demangled_names_hash>: Move to
+       objfile_per_bfd_storage.
+       * symfile.c (reread_symbols): Don't delete the
+       demangled_names_hash.
+       * symtab.c (create_demangled_names_hash): Update.
+       (symbol_set_names): Update.
+
 2013-10-07  Tom Tromey  <tromey@redhat.com>
 
        * gdb_bfd.c (struct gdb_bfd_data) <relocation_computed,
index b9bcfd74830b916b337da9838ae21c328e35c9d6..a10540a5852ecda3bc2d5194f336eb157416fe17 100644 (file)
@@ -168,6 +168,8 @@ free_objfile_per_bfd_storage (struct objfile_per_bfd_storage *storage)
 {
   bcache_xfree (storage->filename_cache);
   bcache_xfree (storage->macro_cache);
+  if (storage->demangled_names_hash)
+    htab_delete (storage->demangled_names_hash);
   obstack_free (&storage->storage_obstack, 0);
 }
 
@@ -655,8 +657,6 @@ free_objfile (struct objfile *objfile)
     xfree (objfile->static_psymbols.list);
   /* Free the obstacks for non-reusable objfiles.  */
   psymbol_bcache_free (objfile->psymbol_cache);
-  if (objfile->demangled_names_hash)
-    htab_delete (objfile->demangled_names_hash);
   obstack_free (&objfile->objfile_obstack, 0);
 
   /* Rebuild section map next time we need it.  */
index 72cef502299d9c32c2e7cb07fe4f530fa4522979..8586e5a12bfc3a8ab7a5a59864e4d73de09f5f22 100644 (file)
@@ -185,6 +185,13 @@ struct objfile_per_bfd_storage
      differ from this e.g. with respect to register types and names.  */
 
   struct gdbarch *gdbarch;
+
+  /* Hash table for mapping symbol names to demangled names.  Each
+     entry in the hash table is actually two consecutive strings,
+     both null-terminated; the first one is a mangled or linkage
+     name, and the second is the demangled name or just a zero byte
+     if the name doesn't demangle.  */
+  struct htab *demangled_names_hash;
 };
 
 /* Master structure for keeping track of each file from which
@@ -270,13 +277,6 @@ struct objfile
 
     struct psymbol_bcache *psymbol_cache; /* Byte cache for partial syms.  */
 
-    /* Hash table for mapping symbol names to demangled names.  Each
-       entry in the hash table is actually two consecutive strings,
-       both null-terminated; the first one is a mangled or linkage
-       name, and the second is the demangled name or just a zero byte
-       if the name doesn't demangle.  */
-    struct htab *demangled_names_hash;
-
     /* Vectors of all partial symbols read in from file.  The actual data
        is stored in the objfile_obstack.  */
 
index ecf4e328358051b327a05a8ea4e940664558ba8f..d260ff9fcdab25da2d29d2f6f79302a7c396f6e9 100644 (file)
@@ -2497,11 +2497,6 @@ reread_symbols (void)
          /* Free the obstacks for non-reusable objfiles.  */
          psymbol_bcache_free (objfile->psymbol_cache);
          objfile->psymbol_cache = psymbol_bcache_init ();
-         if (objfile->demangled_names_hash != NULL)
-           {
-             htab_delete (objfile->demangled_names_hash);
-             objfile->demangled_names_hash = NULL;
-           }
          obstack_free (&objfile->objfile_obstack, 0);
          objfile->sections = NULL;
          objfile->symtabs = NULL;
index d3622e508f10a19a4648340701c0e6f2dcfe4834..3660f1ab6c8322a9039cb43bb8cb64d824a3efce 100644 (file)
@@ -592,7 +592,7 @@ create_demangled_names_hash (struct objfile *objfile)
      Choosing a much larger table size wastes memory, and saves only about
      1% in symbol reading.  */
 
-  objfile->demangled_names_hash = htab_create_alloc
+  objfile->per_bfd->demangled_names_hash = htab_create_alloc
     (256, hash_demangled_name_entry, eq_demangled_name_entry,
      NULL, xcalloc, xfree);
 }
@@ -687,7 +687,7 @@ symbol_find_demangled_name (struct general_symbol_info *gsymbol,
    objfile), and it will not be copied.
 
    The hash table corresponding to OBJFILE is used, and the memory
-   comes from that objfile's objfile_obstack.  LINKAGE_NAME is copied,
+   comes from the per-BFD storage_obstack.  LINKAGE_NAME is copied,
    so the pointer can be discarded after calling this function.  */
 
 /* We have to be careful when dealing with Java names: when we run
@@ -723,6 +723,7 @@ symbol_set_names (struct general_symbol_info *gsymbol,
   /* The length of lookup_name.  */
   int lookup_len;
   struct demangled_name_entry entry;
+  struct objfile_per_bfd_storage *per_bfd = objfile->per_bfd;
 
   if (gsymbol->language == language_ada)
     {
@@ -738,18 +739,18 @@ symbol_set_names (struct general_symbol_info *gsymbol,
        gsymbol->name = linkage_name;
       else
        {
-         char *name = obstack_alloc (&objfile->objfile_obstack, len + 1);
+         char *name = obstack_alloc (&per_bfd->storage_obstack, len + 1);
 
          memcpy (name, linkage_name, len);
          name[len] = '\0';
          gsymbol->name = name;
        }
-      symbol_set_demangled_name (gsymbol, NULL, &objfile->objfile_obstack);
+      symbol_set_demangled_name (gsymbol, NULL, &per_bfd->storage_obstack);
 
       return;
     }
 
-  if (objfile->demangled_names_hash == NULL)
+  if (per_bfd->demangled_names_hash == NULL)
     create_demangled_names_hash (objfile);
 
   /* The stabs reader generally provides names that are not
@@ -789,7 +790,7 @@ symbol_set_names (struct general_symbol_info *gsymbol,
 
   entry.mangled = lookup_name;
   slot = ((struct demangled_name_entry **)
-         htab_find_slot (objfile->demangled_names_hash,
+         htab_find_slot (per_bfd->demangled_names_hash,
                          &entry, INSERT));
 
   /* If this name is not in the hash table, add it.  */
@@ -814,7 +815,7 @@ symbol_set_names (struct general_symbol_info *gsymbol,
         us better bcache hit rates for partial symbols.  */
       if (!copy_name && lookup_name == linkage_name)
        {
-         *slot = obstack_alloc (&objfile->objfile_obstack,
+         *slot = obstack_alloc (&per_bfd->storage_obstack,
                                 offsetof (struct demangled_name_entry,
                                           demangled)
                                 + demangled_len + 1);
@@ -827,7 +828,7 @@ symbol_set_names (struct general_symbol_info *gsymbol,
          /* If we must copy the mangled name, put it directly after
             the demangled name so we can have a single
             allocation.  */
-         *slot = obstack_alloc (&objfile->objfile_obstack,
+         *slot = obstack_alloc (&per_bfd->storage_obstack,
                                 offsetof (struct demangled_name_entry,
                                           demangled)
                                 + lookup_len + demangled_len + 2);
@@ -848,9 +849,9 @@ symbol_set_names (struct general_symbol_info *gsymbol,
   gsymbol->name = (*slot)->mangled + lookup_len - len;
   if ((*slot)->demangled[0] != '\0')
     symbol_set_demangled_name (gsymbol, (*slot)->demangled,
-                              &objfile->objfile_obstack);
+                              &per_bfd->storage_obstack);
   else
-    symbol_set_demangled_name (gsymbol, NULL, &objfile->objfile_obstack);
+    symbol_set_demangled_name (gsymbol, NULL, &per_bfd->storage_obstack);
 }
 
 /* Return the source code name of a symbol.  In languages where
This page took 0.040865 seconds and 4 git commands to generate.