aboutsummaryrefslogtreecommitdiff
path: root/gdb/symfile.c
diff options
context:
space:
mode:
authorUlrich Weigand <uweigand@de.ibm.com>2008-09-05 11:37:18 +0000
committerUlrich Weigand <uweigand@de.ibm.com>2008-09-05 11:37:18 +0000
commit714835d5a63b86bb0e82c13d2a4840d8b5e633d3 (patch)
tree7c84b75c6ae819733cc44c04a6b3d3e9bef9ce08 /gdb/symfile.c
parentf91609ee709c69acbeafdd7000a70a7b63579ee3 (diff)
downloadgdb-714835d5a63b86bb0e82c13d2a4840d8b5e633d3.zip
gdb-714835d5a63b86bb0e82c13d2a4840d8b5e633d3.tar.gz
gdb-714835d5a63b86bb0e82c13d2a4840d8b5e633d3.tar.bz2
* breakpoint.h (struct bp_location): Change type of section
member to "struct obj_section *". * tracepoint.h (struct tracepoint): Likewise. * symtab.h (struct general_symbol_info): Replace bfd_section member with obj_section. (struct symtab_and_line): Change type of section member to "struct obj_section *". (SYMBOL_BFD_SECTION): Remove macro, replace by ... (SYMBOL_OBJ_SECTION): ... this. * minsym.c (prim_record_minimal_symbol_and_info): Record symbol section as obj_section instead of bfd_section. * ada-lang.c (ada_decode_symbol): Use gsymbol->obj_section directly instead of looking of obj_section from bfd_section. * objfiles.h (find_pc_sect_section): Remove. * objfiles.c (find_pc_sect_section): Remove. (find_pc_section): Inline find_pc_sect_section code. * symfile.h (find_pc_overlay): Return struct obj_section *. (find_pc_mapped_section): Likewise. (section_is_overlay, section_is_mapped): Change type of section argument to struct obj_section *. (pc_in_mapped_range, pc_in_unmapped_range): Likewise. (overlay_mapped_address, overlay_unmapped_address): Likewise. (symbol_overlayed_address): Likewise. * symtab.h (symbol_overlayed_address): Likewise. * symfile.c (overlay_is_mapped): Remove. (section_is_mapped): Inline overlay_is_mapped code. Update. (overlay_invalidate_all): Update. (section_is_overlay): Change section argument to type "struct obj_section *". Use bfd_ methods. (pc_in_unmapped_range): Likewise. Handle relocated sections. (pc_in_mapped_range): Likewise. Handle relocated sections. (sections_overlap): Likewise. (overlay_unmapped_address): Likewise. (overlay_mapped_address): Likewise. (symbol_overlayed_address): Likewise. (find_pc_overlay): Return struct obj_section *. (find_pc_mapped_section): Likewise. (list_overlays_command): Update. (map_overlay_command, unmap_overlay_command): Update. (simple_overlay_update): Update. * block.h (blockvector_for_pc_sect): Change section argument to type "struct obj_section *". (block_for_pc_sect): Likewise. * block.c (blockvector_for_pc_sect): Change section argument to type "struct obj_section *". (block_for_pc_sect): Likewise. * symtab.h (find_pc_sect_function, find_pc_sect_psymtab, find_pc_sect_symtab, find_pc_sect_psymbol, find_pc_sect_line, lookup_minimal_symbol_by_pc_section, find_function_start_pc): Likewise. (matching_bfd_sections): Rename to ... (matching_obj_sections): ... this. Update argument types. * blockframe.c (find_pc_sect_function): Likewise. * breakpoint.c (describe_other_breakpoints): Likewise. (breakpoint_has_pc, check_duplicates_for): Likewise. * minsyms.c (lookup_minimal_symbol_by_pc_section_1): Likewise. (lookup_minimal_symbol_by_pc_section): Likewise. * symtab.c (find_pc_sect_psymtab_closer): Likewise. (find_pc_sect_psymtab, find_pc_sect_psymbol, find_pc_sect_symtab, find_pc_sect_line, find_function_start_pc): Likewise. (matching_bfd_sections): Rename to ... (matching_obj_sections): ... this. Update argument types. * blockframe.c (find_pc_partial_function): Update to section type changes. No longer call find_pc_sect_section. (cache_pc_function_section): Change to type "struct obj_section *". * breakpoint.c (resolve_sal_pc): Update to section type changes. * exec.c (xfer_memory): Likewise. * findvar.c (read_var_value): Likewise. * infcmd.c (jump_command): Likewise. * linespec.c (minsym_found): Likewise. * maint.c (maintenance_translate_address): Likewise. * minsyms.c (lookup_minimal_symbol_by_pc_section_1): Likewise. (lookup_solib_trampoline_symbol_by_pc): Likewise. * parse.c (write_exp_msymbol): Likewise. * printcmd.c (build_address_symbolic): Likewise. (address_info, sym_info): Likewise. * symmisc.c (dump_msymbols, print_symbol): Likewise. * symtab.c (fixup_section): Likewise. (fixup_symbol_section, fixup_psymbol_section): Likewise. (find_pc_line, find_function_start_sal): Likewise. * target.c (memory_xfer_partial): Likewise. * hppa-hpux-tdep.c (hppa64_hpux_in_solib_call_trampoline): Likewise. * spu-tdep.c (spu_overlay_update): Likewise.
Diffstat (limited to 'gdb/symfile.c')
-rw-r--r--gdb/symfile.c171
1 files changed, 74 insertions, 97 deletions
diff --git a/gdb/symfile.c b/gdb/symfile.c
index 8d22005..d067d2b 100644
--- a/gdb/symfile.c
+++ b/gdb/symfile.c
@@ -111,8 +111,6 @@ static void decrement_reading_symtab (void *);
static void overlay_invalidate_all (void);
-static int overlay_is_mapped (struct obj_section *);
-
void list_overlays_command (char *, int);
void map_overlay_command (char *, int);
@@ -3253,7 +3251,7 @@ init_psymbol_list (struct objfile *objfile, int total_symbols)
section, return that section.
find_pc_overlay(pc): find any overlay section that contains
the pc, either in its VMA or its LMA
- overlay_is_mapped(sect): true if overlay is marked as mapped
+ section_is_mapped(sect): true if overlay is marked as mapped
section_is_overlay(sect): true if section's VMA != LMA
pc_in_mapped_range(pc,sec): true if pc belongs to section's VMA
pc_in_unmapped_range(...): true if pc belongs to section's LMA
@@ -3275,14 +3273,18 @@ int overlay_cache_invalid = 0; /* True if need to refresh mapped state */
SECTION is loaded at an address different from where it will "run". */
int
-section_is_overlay (asection *section)
+section_is_overlay (struct obj_section *section)
{
- /* FIXME: need bfd *, so we can use bfd_section_lma methods. */
-
- if (overlay_debugging)
- if (section && section->lma != 0 &&
- section->vma != section->lma)
- return 1;
+ if (overlay_debugging && section)
+ {
+ bfd *abfd = section->objfile->obfd;
+ asection *bfd_section = section->the_bfd_section;
+
+ if (bfd_section_lma (abfd, bfd_section) != 0
+ && bfd_section_lma (abfd, bfd_section)
+ != bfd_section_vma (abfd, bfd_section))
+ return 1;
+ }
return 0;
}
@@ -3297,13 +3299,12 @@ overlay_invalidate_all (void)
struct obj_section *sect;
ALL_OBJSECTIONS (objfile, sect)
- if (section_is_overlay (sect->the_bfd_section))
- sect->ovly_mapped = -1;
+ if (section_is_overlay (sect))
+ sect->ovly_mapped = -1;
}
-/* Function: overlay_is_mapped (SECTION)
+/* Function: section_is_mapped (SECTION)
Returns true if section is an overlay, and is currently mapped.
- Private: public access is thru function section_is_mapped.
Access to the ovly_mapped flag is restricted to this function, so
that we can do automatic update. If the global flag
@@ -3311,10 +3312,10 @@ overlay_invalidate_all (void)
overlay_invalidate_all. If the mapped state of the particular
section is stale, then call TARGET_OVERLAY_UPDATE to refresh it. */
-static int
-overlay_is_mapped (struct obj_section *osect)
+int
+section_is_mapped (struct obj_section *osect)
{
- if (osect == 0 || !section_is_overlay (osect->the_bfd_section))
+ if (osect == 0 || !section_is_overlay (osect))
return 0;
switch (overlay_debugging)
@@ -3341,41 +3342,26 @@ overlay_is_mapped (struct obj_section *osect)
}
}
-/* Function: section_is_mapped
- Returns true if section is an overlay, and is currently mapped. */
-
-int
-section_is_mapped (asection *section)
-{
- struct objfile *objfile;
- struct obj_section *osect;
-
- if (overlay_debugging)
- if (section && section_is_overlay (section))
- ALL_OBJSECTIONS (objfile, osect)
- if (osect->the_bfd_section == section)
- return overlay_is_mapped (osect);
-
- return 0;
-}
-
/* Function: pc_in_unmapped_range
If PC falls into the lma range of SECTION, return true, else false. */
CORE_ADDR
-pc_in_unmapped_range (CORE_ADDR pc, asection *section)
+pc_in_unmapped_range (CORE_ADDR pc, struct obj_section *section)
{
- /* FIXME: need bfd *, so we can use bfd_section_lma methods. */
+ if (section_is_overlay (section))
+ {
+ bfd *abfd = section->objfile->obfd;
+ asection *bfd_section = section->the_bfd_section;
- int size;
+ /* We assume the LMA is relocated by the same offset as the VMA. */
+ bfd_vma size = bfd_get_section_size (bfd_section);
+ CORE_ADDR offset = obj_section_offset (section);
+
+ if (bfd_get_section_lma (abfd, bfd_section) + offset <= pc
+ && pc < bfd_get_section_lma (abfd, bfd_section) + offset + size)
+ return 1;
+ }
- if (overlay_debugging)
- if (section && section_is_overlay (section))
- {
- size = bfd_get_section_size (section);
- if (section->lma <= pc && pc < section->lma + size)
- return 1;
- }
return 0;
}
@@ -3383,19 +3369,15 @@ pc_in_unmapped_range (CORE_ADDR pc, asection *section)
If PC falls into the vma range of SECTION, return true, else false. */
CORE_ADDR
-pc_in_mapped_range (CORE_ADDR pc, asection *section)
+pc_in_mapped_range (CORE_ADDR pc, struct obj_section *section)
{
- /* FIXME: need bfd *, so we can use bfd_section_vma methods. */
-
- int size;
+ if (section_is_overlay (section))
+ {
+ if (obj_section_addr (section) <= pc
+ && pc < obj_section_endaddr (section))
+ return 1;
+ }
- if (overlay_debugging)
- if (section && section_is_overlay (section))
- {
- size = bfd_get_section_size (section);
- if (section->vma <= pc && pc < section->vma + size)
- return 1;
- }
return 0;
}
@@ -3403,14 +3385,12 @@ pc_in_mapped_range (CORE_ADDR pc, asection *section)
/* Return true if the mapped ranges of sections A and B overlap, false
otherwise. */
static int
-sections_overlap (asection *a, asection *b)
+sections_overlap (struct obj_section *a, struct obj_section *b)
{
- /* FIXME: need bfd *, so we can use bfd_section_vma methods. */
-
- CORE_ADDR a_start = a->vma;
- CORE_ADDR a_end = a->vma + bfd_get_section_size (a);
- CORE_ADDR b_start = b->vma;
- CORE_ADDR b_end = b->vma + bfd_get_section_size (b);
+ CORE_ADDR a_start = obj_section_addr (a);
+ CORE_ADDR a_end = obj_section_endaddr (a);
+ CORE_ADDR b_start = obj_section_addr (b);
+ CORE_ADDR b_end = obj_section_endaddr (b);
return (a_start < b_end && b_start < a_end);
}
@@ -3420,14 +3400,16 @@ sections_overlap (asection *a, asection *b)
May be the same as PC. */
CORE_ADDR
-overlay_unmapped_address (CORE_ADDR pc, asection *section)
+overlay_unmapped_address (CORE_ADDR pc, struct obj_section *section)
{
- /* FIXME: need bfd *, so we can use bfd_section_lma methods. */
+ if (section_is_overlay (section) && pc_in_mapped_range (pc, section))
+ {
+ bfd *abfd = section->objfile->obfd;
+ asection *bfd_section = section->the_bfd_section;
- if (overlay_debugging)
- if (section && section_is_overlay (section) &&
- pc_in_mapped_range (pc, section))
- return pc + section->lma - section->vma;
+ return pc + bfd_section_lma (abfd, bfd_section)
+ - bfd_section_vma (abfd, bfd_section);
+ }
return pc;
}
@@ -3437,14 +3419,16 @@ overlay_unmapped_address (CORE_ADDR pc, asection *section)
May be the same as PC. */
CORE_ADDR
-overlay_mapped_address (CORE_ADDR pc, asection *section)
+overlay_mapped_address (CORE_ADDR pc, struct obj_section *section)
{
- /* FIXME: need bfd *, so we can use bfd_section_vma methods. */
+ if (section_is_overlay (section) && pc_in_unmapped_range (pc, section))
+ {
+ bfd *abfd = section->objfile->obfd;
+ asection *bfd_section = section->the_bfd_section;
- if (overlay_debugging)
- if (section && section_is_overlay (section) &&
- pc_in_unmapped_range (pc, section))
- return pc + section->vma - section->lma;
+ return pc + bfd_section_vma (abfd, bfd_section)
+ - bfd_section_lma (abfd, bfd_section);
+ }
return pc;
}
@@ -3455,7 +3439,7 @@ overlay_mapped_address (CORE_ADDR pc, asection *section)
depending on whether the section is mapped or not. */
CORE_ADDR
-symbol_overlayed_address (CORE_ADDR address, asection *section)
+symbol_overlayed_address (CORE_ADDR address, struct obj_section *section)
{
if (overlay_debugging)
{
@@ -3483,7 +3467,7 @@ symbol_overlayed_address (CORE_ADDR address, asection *section)
Else if PC matches an unmapped section's VMA, return that section.
Else if PC matches an unmapped section's LMA, return that section. */
-asection *
+struct obj_section *
find_pc_overlay (CORE_ADDR pc)
{
struct objfile *objfile;
@@ -3491,26 +3475,26 @@ find_pc_overlay (CORE_ADDR pc)
if (overlay_debugging)
ALL_OBJSECTIONS (objfile, osect)
- if (section_is_overlay (osect->the_bfd_section))
+ if (section_is_overlay (osect))
{
- if (pc_in_mapped_range (pc, osect->the_bfd_section))
+ if (pc_in_mapped_range (pc, osect))
{
- if (overlay_is_mapped (osect))
- return osect->the_bfd_section;
+ if (section_is_mapped (osect))
+ return osect;
else
best_match = osect;
}
- else if (pc_in_unmapped_range (pc, osect->the_bfd_section))
+ else if (pc_in_unmapped_range (pc, osect))
best_match = osect;
}
- return best_match ? best_match->the_bfd_section : NULL;
+ return best_match;
}
/* Function: find_pc_mapped_section (PC)
If PC falls into the VMA address range of an overlay section that is
currently marked as MAPPED, return that section. Else return NULL. */
-asection *
+struct obj_section *
find_pc_mapped_section (CORE_ADDR pc)
{
struct objfile *objfile;
@@ -3518,9 +3502,8 @@ find_pc_mapped_section (CORE_ADDR pc)
if (overlay_debugging)
ALL_OBJSECTIONS (objfile, osect)
- if (pc_in_mapped_range (pc, osect->the_bfd_section) &&
- overlay_is_mapped (osect))
- return osect->the_bfd_section;
+ if (pc_in_mapped_range (pc, osect) && section_is_mapped (osect))
+ return osect;
return NULL;
}
@@ -3537,7 +3520,7 @@ list_overlays_command (char *args, int from_tty)
if (overlay_debugging)
ALL_OBJSECTIONS (objfile, osect)
- if (overlay_is_mapped (osect))
+ if (section_is_mapped (osect))
{
const char *name;
bfd_vma lma, vma;
@@ -3572,7 +3555,6 @@ map_overlay_command (char *args, int from_tty)
{
struct objfile *objfile, *objfile2;
struct obj_section *sec, *sec2;
- asection *bfdsec;
if (!overlay_debugging)
error (_("\
@@ -3587,8 +3569,7 @@ the 'overlay manual' command."));
if (!strcmp (bfd_section_name (objfile->obfd, sec->the_bfd_section), args))
{
/* Now, check to see if the section is an overlay. */
- bfdsec = sec->the_bfd_section;
- if (!section_is_overlay (bfdsec))
+ if (!section_is_overlay (sec))
continue; /* not an overlay section */
/* Mark the overlay as "mapped" */
@@ -3597,11 +3578,7 @@ the 'overlay manual' command."));
/* Next, make a pass and unmap any sections that are
overlapped by this new section: */
ALL_OBJSECTIONS (objfile2, sec2)
- if (sec2->ovly_mapped
- && sec != sec2
- && sec->the_bfd_section != sec2->the_bfd_section
- && sections_overlap (sec->the_bfd_section,
- sec2->the_bfd_section))
+ if (sec2->ovly_mapped && sec != sec2 && sections_overlap (sec, sec2))
{
if (info_verbose)
printf_unfiltered (_("Note: section %s unmapped by overlap\n"),
@@ -3941,7 +3918,7 @@ simple_overlay_update (struct obj_section *osect)
/* Now may as well update all sections, even if only one was requested. */
ALL_OBJSECTIONS (objfile, osect)
- if (section_is_overlay (osect->the_bfd_section))
+ if (section_is_overlay (osect))
{
int i, size;
bfd *obfd = osect->objfile->obfd;