From: Simon Marchi via Gdb-patches <gdb-patches@sourceware.org>
To: gdb-patches@sourceware.org
Cc: Simon Marchi <simon.marchi@efficios.com>
Subject: [PATCH 05/13] gdb/dwarf: few fixes for handling DW_FORM_{rng, loc}listx
Date: Wed, 20 Jan 2021 00:39:17 -0500 [thread overview]
Message-ID: <20210120053925.142862-6-simon.marchi@polymtl.ca> (raw)
In-Reply-To: <20210120053925.142862-1-simon.marchi@polymtl.ca>
From: Simon Marchi <simon.marchi@efficios.com>
We hit an assertion when loading the binary from PR 26813. When fixing
it, execution goes a up bit further but then hits another assert, and
another, and another. With these fours fixes, I am able to load the
binary and get to the prompt. An error is shown (index pointing outside
of the section), because the DW_FORM_rnglistx attribute is not read
correctly, but that one is taken care of by the next patch.
The four fixes are:
- attribute::form_requires_reprocessing needs to handle forms
DW_FORM_rnglistx and DW_FORM_loclistx, because set_unsigned_reprocess
is called for them in read_attribute_value.
- read_attribute_reprocess must call set_unsigned for them, not
set_address. The parameter of set_address is a CORE_ADDR, meaning
it's for program addresses. Post-reprocess, DW_FORM_rnglistx and
DW_FORM_loclistx are offsets into their respective sections
(.debug_rnglists and .debug_loclists). set_unsigned is the current
attribute value setter that fits the best. But perhaps we should have
a setter that takes a sect_offset?
- read_attribute_process must call as_unsigned_reprocess instead of
as_unsigned to get the pre-reprocess value, otherwise we hit the
assert inside as_unsigned that makes sure the attribute doesn't need
reprocessing.
- attribute::set_unsigned needs to clear the requires_reprocessing flag,
otherwise it stays set when reprocessing DW_FORM_rnglistx and
DW_FORM_loclistx attributes.
There's another assert that we hit once the next patch is applied, but
since it's in the same vein as the changes in this patch, I included it
in this patch:
- attribute::form_is_unsigned must handle form DW_FORM_loclistx,
otherwise we hit the assert when trying to call set_unsigned for an
attribute of this form. DW_FORM_rnglistx is already handled.
gdb/ChangeLog:
PR gdb/26813
* dwarf2/attribute.h (struct attribute) <set_unsigned>: Clear
requires_reprocessing flag.
* dwarf2/attribute.c (attribute::form_is_unsigned): Handle
DW_FORM_loclistx.
(attribute::form_requires_reprocessing): Handle DW_FORM_rnglistx
and DW_FORM_loclistx.
* dwarf2/read.c (read_attribute_reprocess): Use set_unsigned
instead of set_address for DW_FORM_loclistx and
DW_FORM_rnglistx.
Change-Id: I06c156fa3913ca98e4e39085f4ef171645b4bc1e
---
gdb/dwarf2/attribute.c | 5 ++++-
gdb/dwarf2/attribute.h | 1 +
gdb/dwarf2/read.c | 16 +++++++++++++---
3 files changed, 18 insertions(+), 4 deletions(-)
diff --git a/gdb/dwarf2/attribute.c b/gdb/dwarf2/attribute.c
index 479261030c5d..b4f188a096e1 100644
--- a/gdb/dwarf2/attribute.c
+++ b/gdb/dwarf2/attribute.c
@@ -179,6 +179,7 @@ attribute::form_is_unsigned () const
|| form == DW_FORM_flag_present
|| form == DW_FORM_udata
|| form == DW_FORM_rnglistx
+ || form == DW_FORM_loclistx
|| form == DW_FORM_ref1
|| form == DW_FORM_ref2
|| form == DW_FORM_ref4
@@ -197,7 +198,9 @@ attribute::form_requires_reprocessing () const
|| form == DW_FORM_strx4
|| form == DW_FORM_GNU_str_index
|| form == DW_FORM_addrx
- || form == DW_FORM_GNU_addr_index);
+ || form == DW_FORM_GNU_addr_index
+ || form == DW_FORM_rnglistx
+ || form == DW_FORM_loclistx);
}
/* See attribute.h. */
diff --git a/gdb/dwarf2/attribute.h b/gdb/dwarf2/attribute.h
index a3ff9b0eb9c6..56776d64ed34 100644
--- a/gdb/dwarf2/attribute.h
+++ b/gdb/dwarf2/attribute.h
@@ -223,6 +223,7 @@ struct attribute
{
gdb_assert (form_is_unsigned ());
u.unsnd = unsnd;
+ requires_reprocessing = 0;
}
/* Temporarily set this attribute to an unsigned integer. This is
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index 76044187bf76..4146694247ea 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -20287,10 +20287,20 @@ read_attribute_reprocess (const struct die_reader_specs *reader,
attr->as_unsigned_reprocess ()));
break;
case DW_FORM_loclistx:
- attr->set_address (read_loclist_index (cu, attr->as_unsigned ()));
- break;
+ {
+ CORE_ADDR loclists_sect_off
+ = read_loclist_index (cu, attr->as_unsigned_reprocess ());
+
+ attr->set_unsigned (loclists_sect_off);
+ }
+ break;
case DW_FORM_rnglistx:
- attr->set_address (read_rnglist_index (cu, attr->as_unsigned (), tag));
+ {
+ CORE_ADDR rnglists_sect_off
+ = read_rnglist_index (cu, attr->as_unsigned_reprocess (), tag);
+
+ attr->set_unsigned (rnglists_sect_off);
+ }
break;
case DW_FORM_strx:
case DW_FORM_strx1:
--
2.30.0
next prev parent reply other threads:[~2021-01-20 5:39 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 ` Simon Marchi via Gdb-patches [this message]
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 ` [PATCH 12/13] gdb/dwarf: make read_{loc, rng}list_index return sect_offset Simon Marchi via Gdb-patches
2021-02-25 19:26 ` 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-6-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