From: Simon Marchi via Gdb-patches <gdb-patches@sourceware.org>
To: gdb-patches@sourceware.org
Cc: Simon Marchi <simon.marchi@efficios.com>
Subject: [PATCH 12/13] gdb/dwarf: make read_{loc, rng}list_index return sect_offset
Date: Wed, 20 Jan 2021 00:39:24 -0500 [thread overview]
Message-ID: <20210120053925.142862-13-simon.marchi@polymtl.ca> (raw)
In-Reply-To: <20210120053925.142862-1-simon.marchi@polymtl.ca>
From: Simon Marchi <simon.marchi@efficios.com>
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/dwarf2/read.c | 22 ++++++++++++----------
1 file changed, 12 insertions(+), 10 deletions(-)
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index 86a69efe8ecc..b4ac290ca319 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -20195,7 +20195,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;
@@ -20245,14 +20246,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)
{
@@ -20309,9 +20311,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
@@ -20332,18 +20334,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.0
next prev parent reply other threads:[~2021-01-20 5:41 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-20 5:39 [PATCH 00/13] DWARF 5 rnglists & loclists fixes (PR 26813) Simon Marchi via Gdb-patches
2021-01-20 5:39 ` [PATCH 01/13] gdb/dwarf: change read_loclist_index complaints into errors Simon Marchi via Gdb-patches
2021-01-28 15:17 ` Zoran Zaric via Gdb-patches
2021-01-28 15:42 ` Simon Marchi via Gdb-patches
2021-02-25 19:20 ` Tom Tromey
2021-01-20 5:39 ` [PATCH 02/13] gdb/dwarf: fix bound check in read_rnglist_index Simon Marchi via Gdb-patches
2021-01-28 15:22 ` Zoran Zaric via Gdb-patches
2021-01-20 5:39 ` [PATCH 03/13] gdb/dwarf: add missing bound check to read_loclist_index Simon Marchi via Gdb-patches
2021-01-20 5:39 ` [PATCH 04/13] gdb/dwarf: remove unnecessary check in read_{rng, loc}list_index Simon Marchi via Gdb-patches
2021-01-20 5:39 ` [PATCH 05/13] gdb/dwarf: few fixes for handling DW_FORM_{rng, loc}listx Simon Marchi via Gdb-patches
2021-01-28 15:30 ` [PATCH 05/13] gdb/dwarf: few fixes for handling DW_FORM_{rng,loc}listx Zoran Zaric via Gdb-patches
2021-01-20 5:39 ` [PATCH 06/13] gdb/dwarf: read correct rnglist/loclist header in read_{rng, loc}list_index Simon Marchi via Gdb-patches
2021-01-28 15:39 ` [PATCH 06/13] gdb/dwarf: read correct rnglist/loclist header in read_{rng,loc}list_index Zoran Zaric via Gdb-patches
2021-01-28 15:49 ` Simon Marchi via Gdb-patches
2021-01-28 15:54 ` Zoran Zaric via Gdb-patches
2021-01-20 5:39 ` [PATCH 07/13] gdb/dwarf: read DW_AT_ranges value as unsigned in partial_die_info::read Simon Marchi via Gdb-patches
2021-01-28 15:41 ` Zoran Zaric via Gdb-patches
2021-01-28 15:51 ` Simon Marchi via Gdb-patches
2021-01-20 5:39 ` [PATCH 08/13] gdb/testsuite: add .debug_rnglists tests Simon Marchi via Gdb-patches
2021-01-28 16:24 ` Zoran Zaric via Gdb-patches
2021-01-20 5:39 ` [PATCH 09/13] gdb/testsuite: DWARF assembler: add context parameters to _location Simon Marchi via Gdb-patches
2021-01-28 16:30 ` Zoran Zaric via Gdb-patches
2021-01-20 5:39 ` [PATCH 10/13] gdb/testsuite: add .debug_loclists tests Simon Marchi via Gdb-patches
2021-01-28 16:52 ` Zoran Zaric via Gdb-patches
2021-01-28 17:47 ` Simon Marchi via Gdb-patches
2021-01-29 10:13 ` Zoran Zaric via Gdb-patches
2021-01-29 15:57 ` Simon Marchi via Gdb-patches
2021-01-29 16:58 ` Zoran Zaric via Gdb-patches
2021-01-29 17:37 ` Simon Marchi via Gdb-patches
2021-01-20 5:39 ` [PATCH 11/13] gdb/dwarf: split dwarf2_cu::ranges_base in two Simon Marchi via Gdb-patches
2021-01-20 5:39 ` Simon Marchi via Gdb-patches [this message]
2021-02-25 19:26 ` [PATCH 12/13] gdb/dwarf: make read_{loc, rng}list_index return sect_offset Tom Tromey
2021-01-20 5:39 ` [PATCH 13/13] gdb/testsuite: add test for .debug_{rng, loc}lists section without offset array Simon Marchi via Gdb-patches
2021-02-02 15:43 ` [PATCH 00/13] DWARF 5 rnglists & loclists fixes (PR 26813) Simon Marchi via Gdb-patches
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210120053925.142862-13-simon.marchi@polymtl.ca \
--to=gdb-patches@sourceware.org \
--cc=simon.marchi@efficios.com \
--cc=simon.marchi@polymtl.ca \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox