From e57933dc9cda3292f0baadbf80ff07d398566abb Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Tue, 2 Feb 2021 10:40:52 -0500 Subject: [PATCH] gdb/dwarf: make read_{loc,rng}list_index return sect_offset I think it's wrong that read_loclist_index and read_rnglist_index return a CORE_ADDR. A CORE_ADDR is an address in the program. These functions return offset in sections (.debug_loclists and .debug_rnglists). I think sect_offset is more appropriate. I'm wondering if struct attribute should have a "set_sect_offset" method, that takes a sect_offset parameter, or if it's better to be left as a simple "unsigned". gdb/ChangeLog: * dwarf2/read.c (read_loclist_index, read_rnglist_index): Return a sect_offset. (read_attribute_reprocess): Adjust. Change-Id: I0e22e0864130fb490072b41ae099762918b8ad4d --- gdb/ChangeLog | 6 ++++++ gdb/dwarf2/read.c | 22 ++++++++++++---------- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 9f60a77168e..739b39e50ff 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,9 @@ +2021-02-02 Simon Marchi + + * dwarf2/read.c (read_loclist_index, read_rnglist_index): Return + a sect_offset. + (read_attribute_reprocess): Adjust. + 2021-02-02 Simon Marchi * dwarf2/die.h (struct die_info) : Split in... diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index dd2a885691b..5f894895cdc 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -20223,7 +20223,8 @@ lookup_loclist_base (struct dwarf2_cu *cu) /* Given a DW_FORM_loclistx value LOCLIST_INDEX, fetch the offset from the array of offsets in the .debug_loclists section. */ -static CORE_ADDR + +static sect_offset read_loclist_index (struct dwarf2_cu *cu, ULONGEST loclist_index) { dwarf2_per_objfile *per_objfile = cu->per_objfile; @@ -20273,14 +20274,15 @@ read_loclist_index (struct dwarf2_cu *cu, ULONGEST loclist_index) const gdb_byte *info_ptr = section->buffer + start_offset; if (cu->header.offset_size == 4) - return bfd_get_32 (abfd, info_ptr) + loclist_base; + return (sect_offset) (bfd_get_32 (abfd, info_ptr) + loclist_base); else - return bfd_get_64 (abfd, info_ptr) + loclist_base; + return (sect_offset) (bfd_get_64 (abfd, info_ptr) + loclist_base); } /* Given a DW_FORM_rnglistx value RNGLIST_INDEX, fetch the offset from the array of offsets in the .debug_rnglists section. */ -static CORE_ADDR + +static sect_offset read_rnglist_index (struct dwarf2_cu *cu, ULONGEST rnglist_index, dwarf_tag tag) { @@ -20337,9 +20339,9 @@ read_rnglist_index (struct dwarf2_cu *cu, ULONGEST rnglist_index, const gdb_byte *info_ptr = section->buffer + start_offset; if (cu->header.offset_size == 4) - return read_4_bytes (abfd, info_ptr) + rnglist_base; + return (sect_offset) (read_4_bytes (abfd, info_ptr) + rnglist_base); else - return read_8_bytes (abfd, info_ptr) + rnglist_base; + return (sect_offset) (read_8_bytes (abfd, info_ptr) + rnglist_base); } /* Process the attributes that had to be skipped in the first round. These @@ -20360,18 +20362,18 @@ read_attribute_reprocess (const struct die_reader_specs *reader, break; case DW_FORM_loclistx: { - CORE_ADDR loclists_sect_off + sect_offset loclists_sect_off = read_loclist_index (cu, attr->as_unsigned_reprocess ()); - attr->set_unsigned (loclists_sect_off); + attr->set_unsigned (to_underlying (loclists_sect_off)); } break; case DW_FORM_rnglistx: { - CORE_ADDR rnglists_sect_off + sect_offset rnglists_sect_off = read_rnglist_index (cu, attr->as_unsigned_reprocess (), tag); - attr->set_unsigned (rnglists_sect_off); + attr->set_unsigned (to_underlying (rnglists_sect_off)); } break; case DW_FORM_strx: -- 2.30.2