aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
authorKevin Buettner <kevinb@redhat.com>2000-08-04 18:41:05 +0000
committerKevin Buettner <kevinb@redhat.com>2000-08-04 18:41:05 +0000
commitafbb8d7a46453f18c35b9640845e7a63fc311f75 (patch)
tree7cd27ae90c404e21baa8863ed210d2e783c73fc7 /gdb
parent679ebd0f9c7d49cd46facee29a9b157d4acd0004 (diff)
downloadgdb-afbb8d7a46453f18c35b9640845e7a63fc311f75.zip
gdb-afbb8d7a46453f18c35b9640845e7a63fc311f75.tar.gz
gdb-afbb8d7a46453f18c35b9640845e7a63fc311f75.tar.bz2
Add code for (re)building the minimal symbol hash tables.
Diffstat (limited to 'gdb')
-rw-r--r--gdb/ChangeLog5
-rw-r--r--gdb/minsyms.c52
2 files changed, 46 insertions, 11 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 5c8baad..8abe74d 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,10 @@
2000-08-04 Kevin Buettner <kevinb@redhat.com>
+ * minsyms.c (build_minimal_symbol_hash_tables): New function.
+ (compact_minimal_symbols): Don't construct hash tables here.
+ (install_minimal_symbols): Instead, construct them here.
+ (msymbols_sort): And rebuild them here too.
+
* dwarf2read.c (struct comp_unit_head): Add fields offset_size
and initial_length_size. Change type of ``length'' field to long.
(read_initial_length, read_offset): New functions.
diff --git a/gdb/minsyms.c b/gdb/minsyms.c
index 4bb5ed0..94faccb 100644
--- a/gdb/minsyms.c
+++ b/gdb/minsyms.c
@@ -801,11 +801,7 @@ compact_minimal_symbols (struct minimal_symbol *msymbol, int mcount,
copyfrom++;
}
else
- {
- *copyto++ = *copyfrom++;
-
- add_minsym_to_hash_table (copyto - 1, objfile->msymbol_hash);
- }
+ *copyto++ = *copyfrom++;
}
*copyto++ = *copyfrom++;
mcount = copyto - msymbol;
@@ -813,6 +809,38 @@ compact_minimal_symbols (struct minimal_symbol *msymbol, int mcount,
return (mcount);
}
+/* Build (or rebuild) the minimal symbol hash tables. This is necessary
+ after compacting or sorting the table since the entries move around
+ thus causing the internal minimal_symbol pointers to become jumbled. */
+
+static void
+build_minimal_symbol_hash_tables (struct objfile *objfile)
+{
+ int i;
+ struct minimal_symbol *msym;
+
+ /* Clear the hash tables. */
+ for (i = 0; i < MINIMAL_SYMBOL_HASH_SIZE; i++)
+ {
+ objfile->msymbol_hash[i] = 0;
+ objfile->msymbol_demangled_hash[i] = 0;
+ }
+
+ /* Now, (re)insert the actual entries. */
+ for (i = objfile->minimal_symbol_count, msym = objfile->msymbols;
+ i > 0;
+ i--, msym++)
+ {
+ msym->hash_next = 0;
+ add_minsym_to_hash_table (msym, objfile->msymbol_hash);
+
+ msym->demangled_hash_next = 0;
+ if (SYMBOL_DEMANGLED_NAME (msym) != NULL)
+ add_minsym_to_demangled_hash_table (msym,
+ objfile->msymbol_demangled_hash);
+ }
+}
+
/* Add the minimal symbols in the existing bunches to the objfile's official
minimal symbol table. In most cases there is no minimal symbol table yet
for this objfile, and the existing bunches are used to create one. Once
@@ -928,12 +956,13 @@ install_minimal_symbols (struct objfile *objfile)
ones and attempting to cache their C++ demangled names. */
for (; mcount-- > 0; msymbols++)
- {
- SYMBOL_INIT_DEMANGLED_NAME (msymbols, &objfile->symbol_obstack);
- if (SYMBOL_DEMANGLED_NAME (msymbols) != NULL)
- add_minsym_to_demangled_hash_table (msymbols,
- objfile->msymbol_demangled_hash);
- }
+ SYMBOL_INIT_DEMANGLED_NAME (msymbols, &objfile->symbol_obstack);
+
+ /* Now build the hash tables; we can't do this incrementally
+ at an earlier point since we weren't finished with the obstack
+ yet. (And if the msymbol obstack gets moved, all the internal
+ pointers to other msymbols need to be adjusted.) */
+ build_minimal_symbol_hash_tables (objfile);
}
}
@@ -944,6 +973,7 @@ msymbols_sort (struct objfile *objfile)
{
qsort (objfile->msymbols, objfile->minimal_symbol_count,
sizeof (struct minimal_symbol), compare_minimal_symbols);
+ build_minimal_symbol_hash_tables (objfile);
}
/* Check if PC is in a shared library trampoline code stub.