* minsyms.c: add new function lookup_minimal_symbol_text, to look
authorKung Hsu <kung@cygnus>
Fri, 21 Apr 1995 20:02:50 +0000 (20:02 +0000)
committerKung Hsu <kung@cygnus>
Fri, 21 Apr 1995 20:02:50 +0000 (20:02 +0000)
for text symbol only.
* breakpoint.c (create_longjmp_breakpoint): call
lookup_minimal_symbol_text instead of lookup_minimal_symbol.
* symtab.h: add lookup_minimal_symbol_text prototype.

gdb/ChangeLog
gdb/minsyms.c

index 24d28a24935a60645d58dc089e56e66f6d233bf7..b589afbd704c67d48c966cca11a702c24465fc03 100644 (file)
@@ -1,3 +1,11 @@
+Fri Apr 21 12:57:53 1995  Kung Hsu  <kung@mexican.cygnus.com>
+
+       * minsyms.c: add new function lookup_minimal_symbol_text, to look
+       for text symbol only.
+       * breakpoint.c (create_longjmp_breakpoint): call
+       lookup_minimal_symbol_text instead of lookup_minimal_symbol.
+       * symtab.h: add lookup_minimal_symbol_text prototype.
+
 Fri Apr 21 12:03:44 1995  Stan Shebs  <shebs@andros.cygnus.com>
 
        * sh-tdep.c (sh-opc.h): Don't include.
index c04a3538c286e796797255cadc3899ef1e1964a5..75281ce49cdb387a660e265b92003952db409575 100644 (file)
@@ -176,6 +176,84 @@ lookup_minimal_symbol (name, sfile, objf)
   return NULL;
 }
 
+/* Look through all the current minimal symbol tables and find the
+   first minimal symbol that matches NAME and of text type.  
+   If OBJF is non-NULL, limit
+   the search to that objfile.  If SFILE is non-NULL, limit the search
+   to that source file.  Returns a pointer to the minimal symbol that
+   matches, or NULL if no match is found.
+*/
+   
+struct minimal_symbol *
+lookup_minimal_symbol_text (name, sfile, objf)
+     register const char *name;
+     const char *sfile;
+     struct objfile *objf;
+{
+  struct objfile *objfile;
+  struct minimal_symbol *msymbol;
+  struct minimal_symbol *found_symbol = NULL;
+  struct minimal_symbol *found_file_symbol = NULL;
+  struct minimal_symbol *trampoline_symbol = NULL;
+
+#ifdef SOFUN_ADDRESS_MAYBE_MISSING
+  if (sfile != NULL)
+    {
+      char *p = strrchr (sfile, '/');
+      if (p != NULL)
+       sfile = p + 1;
+    }
+#endif
+
+  for (objfile = object_files;
+       objfile != NULL && found_symbol == NULL;
+       objfile = objfile -> next)
+    {
+      if (objf == NULL || objf == objfile)
+       {
+         for (msymbol = objfile -> msymbols;
+              msymbol != NULL && SYMBOL_NAME (msymbol) != NULL &&
+              found_symbol == NULL;
+              msymbol++)
+           {
+             if (SYMBOL_MATCHES_NAME (msymbol, name) && 
+                 (MSYMBOL_TYPE (msymbol) == mst_text ||
+                  MSYMBOL_TYPE (msymbol) == mst_file_text))
+               {
+                 switch (MSYMBOL_TYPE (msymbol))
+                   {
+                   case mst_file_text:
+#ifdef SOFUN_ADDRESS_MAYBE_MISSING
+                     if (sfile == NULL || STREQ (msymbol->filename, sfile))
+                       found_file_symbol = msymbol;
+#else
+                     /* We have neither the ability nor the need to
+                        deal with the SFILE parameter.  If we find
+                        more than one symbol, just return the latest
+                        one (the user can't expect useful behavior in
+                        that case).  */
+                     found_file_symbol = msymbol;
+#endif
+                     break;
+                   default:
+                     found_symbol = msymbol;
+                     break;
+                   }
+               }
+           }
+       }
+    }
+  /* External symbols are best.  */
+  if (found_symbol)
+    return found_symbol;
+
+  /* File-local symbols are next best.  */
+  if (found_file_symbol)
+    return found_file_symbol;
+
+  return NULL;
+}
+
 
 /* Search through the minimal symbol table for each objfile and find the
    symbol whose address is the largest address that is still less than or