aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gdb/ChangeLog14
-rw-r--r--gdb/objfiles.c4
-rw-r--r--gdb/objfiles.h14
-rw-r--r--gdb/symfile.c5
-rw-r--r--gdb/symtab.c21
5 files changed, 34 insertions, 24 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 5a10cba..a0c0b97 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,19 @@
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,
needs_relocations>: New fields.
(gdb_bfd_requires_relocations): New function.
diff --git a/gdb/objfiles.c b/gdb/objfiles.c
index b9bcfd7..a10540a 100644
--- a/gdb/objfiles.c
+++ b/gdb/objfiles.c
@@ -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. */
diff --git a/gdb/objfiles.h b/gdb/objfiles.h
index 72cef50..8586e5a 100644
--- a/gdb/objfiles.h
+++ b/gdb/objfiles.h
@@ -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. */
diff --git a/gdb/symfile.c b/gdb/symfile.c
index ecf4e32..d260ff9 100644
--- a/gdb/symfile.c
+++ b/gdb/symfile.c
@@ -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;
diff --git a/gdb/symtab.c b/gdb/symtab.c
index d3622e5..3660f1a 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -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