* [FYI] Fix regression in variant part handling
@ 2020-09-30 15:50 Tom Tromey
0 siblings, 0 replies; only message in thread
From: Tom Tromey @ 2020-09-30 15:50 UTC (permalink / raw)
To: gdb-patches; +Cc: Tom Tromey
My series to change DWARF attribute handling to be type-safe
introduced a regression in gdb.ada/variant.exp. handle_variant was
using as_unsigned on an attribute with DW_FORM_sdata. This patch
changes it to use constant_value instead.
gdb/ChangeLog
2020-09-30 Tom Tromey <tromey@adacore.com>
* dwarf2/read.c (handle_variant): Use constant_value.
---
gdb/ChangeLog | 4 ++++
gdb/dwarf2/read.c | 4 ++--
2 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index bcac94ed36a..c0a89ecbe1e 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -16178,7 +16178,7 @@ handle_variant (struct die_info *die, struct type *type,
/* In a variant we want to get the discriminant and also add a
field for our sole member child. */
struct attribute *discr = dwarf2_attr (die, DW_AT_discr_value, cu);
- if (discr == nullptr)
+ if (discr == nullptr || !discr->form_is_constant ())
{
discr = dwarf2_attr (die, DW_AT_discr_list, cu);
if (discr == nullptr || discr->as_block ()->size == 0)
@@ -16187,7 +16187,7 @@ handle_variant (struct die_info *die, struct type *type,
variant.discr_list_data = discr->as_block ();
}
else
- variant.discriminant_value = discr->as_unsigned ();
+ variant.discriminant_value = discr->constant_value (0);
for (die_info *variant_child = die->child;
variant_child != NULL;
--
2.26.2
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2020-09-30 15:51 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-30 15:50 [FYI] Fix regression in variant part handling Tom Tromey
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).