aboutsummaryrefslogtreecommitdiff
path: root/gdb/objfiles.h
diff options
context:
space:
mode:
authorSimon Marchi <simon.marchi@polymtl.ca>2020-01-23 17:55:35 -0500
committerSimon Marchi <simon.marchi@efficios.com>2020-01-23 17:55:35 -0500
commitb3b3bada0d514f8e57a04fd333f05d1da94e2304 (patch)
treefb20ef8071ffa1e058668d0f823d38da07381c70 /gdb/objfiles.h
parentab53f3826242df0f051f9a6fa4b2926687205025 (diff)
downloadgdb-b3b3bada0d514f8e57a04fd333f05d1da94e2304.zip
gdb-b3b3bada0d514f8e57a04fd333f05d1da94e2304.tar.gz
gdb-b3b3bada0d514f8e57a04fd333f05d1da94e2304.tar.bz2
gdb: introduce objfile text_section_offset and data_section_offset methods
The pattern objfile->section_offsets[SECT_OFF_TEXT (objfile)] ... appears very often, to get the offset of the text section of an objfile. I thought it would be more readable to write it as: objfile->text_section_offset () ... so I added this method and used it where possible. I also added data_section_offset, although it is not used as much. gdb/ChangeLog: * objfiles.h (ALL_OBJFILE_OSECTIONS): Move up. (SECT_OFF_DATA): Likewise. (SECT_OFF_RODATA): Likewise. (SECT_OFF_TEXT): Likewise. (SECT_OFF_BSS): Likewise. (struct objfile) <text_section_offset, data_section_offset>: New methods. * amd64-windows-tdep.c (amd64_windows_find_unwind_info): Use objfile::text_section_offset. * coff-pe-read.c (add_pe_forwarded_sym): Likewise. * coffread.c (coff_symtab_read): Likewise. (enter_linenos): Likewise. (process_coff_symbol): Likewise. * ctfread.c (get_objfile_text_range): Likewise. * dtrace-probe.c (dtrace_probe::get_relocated_address): Use objfile::data_section_offset. * dwarf2-frame.c (execute_cfa_program): Use objfile::text_section_offset. (dwarf2_frame_find_fde): Likewise. * dwarf2read.c (create_addrmap_from_index): Likewise. (create_addrmap_from_aranges): Likewise. (dw2_find_pc_sect_compunit_symtab): Likewise. (process_psymtab_comp_unit_reader): Likewise. (add_partial_symbol): Likewise. (add_partial_subprogram): Likewise. (process_full_comp_unit): Likewise. (read_file_scope): Likewise. (read_func_scope): Likewise. (read_lexical_block_scope): Likewise. (read_call_site_scope): Likewise. (dwarf2_rnglists_process): Likewise. (dwarf2_ranges_process): Likewise. (dwarf2_ranges_read): Likewise. (dwarf_decode_lines_1): Likewise. (new_symbol): Likewise. (dwarf2_fetch_die_loc_sect_off): Likewise. (dwarf2_per_cu_text_offset): Likewise. * hppa-bsd-tdep.c (hppabsd_find_global_pointer): Likewise. * hppa-tdep.c (read_unwind_info): Likewise. * ia64-tdep.c (ia64_find_unwind_table): Likewise. * psympriv.h (struct partial_symtab): Likewise. * psymtab.c (find_pc_sect_psymtab): Likewise. * solib-svr4.c (enable_break): Likewise. * stap-probe.c (relocate_address): Use objfile::data_section_offset. * xcoffread.c (enter_line_range): Use objfile::text_section_offset. (read_xcoff_symtab): Likewise.
Diffstat (limited to 'gdb/objfiles.h')
-rw-r--r--gdb/objfiles.h72
1 files changed, 40 insertions, 32 deletions
diff --git a/gdb/objfiles.h b/gdb/objfiles.h
index 1301f2c..b71a8a9 100644
--- a/gdb/objfiles.h
+++ b/gdb/objfiles.h
@@ -155,6 +155,37 @@ struct obj_section
+ bfd_section_size ((s)->the_bfd_section) \
+ obj_section_offset (s))
+#define ALL_OBJFILE_OSECTIONS(objfile, osect) \
+ for (osect = objfile->sections; osect < objfile->sections_end; osect++) \
+ if (osect->the_bfd_section == NULL) \
+ { \
+ /* Nothing. */ \
+ } \
+ else
+
+#define SECT_OFF_DATA(objfile) \
+ ((objfile->sect_index_data == -1) \
+ ? (internal_error (__FILE__, __LINE__, \
+ _("sect_index_data not initialized")), -1) \
+ : objfile->sect_index_data)
+
+#define SECT_OFF_RODATA(objfile) \
+ ((objfile->sect_index_rodata == -1) \
+ ? (internal_error (__FILE__, __LINE__, \
+ _("sect_index_rodata not initialized")), -1) \
+ : objfile->sect_index_rodata)
+
+#define SECT_OFF_TEXT(objfile) \
+ ((objfile->sect_index_text == -1) \
+ ? (internal_error (__FILE__, __LINE__, \
+ _("sect_index_text not initialized")), -1) \
+ : objfile->sect_index_text)
+
+/* Sometimes the .bss section is missing from the objfile, so we don't
+ want to die here. Let the users of SECT_OFF_BSS deal with an
+ uninitialized section index. */
+#define SECT_OFF_BSS(objfile) (objfile)->sect_index_bss
+
/* The "objstats" structure provides a place for gdb to record some
interesting information about its internal state at runtime, on a
per objfile basis, such as information about the number of symbols
@@ -492,6 +523,15 @@ public:
return separate_debug_range (this);
}
+ CORE_ADDR text_section_offset () const
+ {
+ return section_offsets[SECT_OFF_TEXT (this)];
+ }
+
+ CORE_ADDR data_section_offset () const
+ {
+ return section_offsets[SECT_OFF_DATA (this)];
+ }
/* The object file's original name as specified by the user,
made absolute, and tilde-expanded. However, it is not canonicalized
@@ -737,38 +777,6 @@ extern void default_iterate_over_objfiles_in_search_order
(struct gdbarch *gdbarch,
iterate_over_objfiles_in_search_order_cb_ftype *cb,
void *cb_data, struct objfile *current_objfile);
-
-
-#define ALL_OBJFILE_OSECTIONS(objfile, osect) \
- for (osect = objfile->sections; osect < objfile->sections_end; osect++) \
- if (osect->the_bfd_section == NULL) \
- { \
- /* Nothing. */ \
- } \
- else
-
-#define SECT_OFF_DATA(objfile) \
- ((objfile->sect_index_data == -1) \
- ? (internal_error (__FILE__, __LINE__, \
- _("sect_index_data not initialized")), -1) \
- : objfile->sect_index_data)
-
-#define SECT_OFF_RODATA(objfile) \
- ((objfile->sect_index_rodata == -1) \
- ? (internal_error (__FILE__, __LINE__, \
- _("sect_index_rodata not initialized")), -1) \
- : objfile->sect_index_rodata)
-
-#define SECT_OFF_TEXT(objfile) \
- ((objfile->sect_index_text == -1) \
- ? (internal_error (__FILE__, __LINE__, \
- _("sect_index_text not initialized")), -1) \
- : objfile->sect_index_text)
-
-/* Sometimes the .bss section is missing from the objfile, so we don't
- want to die here. Let the users of SECT_OFF_BSS deal with an
- uninitialized section index. */
-#define SECT_OFF_BSS(objfile) (objfile)->sect_index_bss
/* Reset the per-BFD storage area on OBJ. */