fort_dyn_array: Support evaluation of dynamic elements inside arrays.
authorBernhard Heckel <bernhard.heckel@intel.com>
Tue, 26 Apr 2016 14:38:19 +0000 (16:38 +0200)
committerBernhard Heckel <bernhard.heckel@intel.com>
Tue, 26 Apr 2016 14:38:19 +0000 (16:38 +0200)
Resolve type of an array's element to be printed in case it is dynamic.
Otherwise we don't use the correct boundaries nor the right location.

Before:
  ptype fivearr(1)
  type = Type five
      Type one
          integer(kind=4) :: ivla(34196784:34196832,34197072:34197120,34197360:34197408)
      End Type one :: tone
  End Type five

After:
  ptype fivearr(1)
  type = Type five
      Type one
          integer(kind=4) :: ivla(2,4,6)
      End Type one :: tone
  End Type five

2016-04-26  Bernhard Heckel  <bernhard.heckel@intel.com>

gdb/Changelog:
* valarith.c (value_address): Resolve dynamic types.

gdb/testsuite/Changelog:
* gdb.fortran/vla-type.f90: Add test for static and dynamic arrays
of dynamic types.
* gdb.fortran/vla-type.exp: Add test for static and dynamic arrays
of dynamic types.

gdb/ChangeLog
gdb/testsuite/ChangeLog
gdb/testsuite/gdb.fortran/vla-type.exp
gdb/testsuite/gdb.fortran/vla-type.f90
gdb/valarith.c

index be192e798a7f7fb5015cc54d607b8f619c47b728..e512251d4948a59cc3c6814fa94755408e3b1c8f 100644 (file)
@@ -1,3 +1,7 @@
+2016-04-26  Bernhard Heckel  <bernhard.heckel@intel.com>
+
+       * valarith.c (value_address): Resolve dynamic types.
+
 2016-04-26  Bernhard Heckel  <bernhard.heckel@intel.com>
            Keven Boell  <kevel.boell@intel.com>
 
index bb5258283c7e3a701c6d4092a11b25c92fc758f7..7a8f9223c88d9dba175de8a9dddc673301957946 100644 (file)
@@ -1,3 +1,10 @@
+2016-04-26  Bernhard Heckel  <bernhard.heckel@intel.com>
+
+       * gdb.fortran/vla-type.f90: Add test for static and dynamic arrays
+       of dynamic types.
+       * gdb.fortran/vla-type.exp: Add test for static and dynamic arrays
+       of dynamic types.
+
 2016-04-26  Bernhard Heckel  <bernhard.heckel@intel.com>
 
        * gdb.fortran/vla-type.f90: New file.
index 24191fe082952bacfcb8e12a3d1bc17039952ea0..011e27ea1525512294b05a52f96c778650ec58aa 100755 (executable)
@@ -100,3 +100,55 @@ gdb_test "ptype fivev" \
                      "\\s+$int :: ivla\\\(10,10,10\\\)" \
                      "\\s+End Type one :: tone" \
                      "End Type five" ]
