2010-07-13 Emmanuel Thomé <Emmanuel.Thome@gmail.com>
[binutils-gdb.git] / gdb / minsyms.c
index ee730a449a9ceda261afd723741cefff6de1c975..cb4545c06fc7bad66d92078bd2d37948642a2b85 100644 (file)
@@ -82,6 +82,7 @@ unsigned int
 msymbol_hash_iw (const char *string)
 {
   unsigned int hash = 0;
+
   while (*string && *string != '(')
     {
       while (isspace (*string))
@@ -101,6 +102,7 @@ unsigned int
 msymbol_hash (const char *string)
 {
   unsigned int hash = 0;
+
   for (; *string; ++string)
     hash = hash * 67 + *string - 113;
   return hash;
@@ -115,6 +117,7 @@ add_minsym_to_hash_table (struct minimal_symbol *sym,
     {
       unsigned int hash
        = msymbol_hash (SYMBOL_LINKAGE_NAME (sym)) % MINIMAL_SYMBOL_HASH_SIZE;
+
       sym->hash_next = table[hash];
       table[hash] = sym;
     }
@@ -130,6 +133,7 @@ add_minsym_to_demangled_hash_table (struct minimal_symbol *sym,
     {
       unsigned int hash
        = msymbol_hash_iw (SYMBOL_SEARCH_NAME (sym)) % MINIMAL_SYMBOL_HASH_SIZE;
+
       sym->demangled_hash_next = table[hash];
       table[hash] = sym;
     }
@@ -195,6 +199,7 @@ lookup_minimal_symbol (const char *name, const char *sfile,
   if (sfile != NULL)
     {
       char *p = strrchr (sfile, '/');
+
       if (p != NULL)
        sfile = p + 1;
     }
@@ -204,6 +209,7 @@ lookup_minimal_symbol (const char *name, const char *sfile,
   if (current_language->la_language == language_cplus)
     {
       char *cname = cp_canonicalize_string (name);
+
       if (cname)
        {
          modified_name = cname;
@@ -693,6 +699,37 @@ lookup_minimal_symbol_by_pc (CORE_ADDR pc)
 {
   return lookup_minimal_symbol_by_pc_section (pc, NULL);
 }
+
+/* Find the minimal symbol named NAME, and return both the minsym
+   struct and its objfile.  This only checks the linkage name.  Sets
+   *OBJFILE_P and returns the minimal symbol, if it is found.  If it
+   is not found, returns NULL.  */
+
+struct minimal_symbol *
+lookup_minimal_symbol_and_objfile (const char *name,
+                                  struct objfile **objfile_p)
+{
+  struct objfile *objfile;
+  unsigned int hash = msymbol_hash (name) % MINIMAL_SYMBOL_HASH_SIZE;
+
+  ALL_OBJFILES (objfile)
+    {
+      struct minimal_symbol *msym;
+
+      for (msym = objfile->msymbol_hash[hash];
+          msym != NULL;
+          msym = msym->hash_next)
+       {
+         if (strcmp (SYMBOL_LINKAGE_NAME (msym), name) == 0)
+           {
+             *objfile_p = objfile;
+             return msym;
+           }
+       }
+    }
+
+  return 0;
+}
 \f
 
 /* Return leading symbol character for a BFD. If BFD is NULL,
@@ -1130,6 +1167,7 @@ install_minimal_symbols (struct objfile *objfile)
               mixing ABIs then the user will need to "set cp-abi"
               manually.  */
            const char *name = SYMBOL_LINKAGE_NAME (&objfile->msymbols[i]);
+
            if (name[0] == '_' && name[1] == 'Z'
                && SYMBOL_DEMANGLED_NAME (&objfile->msymbols[i]) != NULL)
              {
@@ -1208,6 +1246,7 @@ find_solib_trampoline_target (struct frame_info *frame, CORE_ADDR pc)
                       SYMBOL_LINKAGE_NAME (tsymbol)) == 0)
          {
            CORE_ADDR func;
+
            func = gdbarch_convert_from_func_ptr_addr
                    (get_objfile_arch (objfile),
                     SYMBOL_VALUE_ADDRESS (msymbol),