This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
minsyms.c bug: broken hashtables after doing msymbols_sort()
- To: "gdb-patches at sources dot redhat dot com" <gdb-patches at sources dot redhat dot com>
- Subject: minsyms.c bug: broken hashtables after doing msymbols_sort()
- From: Till Straumann <strauman at SLAC dot Stanford dot EDU>
- Date: Mon, 06 Nov 2000 19:37:27 -0800
- Organization: SSRL (Stanford Synchrotron Radiation Laboratory)
- References: <39EF530C.8EC0F049@slac.stanford.edu>
Hi.
There is a bug in minsyms.c. When re-sorting the msymbols[]
array
in an objfile, the hashtables which hold pointers to
the
msymbols[] entries become invalid. Therefore, the hash
tables must be recreated after sorting. A patch is attached
(against gdb-5.0).
Regards, Till.
PS: send replies to <strauman@slac.stanford.edu>, I am NOT on this
mailing list...
*** minsyms.c.orig Mon Nov 6 18:11:14 2000
--- minsyms.c Mon Nov 6 19:12:16 2000
***************
*** 963,970 ****
--- 963,999 ----
msymbols_sort (objfile)
struct objfile *objfile;
{
+ struct minimal_symbol *msymbol;
+
qsort (objfile->msymbols, objfile->minimal_symbol_count,
sizeof (struct minimal_symbol), compare_minimal_symbols);
+ /* Till Straumann <strauman@slac.stanford.edu>, 6. Nov. 2000:
+ * after reordering the msymbols array, the hash tables
+ * must be recalculated. Note that the link fields
+ * also have become invalid.
+ */
+ if (objfile->msymbols)
+ {
+ ALL_OBJFILE_MSYMBOLS (objfile, msymbol)
+ {
+ /* clear invalid old link values */
+ msymbol->hash_next = 0;
+ msymbol->demangled_hash_next = 0;
+ }
+ /* now clear the hash tables */
+ memset(&objfile->msymbol_hash, 0,
+ sizeof(objfile->msymbol_hash));
+ memset (&objfile->msymbol_demangled_hash, 0,
+ sizeof (objfile->msymbol_demangled_hash));
+ /* finally, reconstruct them */
+ ALL_OBJFILE_MSYMBOLS (objfile, msymbol)
+ {
+ add_minsym_to_hash_table(msymbol, objfile->msymbol_hash);
+ if (SYMBOL_DEMANGLED_NAME (msymbol) != NULL)
+ add_minsym_to_demangled_hash_table (msymbol,
+ objfile->msymbol_demangled_hash);
+ }
+ }
}
/* Check if PC is in a shared library trampoline code stub.