+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,
{
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);
}
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. */
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
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. */
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);
}
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
/* 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)
{
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
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. */
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);
/* 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);
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