From: Tom Tromey <tom@tromey.com>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tom@tromey.com>
Subject: [PATCH 8.2+trunk 2/2] Set TYPE_LENGTH on a variant part
Date: Fri, 31 Aug 2018 14:53:00 -0000 [thread overview]
Message-ID: <20180831145302.14493-3-tom@tromey.com> (raw)
In-Reply-To: <20180831145302.14493-1-tom@tromey.com>
gdb represents a DW_TAG_variant_part as a union. While normally DWARF
would not set the size of a DW_TAG_variant_part, gdb's representation
requires the TYPE_LENGTH to be set.
This patch arranges to set the TYPE_LENGTH of a variant part if it has
not already been set.
This fixes some Rust regressions when testing against a version of
rustc that emits DW_TAG_variant_part.
gdb/ChangeLog
2018-08-31 Tom Tromey <tom@tromey.com>
* dwarf2read.c (dwarf2_add_field): Set the TYPE_LENGTH of the
variant part type.
---
gdb/ChangeLog | 5 +++++
gdb/dwarf2read.c | 12 ++++++++++++
2 files changed, 17 insertions(+)
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 0d55fd45f5..fc9e2b943f 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,8 @@
+2018-08-31 Tom Tromey <tom@tromey.com>
+
+ * dwarf2read.c (dwarf2_add_field): Set the TYPE_LENGTH of the
+ variant part type.
+
2018-08-30 Andrew Burgess <andrew.burgess@embecosm.com>
* riscv-tdep.c (riscv_insn::decode): Decode c.addi4spn, c.sd,
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index 8834d08a1c..d66dfeaf2d 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -15169,6 +15169,18 @@ dwarf2_add_field (struct field_info *fip, struct die_info *die,
fp->type = get_die_type (die, cu);
fp->artificial = 1;
fp->name = "<<variant>>";
+
+ /* Normally a DW_TAG_variant_part won't have a size, but our
+ representation requires one, so set it to the maximum of the
+ child sizes. */
+ if (TYPE_LENGTH (fp->type) == 0)
+ {
+ unsigned max = 0;
+ for (int i = 0; i < TYPE_NFIELDS (fp->type); ++i)
+ if (TYPE_LENGTH (TYPE_FIELD_TYPE (fp->type, i)) > max)
+ max = TYPE_LENGTH (TYPE_FIELD_TYPE (fp->type, i));
+ TYPE_LENGTH (fp->type) = max;
+ }
}
else
gdb_assert_not_reached ("missing case in dwarf2_add_field");
--
2.17.1
next prev parent reply other threads:[~2018-08-31 14:53 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-08-31 14:53 [PATCH 8.2+trunk 0/2] two small rust fixes Tom Tromey
2018-08-31 14:53 ` Tom Tromey [this message]
2018-08-31 14:53 ` [PATCH 8.2+trunk 1/2] Fix a small bug in gdb.rust/simple.rs Tom Tromey
2018-08-31 15:31 ` [PATCH 8.2+trunk 0/2] two small rust fixes Joel Brobecker
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=20180831145302.14493-3-tom@tromey.com \
--to=tom@tromey.com \
--cc=gdb-patches@sourceware.org \
/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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).