summaryrefslogtreecommitdiff
path: root/gdb/symfile.c
diff options
context:
space:
mode:
authorSimon Marchi <simon.marchi@polymtl.ca>2021-06-28 15:28:26 -0400
committerSimon Marchi <simon.marchi@polymtl.ca>2021-06-28 15:28:26 -0400
commit0c1bcd23274e9f465dc43eda4fc467150631f824 (patch)
treea7ebad33d064631f80c6b016da5cb3e2df3eedae /gdb/symfile.c
parentf07fad95a949b070e51a18276b8f1e03cf86490f (diff)
gdb: convert obj_section macros to methods
Convert these three macros to methods of obj_section. The problem fixed by the following patch is caused by an out of bound access of the objfile::section_offsets vector. Since this is deep in macros, we don't get a clear backtrace and it's difficult to debug. Changing that to methods means we can step in them and break on them. Because their implementation requires knowing about struct objfile, move struct obj_section below struct objfile in objfiles.h. The obj_section_offset was used in one place as an lvalue to set offsets, in machoread.c. Replace that with a set_offset method. Add the objfile::section_offset and objfile::set_section_offset methods to improve encapsulation (reduce other objects poking into struct objfile's internals). gdb/ChangeLog: * objfiles.h (struct obj_section): Move down. <offset, set_offset, addr, endaddr>: New. (obj_section_offset, obj_section_addr, obj_section_endaddr), replace all users to use obj_section methods. (struct objfile) <section_offset, set_section_offset>: New. Change-Id: I97e8fcae93ab2353fbdadcb4a5ec10d7949a7334
Diffstat (limited to 'gdb/symfile.c')
-rw-r--r--gdb/symfile.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/gdb/symfile.c b/gdb/symfile.c
index 5ae3093095..0eb48d04d5 100644
--- a/gdb/symfile.c
+++ b/gdb/symfile.c
@@ -3012,7 +3012,7 @@ pc_in_unmapped_range (CORE_ADDR pc, struct obj_section *section)
/* We assume the LMA is relocated by the same offset as the VMA. */
bfd_vma size = bfd_section_size (bfd_section);
- CORE_ADDR offset = obj_section_offset (section);
+ CORE_ADDR offset = section->offset ();
if (bfd_section_lma (bfd_section) + offset <= pc
&& pc < bfd_section_lma (bfd_section) + offset + size)
@@ -3030,8 +3030,8 @@ pc_in_mapped_range (CORE_ADDR pc, struct obj_section *section)
{
if (section_is_overlay (section))
{
- if (obj_section_addr (section) <= pc
- && pc < obj_section_endaddr (section))
+ if (section->addr () <= pc
+ && pc < section->endaddr ())
return 1;
}
@@ -3044,10 +3044,10 @@ pc_in_mapped_range (CORE_ADDR pc, struct obj_section *section)
static int
sections_overlap (struct obj_section *a, struct obj_section *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);
+ CORE_ADDR a_start = a->addr ();
+ CORE_ADDR a_end = a->endaddr ();
+ CORE_ADDR b_start = b->addr ();
+ CORE_ADDR b_end = b->endaddr ();
return (a_start < b_end && b_start < a_end);
}