Fix regression in variant part handling
authorTom Tromey <tromey@adacore.com>
Wed, 30 Sep 2020 15:46:36 +0000 (09:46 -0600)
committerTom Tromey <tromey@adacore.com>
Wed, 30 Sep 2020 15:51:44 +0000 (09:51 -0600)
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.

gdb/ChangeLog
gdb/dwarf2/read.c

index 9c802c57ef4b5b4a7005c075831bc2a13e45cb63..c448589b6790f9077c2ba524863dda4afa452d75 100644 (file)
@@ -1,3 +1,7 @@
+2020-09-30  Tom Tromey  <tromey@adacore.com>
+
+       * dwarf2/read.c (handle_variant): Use constant_value.
+
 2020-09-29  Tom Tromey  <tom@tromey.com>
 
        * dwarf2/read.c (lookup_dwo_id, get_type_unit_group)
index bcac94ed36adc18255518fa50eb41081ef980217..c0a89ecbe1e37d0ed2b35cd831367dd93226e78a 100644 (file)
@@ -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;
This page took 0.041891 seconds and 4 git commands to generate.