diff options
author | Paul Pluzhnikov <ppluzhnikov@google.com> | 2009-09-14 17:17:30 +0000 |
---|---|---|
committer | Paul Pluzhnikov <ppluzhnikov@google.com> | 2009-09-14 17:17:30 +0000 |
commit | 00878c6e41a8a85fde9d0011809027db3cddee61 (patch) | |
tree | a653e2e2f04ae95beb4160d0f4636886151154e3 /gdb/minsyms.c | |
parent | 6fbf07cd381e44b05e69db61080d0c9184def6fd (diff) | |
download | gdb-00878c6e41a8a85fde9d0011809027db3cddee61.zip gdb-00878c6e41a8a85fde9d0011809027db3cddee61.tar.gz gdb-00878c6e41a8a85fde9d0011809027db3cddee61.tar.bz2 |
2009-09-14 Paul Pluzhnikov <ppluzhnikov@google.com>
*minsyms.c (lookup_minimal_symbol_by_pc_section_1): Assert non-NULL
section.
(lookup_minimal_symbol_by_pc_section): Check for NULL section.
(lookup_minimal_symbol_by_pc): Adjust.
Diffstat (limited to 'gdb/minsyms.c')
-rw-r--r-- | gdb/minsyms.c | 45 |
1 files changed, 21 insertions, 24 deletions
diff --git a/gdb/minsyms.c b/gdb/minsyms.c index 1a1a37f..64d20d2 100644 --- a/gdb/minsyms.c +++ b/gdb/minsyms.c @@ -434,13 +434,14 @@ 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 - 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 - comes closest to the specified PC. This is because objfiles can - overlap, for example objfile A has .text at 0x100 and .data at - 0x40000 and objfile B has .text at 0x234 and .data at 0x40048. + than or equal to PC, and matches SECTION (which is not 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 comes closest to the specified PC. + This is because objfiles can overlap, for example objfile A has .text + at 0x100 and .data at 0x40000 and objfile B has .text at 0x234 and + .data at 0x40048. If WANT_TRAMPOLINE is set, prefer mst_solib_trampoline symbols when there are text and trampoline symbols at the same address. @@ -457,20 +458,12 @@ lookup_minimal_symbol_by_pc_section_1 (CORE_ADDR pc, struct objfile *objfile; struct minimal_symbol *msymbol; struct minimal_symbol *best_symbol = NULL; - struct obj_section *pc_section; enum minimal_symbol_type want_type, other_type; want_type = want_trampoline ? mst_solib_trampoline : mst_text; other_type = want_trampoline ? mst_text : mst_solib_trampoline; - - /* 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; - /* We can not require the symbol found to be in pc_section, because + /* We can not require the symbol found to be in section, because e.g. IRIX 6.5 mdebug relies on this code returning an absolute symbol - but find_pc_section won't return an absolute section and hence the code below would skip over absolute symbols. We can @@ -479,7 +472,8 @@ lookup_minimal_symbol_by_pc_section_1 (CORE_ADDR pc, files, search both the file and its separate debug file. There's no telling which one will have the minimal symbols. */ - objfile = pc_section->objfile; + gdb_assert (section != NULL); + objfile = section->objfile; if (objfile->separate_debug_objfile) objfile = objfile->separate_debug_objfile; @@ -680,6 +674,15 @@ lookup_minimal_symbol_by_pc_section_1 (CORE_ADDR pc, struct minimal_symbol * lookup_minimal_symbol_by_pc_section (CORE_ADDR pc, struct obj_section *section) { + if (section == NULL) + { + /* 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. */ + section = find_pc_section (pc); + if (section == NULL) + return NULL; + } return lookup_minimal_symbol_by_pc_section_1 (pc, section, 0); } @@ -689,13 +692,7 @@ lookup_minimal_symbol_by_pc_section (CORE_ADDR pc, struct obj_section *section) struct minimal_symbol * lookup_minimal_symbol_by_pc (CORE_ADDR 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); + return lookup_minimal_symbol_by_pc_section (pc, NULL); } |