+
+# Check array of types containing a VLA
+gdb_breakpoint [gdb_get_line_number "fivearr-filled"]
+gdb_continue_to_breakpoint "fivearr-filled"
+gdb_test "print fivearr(1)%tone%ivla(1, 2, 3)" " = 1"
+gdb_test "print fivearr(1)%tone%ivla(2, 2, 10)" "no such vector element"
+gdb_test "print fivearr(1)%tone%ivla(2, 2, 3)" " = 223"
+gdb_test "print fivearr(2)%tone%ivla(12, 14, 16)" " = 2"
+gdb_test "print fivearr(2)%tone%ivla(6, 7, 8)" " = 678"
+gdb_test "ptype fivearr(1)" \
+         [multi_line "type = Type five" \
+                     "\\s+Type one" \
+                     "\\s+$int :: ivla\\\(2,4,6\\\)" \
+                     "\\s+End Type one :: tone" \
+                     "End Type five" ]
+gdb_test "ptype fivearr(2)" \
+         [multi_line "type = Type five" \
+                     "\\s+Type one" \
+                     "\\s+$int :: ivla\\\(12,14,16\\\)" \
+                     "\\s+End Type one :: tone" \
+                     "End Type five" ]
+
+# Check allocation status of dynamic array and it's dynamic members
+gdb_test "ptype fivedynarr" "type = <not allocated>"
+gdb_test "next" ""
+gdb_test "ptype fivedynarr(2)" \
+         [multi_line "type = Type five" \
+                     "\\s+Type one" \
+                     "\\s+$int :: ivla\\\(<not allocated>\\\)" \
+                     "\\s+End Type one :: tone" \
+                     "End Type five" ]
+
+# Check dynamic array of types containing a VLA
+gdb_breakpoint [gdb_get_line_number "fivedynarr-filled"]
+gdb_continue_to_breakpoint "fivedynarr-filled"
+gdb_test "print fivedynarr(1)%tone%ivla(1, 2, 3)" " = 1"
+gdb_test "print fivedynarr(1)%tone%ivla(2, 2, 10)" "no such vector element"
+gdb_test "print fivedynarr(1)%tone%ivla(2, 2, 3)" " = 223"
+gdb_test "print fivedynarr(2)%tone%ivla(12, 14, 16)" " = 2"
+gdb_test "print fivedynarr(2)%tone%ivla(6, 7, 8)" " = 678"
+gdb_test "ptype fivedynarr(1)" \
+         [multi_line "type = Type five" \
+                     "\\s+Type one" \
+                     "\\s+$int :: ivla\\\(2,4,6\\\)" \
+                     "\\s+End Type one :: tone" \
+                     "End Type five" ]
+gdb_test "ptype fivedynarr(2)" \
+         [multi_line "type = Type five" \
+                     "\\s+Type one" \
+                     "\\s+$int :: ivla\\\(12,14,16\\\)" \
+                     "\\s+End Type one :: tone" \
+                     "End Type five" ]
index a1066177e301977a15e3526b16924e9e51843eb8..547312424e166a8815678339cc59570f67af97af 100755 (executable)
@@ -38,6 +38,8 @@ program vla_struct
   type(three)              :: threev
   type(four)               :: fourv
   type(five)               :: fivev
+  type(five)               :: fivearr (2)
+  type(five), allocatable  :: fivedynarr (:)
   logical                  :: l
   integer                  :: i, j
 
@@ -83,6 +85,20 @@ program vla_struct
   fivev%tone%ivla(1, 2, 3) = 123
   fivev%tone%ivla(3, 2, 1) = 321
 
-  ! dummy statement for bp
-  l = allocated(fivev%tone%ivla)                  ! fivev-filled
+  allocate (fivearr(1)%tone%ivla (2, 4, 6))        ! fivev-filled
+  allocate (fivearr(2)%tone%ivla (12, 14, 16))
+  fivearr(1)%tone%ivla(:, :, :) = 1
+  fivearr(1)%tone%ivla(2, 2, 3) = 223
+  fivearr(2)%tone%ivla(:, :, :) = 2
+  fivearr(2)%tone%ivla(6, 7, 8) = 678
+
+  allocate (fivedynarr(2))                         ! fivearr-filled
+  allocate (fivedynarr(1)%tone%ivla (2, 4, 6))
+  allocate (fivedynarr(2)%tone%ivla (12, 14, 16))
+  fivedynarr(1)%tone%ivla(:, :, :) = 1
+  fivedynarr(1)%tone%ivla(2, 2, 3) = 223
+  fivedynarr(2)%tone%ivla(:, :, :) = 2
+  fivedynarr(2)%tone%ivla(6, 7, 8) = 678
+
+  l = allocated(fivedynarr)                        ! fivedynarr-filled
 end program vla_struct
index 7959f3b2215eff75058e025dd9f34594e40842aa..254d99838a9e03fd57041a50571507147fb882a0 100644 (file)
@@ -207,6 +207,14 @@ value_subscripted_rvalue (struct value *array, LONGEST index, int lowerbound)
         error (_("no such vector element"));
     }
 
+  if (is_dynamic_type (elt_type))
+    {
+      CORE_ADDR address;
+
+      address = value_address (array) + elt_offs;
+      elt_type = resolve_dynamic_type (elt_type, NULL, address);
+    }
+
   if (VALUE_LVAL (array) == lval_memory && value_lazy (array))
     v = allocate_value_lazy (elt_type);
   else
This page took 0.031506 seconds and 4 git commands to generate.