use bound_minsym as result for lookup_minimal_symbol et al
[deliverable/binutils-gdb.git] / gdb / minsyms.c
index aad7685f4d1652dd4a413e7d821dd8a54d18e11f..8335d51dc7bec6c49e9b5704b835ae26a3299d6b 100644 (file)
@@ -159,9 +159,9 @@ add_minsym_to_demangled_hash_table (struct minimal_symbol *sym,
    Obviously, there must be distinct mangled names for each of these,
    but the demangled names are all the same: S::S or S::~S.  */
 
-static struct bound_minimal_symbol
-lookup_minimal_symbol_internal (const char *name, const char *sfile,
-                               struct objfile *objf)
+struct bound_minimal_symbol
+lookup_minimal_symbol (const char *name, const char *sfile,
+                      struct objfile *objf)
 {
   struct objfile *objfile;
   struct bound_minimal_symbol found_symbol = { NULL, NULL };
@@ -294,23 +294,10 @@ lookup_minimal_symbol_internal (const char *name, const char *sfile,
 
 /* See minsyms.h.  */
 
-struct minimal_symbol *
-lookup_minimal_symbol (const char *name, const char *sfile,
-                      struct objfile *objf)
-{
-  struct bound_minimal_symbol bms = lookup_minimal_symbol_internal (name,
-                                                                   sfile,
-                                                                   objf);
-
-  return bms.minsym;
-}
-
-/* See minsyms.h.  */
-
 struct bound_minimal_symbol
 lookup_bound_minimal_symbol (const char *name)
 {
-  return lookup_minimal_symbol_internal (name, NULL, NULL);
+  return lookup_minimal_symbol (name, NULL, NULL);
 }
 
 /* See minsyms.h.  */
@@ -349,25 +336,25 @@ iterate_over_minimal_symbols (struct objfile *objf, const char *name,
 
 /* See minsyms.h.  */
 
-struct minimal_symbol *
+struct bound_minimal_symbol
 lookup_minimal_symbol_text (const char *name, struct objfile *objf)
 {
   struct objfile *objfile;
   struct minimal_symbol *msymbol;
-  struct minimal_symbol *found_symbol = NULL;
-  struct minimal_symbol *found_file_symbol = NULL;
+  struct bound_minimal_symbol found_symbol = { NULL, NULL };
+  struct bound_minimal_symbol found_file_symbol = { NULL, NULL };
 
   unsigned int hash = msymbol_hash (name) % MINIMAL_SYMBOL_HASH_SIZE;
 
   for (objfile = object_files;
-       objfile != NULL && found_symbol == NULL;
+       objfile != NULL && found_symbol.minsym == NULL;
        objfile = objfile->next)
     {
       if (objf == NULL || objf == objfile
          || objf == objfile->separate_debug_objfile_backlink)
        {
          for (msymbol = objfile->msymbol_hash[hash];
-              msymbol != NULL && found_symbol == NULL;
+              msymbol != NULL && found_symbol.minsym == NULL;
               msymbol = msymbol->hash_next)
            {
              if (strcmp (MSYMBOL_LINKAGE_NAME (msymbol), name) == 0 &&
@@ -378,10 +365,12 @@ lookup_minimal_symbol_text (const char *name, struct objfile *objf)
                  switch (MSYMBOL_TYPE (msymbol))
                    {
                    case mst_file_text:
-                     found_file_symbol = msymbol;
+                     found_file_symbol.minsym = msymbol;
+                     found_file_symbol.objfile = objfile;
                      break;
                    default:
-                     found_symbol = msymbol;
+                     found_symbol.minsym = msymbol;
+                     found_symbol.objfile = objfile;
                      break;
                    }
                }
@@ -389,14 +378,11 @@ lookup_minimal_symbol_text (const char *name, struct objfile *objf)
        }
     }
   /* External symbols are best.  */
-  if (found_symbol)
+  if (found_symbol.minsym)
     return found_symbol;
 
   /* File-local symbols are next best.  */
-  if (found_file_symbol)
-    return found_file_symbol;
-
-  return NULL;
+  return found_file_symbol;
 }
 
 /* See minsyms.h.  */
@@ -433,35 +419,39 @@ lookup_minimal_symbol_by_pc_name (CORE_ADDR pc, const char *name,
 
 /* See minsyms.h.  */
 
-struct minimal_symbol *
+struct bound_minimal_symbol
 lookup_minimal_symbol_solib_trampoline (const char *name,
                                        struct objfile *objf)
 {
   struct objfile *objfile;
   struct minimal_symbol *msymbol;
-  struct minimal_symbol *found_symbol = NULL;
+  struct bound_minimal_symbol found_symbol = { NULL, NULL };
 
   unsigned int hash = msymbol_hash (name) % MINIMAL_SYMBOL_HASH_SIZE;
 
   for (objfile = object_files;
-       objfile != NULL && found_symbol == NULL;
+       objfile != NULL;
        objfile = objfile->next)
     {
       if (objf == NULL || objf == objfile
          || objf == objfile->separate_debug_objfile_backlink)
        {
          for (msymbol = objfile->msymbol_hash[hash];
-              msymbol != NULL && found_symbol == NULL;
+              msymbol != NULL;
               msymbol = msymbol->hash_next)
            {
              if (strcmp (MSYMBOL_LINKAGE_NAME (msymbol), name) == 0 &&
                  MSYMBOL_TYPE (msymbol) == mst_solib_trampoline)
-               return msymbol;
+               {
+                 found_symbol.objfile = objfile;
+                 found_symbol.minsym = msymbol;
+                 return found_symbol;
+               }
            }
        }
     }
 
-  return NULL;
+  return found_symbol;
 }
 
 /* Search through the minimal symbol table for each objfile and find
@@ -944,7 +934,7 @@ prim_record_minimal_symbol_full (const char *name, int name_len, int copy_name,
   MSYMBOL_SET_LANGUAGE (msymbol, language_auto, &objfile->objfile_obstack);
   MSYMBOL_SET_NAMES (msymbol, name, name_len, copy_name, objfile);
 
-  MSYMBOL_VALUE_ADDRESS (msymbol) = address;
+  SET_MSYMBOL_VALUE_ADDRESS (msymbol, address);
   MSYMBOL_SECTION (msymbol) = section;
 
   MSYMBOL_TYPE (msymbol) = ms_type;
This page took 0.025029 seconds and 4 git commands to generate.