From: Kung Hsu Date: Fri, 21 Apr 1995 20:02:50 +0000 (+0000) Subject: * minsyms.c: add new function lookup_minimal_symbol_text, to look X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=cdd2212f7514672add02f490e7f7ab19c67d3a6e;p=binutils-gdb.git * 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. --- diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 24d28a24935..b589afbd704 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,11 @@ +Fri Apr 21 12:57:53 1995 Kung Hsu + + * 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 * sh-tdep.c (sh-opc.h): Don't include. diff --git a/gdb/minsyms.c b/gdb/minsyms.c index c04a3538c28..75281ce49cd 100644 --- a/gdb/minsyms.c +++ b/gdb/minsyms.c @@ -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