This is the mail archive of the gdb-patches@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

minsyms.c bug: broken hashtables after doing msymbols_sort()


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]