dwarf2read.c::read_subrange_type: Handle dynamic lower bounds
authorJoel Brobecker <brobecker@adacore.com>
Sun, 20 Apr 2014 03:41:56 +0000 (20:41 -0700)
committerJoel Brobecker <brobecker@adacore.com>
Mon, 28 Apr 2014 19:46:29 +0000 (15:46 -0400)
Currently, read_subrange_type handles dynamicity only in the case of
the upper bound, and assumes that the lower bound is always static.
That's rooted in the fact that dynamicity was added to support C99
variable-length arrays, where the lower bound is always zero, and
therefore never dynamic.  But the lower bound can, in fact, be dynamic
in other languages such as Ada.

Consider for instance the following declaration in Ada...

    type Array_Type is array (L .. U) of Natural;

... where L and U are parameters of the function where the declaration
above was made, and whose value are 5 and 10.  Currently, the debugger
is able to print the value of the upper bound correctly, but not the
lower bound:

    (gdb) ptype array_type
    type = array (1 .. 10) of natural

After this patch, the debugger now prints:

    (gdb) ptype array_type
    type = array (5 .. 10) of natural

gdb/ChangeLog:

        * dwarf2read.c (read_subrange_type): Handle dynamic
        DW_AT_lower_bound attributes.

gdb/ChangeLog
gdb/dwarf2read.c

index 6c811ea0adc2d45c1d732cfcb79b29f58b0fa860..56f3c17438639e3e79b8eb46bf3eb64f5815dab1 100644 (file)
@@ -1,3 +1,8 @@
+2014-04-28  Joel Brobecker  <brobecker@adacore.com>
+
+       * dwarf2read.c (read_subrange_type): Handle dynamic
+       DW_AT_lower_bound attributes.
+
 2014-04-28  Joel Brobecker  <brobecker@adacore.com>
 
        * ada-lang.c (ada_discrete_type_high_bound): Resolve the type's
index e72cc4bfe527ea85803a035f29601eec5a9971d5..bf1e3d0bb63ec38c2551e6b891922543921f1d14 100644 (file)
@@ -14572,13 +14572,9 @@ read_subrange_type (struct die_info *die, struct dwarf2_cu *cu)
       break;
     }
 
-  /* FIXME: For variable sized arrays either of these could be
-     a variable rather than a constant value.  We'll allow it,
-     but we don't know how to handle it.  */
   attr = dwarf2_attr (die, DW_AT_lower_bound, cu);
   if (attr)
-    low.data.const_val
-      = dwarf2_get_attr_constant_value (attr, low.data.const_val);
+    attr_to_dynamic_prop (attr, die, cu, &low);
   else if (!low_default_is_valid)
     complaint (&symfile_complaints, _("Missing DW_AT_lower_bound "
                                      "- DIE at 0x%x [in module %s]"),
This page took 0.396061 seconds and 4 git commands to generate.