diff options
author | Simon Marchi <simon.marchi@efficios.com> | 2021-02-02 10:40:52 -0500 |
---|---|---|
committer | Simon Marchi <simon.marchi@polymtl.ca> | 2021-02-02 10:42:12 -0500 |
commit | e57933dc9cda3292f0baadbf80ff07d398566abb (patch) | |
tree | 968dec25a70d80a2fb73c3ffcffa4bbf1517bed3 | |
parent | 2b0c7f41d1d90811fbfd71c523aaa157c8f21448 (diff) | |
download | gdb-e57933dc9cda3292f0baadbf80ff07d398566abb.zip gdb-e57933dc9cda3292f0baadbf80ff07d398566abb.tar.gz gdb-e57933dc9cda3292f0baadbf80ff07d398566abb.tar.bz2 |
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
-rw-r--r-- | gdb/ChangeLog | 6 | ||||
-rw-r--r-- | gdb/dwarf2/read.c | 22 |
2 files changed, 18 insertions, 10 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 9f60a77..739b39e 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,11 @@ 2021-02-02 Simon Marchi <simon.marchi@efficios.com> + * dwarf2/read.c (read_loclist_index, read_rnglist_index): Return + a sect_offset. + (read_attribute_reprocess): Adjust. + +2021-02-02 Simon Marchi <simon.marchi@efficios.com> + * dwarf2/die.h (struct die_info) <ranges_base>: Split in... <gnu_ranges_base>: ... this... <rnglists_base>: ... and this. diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index dd2a885..5f89489 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: |