From cdd2212f7514672add02f490e7f7ab19c67d3a6e Mon Sep 17 00:00:00 2001 From: Kung Hsu Date: Fri, 21 Apr 1995 20:02:50 +0000 Subject: * 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. --- gdb/minsyms.c | 78 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) (limited to 'gdb/minsyms.c') diff --git a/gdb/minsyms.c b/gdb/minsyms.c index c04a353..75281ce 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 -- cgit v1.1