summaryrefslogtreecommitdiff
path: root/gdb/minsyms.c
diff options
context:
space:
mode:
authorPaul Pluzhnikov <ppluzhnikov@google.com>2009-09-14 17:17:30 +0000
committerPaul Pluzhnikov <ppluzhnikov@google.com>2009-09-14 17:17:30 +0000
commitcb659000585c0f5a61c9c953ac789b93b5224f9b (patch)
tree0257b232ddbeda24123840ee335475764c629ec5 /gdb/minsyms.c
parenta8da7828378398afe77f2d62d3f9b11298222930 (diff)
downloadgdb-cb659000585c0f5a61c9c953ac789b93b5224f9b.tar.gz
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.c45
1 files changed, 21 insertions, 24 deletions
diff --git a/gdb/minsyms.c b/gdb/minsyms.c
index 1a1a37fa6df..64d20d2d7c0 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);
}