diff options
author | Tom Tromey <tromey@adacore.com> | 2020-09-30 09:46:36 -0600 |
---|---|---|
committer | Tom Tromey <tromey@adacore.com> | 2020-09-30 09:51:44 -0600 |
commit | cae21f8ebf01e379150bcf602a9ffb1f7c95b59e (patch) | |
tree | 9ea234f7d032d42bf096f882907e48c63e31005d /gdb/dwarf2 | |
parent | 77718e5b7d3a7755fe8407a7fcb34fc0e684e7a6 (diff) | |
download | gdb-cae21f8ebf01e379150bcf602a9ffb1f7c95b59e.zip gdb-cae21f8ebf01e379150bcf602a9ffb1f7c95b59e.tar.gz gdb-cae21f8ebf01e379150bcf602a9ffb1f7c95b59e.tar.bz2 |
Fix regression in variant part handling
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.
2020-09-30 Tom Tromey <tromey@adacore.com>
* dwarf2/read.c (handle_variant): Use constant_value.
Diffstat (limited to 'gdb/dwarf2')
-rw-r--r-- | gdb/dwarf2/read.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index bcac94e..c0a89ec 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; |