From 43b54b88e73a74b1505df5eb4de6d6885bd4c3b4 Mon Sep 17 00:00:00 2001 From: Andrew Cagney Date: Mon, 9 Feb 2004 19:13:46 +0000 Subject: [PATCH] 2004-02-09 Andrew Cagney * blockframe.c (find_pc_partial_function): If find_pc_overlay fails, try find_pc_section. Fix PR c++/1267. * minsyms.c (lookup_minimal_symbol_by_pc): Use find_pc_section instead of find_pc_mapped_section. (lookup_minimal_symbol_by_pc_section): If the SECTION is NULL, do not default to the section containing PC. Fix PR symtab/1519. --- gdb/ChangeLog | 9 +++++++++ gdb/blockframe.c | 22 ++++++++++++++++++---- gdb/minsyms.c | 33 +++++++++++++++++++++------------ 3 files changed, 48 insertions(+), 16 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 55927f61dd8..afb0dc207a4 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,12 @@ +2004-02-09 Andrew Cagney + + * blockframe.c (find_pc_partial_function): If find_pc_overlay + fails, try find_pc_section. Fix PR c++/1267. + * minsyms.c (lookup_minimal_symbol_by_pc): Use find_pc_section + instead of find_pc_mapped_section. + (lookup_minimal_symbol_by_pc_section): If the SECTION is NULL, do + not default to the section containing PC. Fix PR symtab/1519. + 2004-02-09 Andrew Cagney * Makefile.in (mips-tdep.o): Update dependencies. diff --git a/gdb/blockframe.c b/gdb/blockframe.c index 00d7d8f13e4..409ec946156 100644 --- a/gdb/blockframe.c +++ b/gdb/blockframe.c @@ -507,10 +507,24 @@ int find_pc_partial_function (CORE_ADDR pc, char **name, CORE_ADDR *address, CORE_ADDR *endaddr) { - asection *section; - - section = find_pc_overlay (pc); - return find_pc_sect_partial_function (pc, section, name, address, endaddr); + struct bfd_section *bfd_section; + + /* To ensure that the symbol returned belongs to the correct setion + (and that the last [random] symbol from the previous section + isn't returned) try to find the section containing PC. First try + the overlay code (which by default returns NULL); and second try + the normal section code (which almost always succeeds). */ + bfd_section = find_pc_overlay (pc); + if (bfd_section == NULL) + { + struct obj_section *obj_section = find_pc_section (pc); + if (obj_section == NULL) + bfd_section = NULL; + else + bfd_section = obj_section->the_bfd_section; + } + return find_pc_sect_partial_function (pc, bfd_section, name, address, + endaddr); } /* Return the innermost stack frame executing inside of BLOCK, diff --git a/gdb/minsyms.c b/gdb/minsyms.c index 74b867d59b2..83aef9d4428 100644 --- a/gdb/minsyms.c +++ b/gdb/minsyms.c @@ -355,7 +355,7 @@ lookup_minimal_symbol_solib_trampoline (const char *name, /* 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 equal to PC, and matches SECTION (if non-null). Returns a + than or equal to PC, and matches SECTION (if non-NULL). Returns a pointer to the minimal symbol if such a symbol is found, or NULL if PC is not in a suitable range. Note that we need to look through ALL the minimal symbol tables before deciding on the symbol that @@ -374,20 +374,23 @@ lookup_minimal_symbol_by_pc_section (CORE_ADDR pc, asection *section) struct minimal_symbol *best_symbol = NULL; struct obj_section *pc_section; - /* pc has to be in a known section. This ensures that anything beyond - the end of the last segment doesn't appear to be part of the last - function in the last segment. */ + /* PC has to be in a known section. This ensures that anything + beyond the end of the last segment doesn't appear to be part of + the last function in the last segment. */ pc_section = find_pc_section (pc); if (pc_section == NULL) return NULL; - /* If no section was specified, then just make sure that the PC is in - the same section as the minimal symbol we find. */ - if (section == NULL) - section = pc_section->the_bfd_section; - - /* FIXME drow/2003-07-19: Should we also check that PC is in SECTION - if we were passed a non-NULL SECTION argument? */ + /* NOTE: cagney/2004-01-27: Removed code (added 2003-07-19) that was + trying to force the PC into a valid section as returned by + find_pc_section. It broke IRIX 6.5 mdebug which relies on this + code returning an absolute symbol - the problem was that + find_pc_section wasn't returning an absolute section and hence + the code below would skip over absolute symbols. Since the + original problem was with finding a frame's function, and that + uses [indirectly] lookup_minimal_symbol_by_pc, the original + problem has been fixed by having that function use + find_pc_section. */ for (objfile = object_files; objfile != NULL; @@ -497,7 +500,13 @@ lookup_minimal_symbol_by_pc_section (CORE_ADDR pc, asection *section) struct minimal_symbol * lookup_minimal_symbol_by_pc (CORE_ADDR pc) { - return lookup_minimal_symbol_by_pc_section (pc, find_pc_mapped_section (pc)); + /* NOTE: cagney/2004-01-27: This was using find_pc_mapped_section to + force the section but that (well unless you're doing overlay + debugging) always returns NULL making the call somewhat useless. */ + struct obj_section *section = find_pc_section (pc); + if (section == NULL) + return NULL; + return lookup_minimal_symbol_by_pc_section (pc, section->the_bfd_section); } -- 2.30.2