Jan Kratochvil cec9297
[PATCH 00/23] Fortran dynamic array support
Jan Kratochvil cec9297
https://sourceware.org/ml/gdb-patches/2014-06/msg00108.html
Jan Kratochvil cec9297
https://github.com/intel-gdb/vla/tree/vla-fortran
Jan Kratochvil cec9297
Jan Kratochvil cec9297
GIT snapshot:
Jan Kratochvil a972d47
commit 511bff520372ffc10fa2ff569c176bdf1e6e475d
Jan Kratochvil cec9297
Jan Kratochvil cec9297
Jan Kratochvil 2116e53
Index: gdb-7.10.50.20160106/gdb/c-valprint.c
Jan Kratochvil b132e8a
===================================================================
Jan Kratochvil 2116e53
--- gdb-7.10.50.20160106.orig/gdb/c-valprint.c	2016-01-08 19:15:35.065582359 +0100
Jan Kratochvil 2116e53
+++ gdb-7.10.50.20160106/gdb/c-valprint.c	2016-01-08 19:15:44.974637630 +0100
Jan Kratochvil 2116e53
@@ -642,7 +642,16 @@
Jan Kratochvil cec9297
 	{
Jan Kratochvil cec9297
 	  /* normal case */
Jan Kratochvil cec9297
 	  fprintf_filtered (stream, "(");
Jan Kratochvil cec9297
-	  type_print (value_type (val), "", stream, -1);
Jan Kratochvil cec9297
+	  if (is_dynamic_type (TYPE_TARGET_TYPE (type)))
Jan Kratochvil cec9297
+	    {
Jan Kratochvil cec9297
+	      struct value *v;
Jan Kratochvil cec9297
+
Jan Kratochvil cec9297
+	      v = value_ind (val);
Jan Kratochvil cec9297
+	      v = value_addr (v);
Jan Kratochvil cec9297
+	      type_print (value_type (v), "", stream, -1);
Jan Kratochvil cec9297
+	    }
Jan Kratochvil cec9297
+	  else
Jan Kratochvil cec9297
+	    type_print (value_type (val), "", stream, -1);
Jan Kratochvil cec9297
 	  fprintf_filtered (stream, ") ");
Jan Kratochvil cec9297
 	}
Jan Kratochvil cec9297
     }
Jan Kratochvil 2116e53
Index: gdb-7.10.50.20160106/gdb/dwarf2loc.h
Jan Kratochvil b132e8a
===================================================================
Jan Kratochvil 2116e53
--- gdb-7.10.50.20160106.orig/gdb/dwarf2loc.h	2016-01-08 19:15:35.066582365 +0100
Jan Kratochvil 2116e53
+++ gdb-7.10.50.20160106/gdb/dwarf2loc.h	2016-01-08 19:15:44.974637630 +0100
Jan Kratochvil 2116e53
@@ -138,6 +138,11 @@
Jan Kratochvil 32f92b2
 			      struct property_addr_info *addr_stack,
Jan Kratochvil cec9297
 			      CORE_ADDR *value);
Jan Kratochvil cec9297
 
Jan Kratochvil cec9297
+/* Checks if a dwarf location definition is valid.
Jan Kratochvil cec9297
+   Returns 1 if valid; 0 otherwise.  */
Jan Kratochvil cec9297
+
Jan Kratochvil cec9297
+extern int dwarf2_address_data_valid (const struct type *type);
Jan Kratochvil cec9297
+
Jan Kratochvil 2f7f533
 /* A helper for the compiler interface that compiles a single dynamic
Jan Kratochvil 2f7f533
    property to C code.
Jan Kratochvil 2f7f533
 
Jan Kratochvil 2116e53
Index: gdb-7.10.50.20160106/gdb/dwarf2read.c
Jan Kratochvil b132e8a
===================================================================
Jan Kratochvil 2116e53
--- gdb-7.10.50.20160106.orig/gdb/dwarf2read.c	2016-01-08 19:15:35.078582432 +0100
Jan Kratochvil 2116e53
+++ gdb-7.10.50.20160106/gdb/dwarf2read.c	2016-01-08 19:15:44.980637663 +0100
Jan Kratochvil 2116e53
@@ -1745,7 +1745,9 @@
Jan Kratochvil 0728371
 
Jan Kratochvil 23f398e
 static int attr_to_dynamic_prop (const struct attribute *attr,
Jan Kratochvil 23f398e
 				 struct die_info *die, struct dwarf2_cu *cu,
Jan Kratochvil 23f398e
-				 struct dynamic_prop *prop);
Jan Kratochvil 23f398e
+				 struct dynamic_prop *prop,
Jan Kratochvil 23f398e
+				 const gdb_byte *additional_data,
Jan Kratochvil 23f398e
+				 int additional_data_size);
Jan Kratochvil 23f398e
 
Jan Kratochvil 23f398e
 /* memory allocation interface */
Jan Kratochvil 23f398e
 
Jan Kratochvil 2116e53
@@ -11420,7 +11422,7 @@
Jan Kratochvil 23f398e
     {
Jan Kratochvil 23f398e
       newobj->static_link
Jan Kratochvil 23f398e
 	= XOBNEW (&objfile->objfile_obstack, struct dynamic_prop);
Jan Kratochvil 23f398e
-      attr_to_dynamic_prop (attr, die, cu, newobj->static_link);
Jan Kratochvil 23f398e
+      attr_to_dynamic_prop (attr, die, cu, newobj->static_link, NULL, 0);
Jan Kratochvil 23f398e
     }
Jan Kratochvil cec9297
 
Jan Kratochvil 23f398e
   cu->list_in_scope = &local_symbols;
Jan Kratochvil 2116e53
@@ -14471,29 +14473,92 @@
Jan Kratochvil cec9297
   struct gdbarch *gdbarch = get_objfile_arch (objfile);
Jan Kratochvil cec9297
   struct type *type, *range_type, *index_type, *char_type;
Jan Kratochvil cec9297
   struct attribute *attr;
Jan Kratochvil cec9297
-  unsigned int length;
Jan Kratochvil cec9297
+  unsigned int length = UINT_MAX;
Jan Kratochvil b132e8a
 
Jan Kratochvil cec9297
+  index_type = objfile_type (objfile)->builtin_int;
Jan Kratochvil cec9297
+  range_type = create_static_range_type (NULL, index_type, 1, length);
Jan Kratochvil b132e8a
+
Jan Kratochvil cec9297
+  /* If DW_AT_string_length is defined, the length is stored at some location
Jan Kratochvil cec9297
+   * in memory. */
Jan Kratochvil cec9297
   attr = dwarf2_attr (die, DW_AT_string_length, cu);
Jan Kratochvil cec9297
   if (attr)
Jan Kratochvil cec9297
     {
Jan Kratochvil cec9297
-      length = DW_UNSND (attr);
Jan Kratochvil cec9297
+      if (attr_form_is_block (attr))
Jan Kratochvil cec9297
+        {
Jan Kratochvil cec9297
+          struct attribute *byte_size, *bit_size;
Jan Kratochvil cec9297
+          struct dynamic_prop high;
Jan Kratochvil cec9297
+
Jan Kratochvil cec9297
+          byte_size = dwarf2_attr (die, DW_AT_byte_size, cu);
Jan Kratochvil cec9297
+          bit_size = dwarf2_attr (die, DW_AT_bit_size, cu);
Jan Kratochvil cec9297
+
Jan Kratochvil cec9297
+          /* DW_AT_byte_size should never occur together in combination with
Jan Kratochvil cec9297
+             DW_AT_string_length.  */
Jan Kratochvil cec9297
+          if ((byte_size == NULL && bit_size != NULL) ||
Jan Kratochvil cec9297
+                  (byte_size != NULL && bit_size == NULL))
Jan Kratochvil cec9297
+            complaint (&symfile_complaints, _("DW_AT_byte_size AND "
Jan Kratochvil cec9297
+                      "DW_AT_bit_size found together at the same time."));
Jan Kratochvil cec9297
+
Jan Kratochvil cec9297
+          /* If DW_AT_string_length AND DW_AT_byte_size exist together, it
Jan Kratochvil cec9297
+             describes the number of bytes that should be read from the length
Jan Kratochvil cec9297
+             memory location.  */
Jan Kratochvil cec9297
+          if (byte_size != NULL && bit_size == NULL)
Jan Kratochvil cec9297
+            {
Jan Kratochvil cec9297
+              /* Build new dwarf2_locexpr_baton structure with additions to the
Jan Kratochvil cec9297
+                 data attribute, to reflect DWARF specialities to get address
Jan Kratochvil cec9297
+                 sizes.  */
Jan Kratochvil cec9297
+              const gdb_byte append_ops[] = {
Jan Kratochvil cec9297
+                /* DW_OP_deref_size: size of an address on the target machine
Jan Kratochvil cec9297
+                   (bytes), where the size will be specified by the next
Jan Kratochvil cec9297
+                   operand.  */
Jan Kratochvil cec9297
+                DW_OP_deref_size,
Jan Kratochvil cec9297
+                /* Operand for DW_OP_deref_size.  */
Jan Kratochvil cec9297
+                DW_UNSND (byte_size) };
Jan Kratochvil cec9297
+
Jan Kratochvil cec9297
+              if (!attr_to_dynamic_prop (attr, die, cu, &high,
Jan Kratochvil cec9297
+                      append_ops, ARRAY_SIZE (append_ops)))
Jan Kratochvil cec9297
+                complaint (&symfile_complaints,
Jan Kratochvil cec9297
+                        _("Could not parse DW_AT_byte_size"));
Jan Kratochvil cec9297
+            }
Jan Kratochvil cec9297
+          else if (bit_size != NULL && byte_size == NULL)
Jan Kratochvil cec9297
+            complaint (&symfile_complaints, _("DW_AT_string_length AND "
Jan Kratochvil cec9297
+                      "DW_AT_bit_size found but not supported yet."));
Jan Kratochvil cec9297
+          /* If DW_AT_string_length WITHOUT DW_AT_byte_size exist, the default
Jan Kratochvil cec9297
+             is the address size of the target machine.  */
Jan Kratochvil cec9297
+          else
Jan Kratochvil cec9297
+            {
Jan Kratochvil a972d47
+              const gdb_byte append_ops[] = { DW_OP_deref };
Jan Kratochvil a972d47
+
Jan Kratochvil a972d47
+              if (!attr_to_dynamic_prop (attr, die, cu, &high, append_ops,
Jan Kratochvil a972d47
+                      ARRAY_SIZE (append_ops)))
Jan Kratochvil cec9297
+                complaint (&symfile_complaints,
Jan Kratochvil cec9297
+                        _("Could not parse DW_AT_string_length"));
Jan Kratochvil cec9297
+            }
Jan Kratochvil cec9297
+
Jan Kratochvil cec9297
+          TYPE_RANGE_DATA (range_type)->high = high;
Jan Kratochvil cec9297
+        }
Jan Kratochvil cec9297
+      else
Jan Kratochvil cec9297
+        {
Jan Kratochvil cec9297
+          TYPE_HIGH_BOUND (range_type) = DW_UNSND (attr);
Jan Kratochvil cec9297
+          TYPE_HIGH_BOUND_KIND (range_type) = PROP_CONST;
Jan Kratochvil cec9297
+        }
Jan Kratochvil cec9297
     }
Jan Kratochvil cec9297
   else
Jan Kratochvil cec9297
     {
Jan Kratochvil cec9297
-      /* Check for the DW_AT_byte_size attribute.  */
Jan Kratochvil cec9297
+      /* Check for the DW_AT_byte_size attribute, which represents the length
Jan Kratochvil cec9297
+         in this case.  */
Jan Kratochvil cec9297
       attr = dwarf2_attr (die, DW_AT_byte_size, cu);
Jan Kratochvil cec9297
       if (attr)
Jan Kratochvil cec9297
         {
Jan Kratochvil cec9297
-          length = DW_UNSND (attr);
Jan Kratochvil cec9297
+          TYPE_HIGH_BOUND (range_type) = DW_UNSND (attr);
Jan Kratochvil cec9297
+          TYPE_HIGH_BOUND_KIND (range_type) = PROP_CONST;
Jan Kratochvil cec9297
         }
Jan Kratochvil cec9297
       else
Jan Kratochvil cec9297
         {
Jan Kratochvil cec9297
-          length = 1;
Jan Kratochvil cec9297
+          TYPE_HIGH_BOUND (range_type) = 1;
Jan Kratochvil cec9297
+          TYPE_HIGH_BOUND_KIND (range_type) = PROP_CONST;
Jan Kratochvil cec9297
         }
Jan Kratochvil cec9297
     }
Jan Kratochvil cec9297
 
Jan Kratochvil cec9297
-  index_type = objfile_type (objfile)->builtin_int;
Jan Kratochvil cec9297
-  range_type = create_static_range_type (NULL, index_type, 1, length);
Jan Kratochvil cec9297
   char_type = language_string_char_type (cu->language_defn, gdbarch);
Jan Kratochvil cec9297
   type = create_string_type (NULL, char_type, range_type);
Jan Kratochvil cec9297
 
Jan Kratochvil 2116e53
@@ -14816,13 +14881,15 @@
Jan Kratochvil cec9297
   return set_die_type (die, type, cu);
Jan Kratochvil cec9297
 }
Jan Kratochvil cec9297
 
Jan Kratochvil cec9297
+
Jan Kratochvil cec9297
 /* Parse dwarf attribute if it's a block, reference or constant and put the
Jan Kratochvil cec9297
    resulting value of the attribute into struct bound_prop.
Jan Kratochvil cec9297
    Returns 1 if ATTR could be resolved into PROP, 0 otherwise.  */
Jan Kratochvil cec9297
 
Jan Kratochvil cec9297
 static int
Jan Kratochvil cec9297
 attr_to_dynamic_prop (const struct attribute *attr, struct die_info *die,
Jan Kratochvil cec9297
-		      struct dwarf2_cu *cu, struct dynamic_prop *prop)
Jan Kratochvil cec9297
+		      struct dwarf2_cu *cu, struct dynamic_prop *prop,
Jan Kratochvil cec9297
+		      const gdb_byte *additional_data, int additional_data_size)
Jan Kratochvil cec9297
 {
Jan Kratochvil cec9297
   struct dwarf2_property_baton *baton;
Jan Kratochvil cec9297
   struct obstack *obstack = &cu->objfile->objfile_obstack;
Jan Kratochvil 2116e53
@@ -14835,8 +14902,25 @@
Jan Kratochvil 23f398e
       baton = XOBNEW (obstack, struct dwarf2_property_baton);
Jan Kratochvil cec9297
       baton->referenced_type = NULL;
Jan Kratochvil cec9297
       baton->locexpr.per_cu = cu->per_cu;
Jan Kratochvil cec9297
-      baton->locexpr.size = DW_BLOCK (attr)->size;
Jan Kratochvil a972d47
-      baton->locexpr.data = DW_BLOCK (attr)->data;
Jan Kratochvil a972d47
+
Jan Kratochvil a972d47
+      if (additional_data != NULL && additional_data_size > 0)
Jan Kratochvil a972d47
+        {
Jan Kratochvil a972d47
+          gdb_byte *data;
Jan Kratochvil a972d47
+
Jan Kratochvil a972d47
+          data = obstack_alloc (&cu->objfile->objfile_obstack,
Jan Kratochvil a972d47
+                  DW_BLOCK (attr)->size + additional_data_size);
Jan Kratochvil a972d47
+          memcpy (data, DW_BLOCK (attr)->data, DW_BLOCK (attr)->size);
Jan Kratochvil a972d47
+          memcpy (data + DW_BLOCK (attr)->size,
Jan Kratochvil a972d47
+                  additional_data, additional_data_size);
Jan Kratochvil a972d47
+
Jan Kratochvil a972d47
+          baton->locexpr.data = data;
Jan Kratochvil a972d47
+          baton->locexpr.size = DW_BLOCK (attr)->size + additional_data_size;
Jan Kratochvil a972d47
+        }
Jan Kratochvil a972d47
+      else
Jan Kratochvil a972d47
+        {
Jan Kratochvil a972d47
+          baton->locexpr.data = DW_BLOCK (attr)->data;
Jan Kratochvil a972d47
+          baton->locexpr.size = DW_BLOCK (attr)->size;
Jan Kratochvil a972d47
+        }
Jan Kratochvil cec9297
       prop->data.baton = baton;
Jan Kratochvil cec9297
       prop->kind = PROP_LOCEXPR;
Jan Kratochvil cec9297
       gdb_assert (prop->data.baton != NULL);
Jan Kratochvil 2116e53
@@ -14872,8 +14956,28 @@
Jan Kratochvil 23f398e
 		baton = XOBNEW (obstack, struct dwarf2_property_baton);
Jan Kratochvil 32f92b2
 		baton->referenced_type = die_type (target_die, target_cu);
Jan Kratochvil 32f92b2
 		baton->locexpr.per_cu = cu->per_cu;
Jan Kratochvil 32f92b2
-		baton->locexpr.size = DW_BLOCK (target_attr)->size;
Jan Kratochvil 32f92b2
-		baton->locexpr.data = DW_BLOCK (target_attr)->data;
Jan Kratochvil 32f92b2
+
Jan Kratochvil 32f92b2
+		if (additional_data != NULL && additional_data_size > 0)
Jan Kratochvil 32f92b2
+		  {
Jan Kratochvil 32f92b2
+		    gdb_byte *data;
Jan Kratochvil 32f92b2
+
Jan Kratochvil 32f92b2
+		    data = obstack_alloc (&cu->objfile->objfile_obstack,
Jan Kratochvil 32f92b2
+			    DW_BLOCK (target_attr)->size + additional_data_size);
Jan Kratochvil 32f92b2
+		    memcpy (data, DW_BLOCK (target_attr)->data,
Jan Kratochvil 32f92b2
+			    DW_BLOCK (target_attr)->size);
Jan Kratochvil 32f92b2
+		    memcpy (data + DW_BLOCK (target_attr)->size,
Jan Kratochvil 32f92b2
+			    additional_data, additional_data_size);
Jan Kratochvil 32f92b2
+
Jan Kratochvil 32f92b2
+		    baton->locexpr.data = data;
Jan Kratochvil 32f92b2
+		    baton->locexpr.size = (DW_BLOCK (target_attr)->size
Jan Kratochvil 32f92b2
+					   + additional_data_size);
Jan Kratochvil 32f92b2
+		  }
Jan Kratochvil 32f92b2
+		else
Jan Kratochvil 32f92b2
+		  {
Jan Kratochvil 32f92b2
+		    baton->locexpr.data = DW_BLOCK (target_attr)->data;
Jan Kratochvil 32f92b2
+		    baton->locexpr.size = DW_BLOCK (target_attr)->size;
Jan Kratochvil 32f92b2
+		  }
Jan Kratochvil 32f92b2
+
Jan Kratochvil 32f92b2
 		prop->data.baton = baton;
Jan Kratochvil 32f92b2
 		prop->kind = PROP_LOCEXPR;
Jan Kratochvil 32f92b2
 		gdb_assert (prop->data.baton != NULL);
Jan Kratochvil 2116e53
@@ -14927,7 +15031,7 @@
Jan Kratochvil cec9297
   struct type *base_type, *orig_base_type;
Jan Kratochvil cec9297
   struct type *range_type;
Jan Kratochvil cec9297
   struct attribute *attr;
Jan Kratochvil cec9297
-  struct dynamic_prop low, high;
Jan Kratochvil cec9297
+  struct dynamic_prop low, high, stride;
Jan Kratochvil cec9297
   int low_default_is_valid;
Jan Kratochvil cec9297
   int high_bound_is_count = 0;
Jan Kratochvil cec9297
   const char *name;
Jan Kratochvil 2116e53
@@ -14947,7 +15051,9 @@
Jan Kratochvil cec9297
 
Jan Kratochvil cec9297
   low.kind = PROP_CONST;
Jan Kratochvil cec9297
   high.kind = PROP_CONST;
Jan Kratochvil cec9297
+  stride.kind = PROP_CONST;
Jan Kratochvil cec9297
   high.data.const_val = 0;
Jan Kratochvil cec9297
+  stride.data.const_val = 0;
Jan Kratochvil cec9297
 
Jan Kratochvil cec9297
   /* Set LOW_DEFAULT_IS_VALID if current language and DWARF version allow
Jan Kratochvil cec9297
      omitting DW_AT_lower_bound.  */
Jan Kratochvil 2116e53
@@ -14980,19 +15086,26 @@
Jan Kratochvil cec9297
       break;
Jan Kratochvil cec9297
     }
Jan Kratochvil cec9297
 
Jan Kratochvil cec9297
+  attr = dwarf2_attr (die, DW_AT_byte_stride, cu);
Jan Kratochvil cec9297
+  if (attr)
Jan Kratochvil cec9297
+    if (!attr_to_dynamic_prop (attr, die, cu, &stride, NULL, 0))
Jan Kratochvil cec9297
+        complaint (&symfile_complaints, _("Missing DW_AT_byte_stride "
Jan Kratochvil cec9297
+                  "- DIE at 0x%x [in module %s]"),
Jan Kratochvil cec9297
+             die->offset.sect_off, objfile_name (cu->objfile));
Jan Kratochvil cec9297
+
Jan Kratochvil cec9297
   attr = dwarf2_attr (die, DW_AT_lower_bound, cu);
Jan Kratochvil cec9297
   if (attr)
Jan Kratochvil cec9297
-    attr_to_dynamic_prop (attr, die, cu, &low);
Jan Kratochvil cec9297
+    attr_to_dynamic_prop (attr, die, cu, &low, NULL, 0);
Jan Kratochvil cec9297
   else if (!low_default_is_valid)
Jan Kratochvil cec9297
     complaint (&symfile_complaints, _("Missing DW_AT_lower_bound "
Jan Kratochvil cec9297
 				      "- DIE at 0x%x [in module %s]"),
Jan Kratochvil cec9297
 	       die->offset.sect_off, objfile_name (cu->objfile));
Jan Kratochvil cec9297
 
Jan Kratochvil cec9297
   attr = dwarf2_attr (die, DW_AT_upper_bound, cu);
Jan Kratochvil cec9297
-  if (!attr_to_dynamic_prop (attr, die, cu, &high))
Jan Kratochvil cec9297
+  if (!attr_to_dynamic_prop (attr, die, cu, &high, NULL, 0))
Jan Kratochvil cec9297
     {
Jan Kratochvil cec9297
       attr = dwarf2_attr (die, DW_AT_count, cu);
Jan Kratochvil cec9297
-      if (attr_to_dynamic_prop (attr, die, cu, &high))
Jan Kratochvil cec9297
+      if (attr_to_dynamic_prop (attr, die, cu, &high, NULL, 0))
Jan Kratochvil cec9297
 	{
Jan Kratochvil cec9297
 	  /* If bounds are constant do the final calculation here.  */
Jan Kratochvil cec9297
 	  if (low.kind == PROP_CONST && high.kind == PROP_CONST)
Jan Kratochvil 2116e53
@@ -15056,7 +15169,7 @@
Jan Kratochvil cec9297
       && !TYPE_UNSIGNED (base_type) && (high.data.const_val & negative_mask))
Jan Kratochvil cec9297
     high.data.const_val |= negative_mask;
Jan Kratochvil cec9297
 
Jan Kratochvil cec9297
-  range_type = create_range_type (NULL, orig_base_type, &low, &high);
Jan Kratochvil cec9297
+  range_type = create_range_type (NULL, orig_base_type, &low, &high, &stride);
Jan Kratochvil cec9297
 
Jan Kratochvil cec9297
   if (high_bound_is_count)
Jan Kratochvil cec9297
     TYPE_RANGE_DATA (range_type)->flag_upper_bound_is_count = 1;
Jan Kratochvil 2116e53
@@ -22360,7 +22473,7 @@
Jan Kratochvil 23f398e
   attr = dwarf2_attr (die, DW_AT_allocated, cu);
Jan Kratochvil 23f398e
   if (attr_form_is_block (attr))
Jan Kratochvil 23f398e
     {
Jan Kratochvil 23f398e
-      if (attr_to_dynamic_prop (attr, die, cu, &prop))
Jan Kratochvil cec9297
+      if (attr_to_dynamic_prop (attr, die, cu, &prop, NULL, 0))
Jan Kratochvil 23f398e
         add_dyn_prop (DYN_PROP_ALLOCATED, prop, type, objfile);
Jan Kratochvil 23f398e
     }
Jan Kratochvil 23f398e
   else if (attr != NULL)
Jan Kratochvil 2116e53
@@ -22375,7 +22488,7 @@
Jan Kratochvil 23f398e
   attr = dwarf2_attr (die, DW_AT_associated, cu);
Jan Kratochvil 23f398e
   if (attr_form_is_block (attr))
Jan Kratochvil 23f398e
     {
Jan Kratochvil 23f398e
-      if (attr_to_dynamic_prop (attr, die, cu, &prop))
Jan Kratochvil cec9297
+      if (attr_to_dynamic_prop (attr, die, cu, &prop, NULL, 0))
Jan Kratochvil 23f398e
         add_dyn_prop (DYN_PROP_ASSOCIATED, prop, type, objfile);
Jan Kratochvil 23f398e
     }
Jan Kratochvil 23f398e
   else if (attr != NULL)
Jan Kratochvil 2116e53
@@ -22388,7 +22501,7 @@
Jan Kratochvil 23f398e
 
Jan Kratochvil 32f92b2
   /* Read DW_AT_data_location and set in type.  */
Jan Kratochvil 32f92b2
   attr = dwarf2_attr (die, DW_AT_data_location, cu);
Jan Kratochvil 32f92b2
-  if (attr_to_dynamic_prop (attr, die, cu, &prop))
Jan Kratochvil cec9297
+  if (attr_to_dynamic_prop (attr, die, cu, &prop, NULL, 0))
Jan Kratochvil 32f92b2
     add_dyn_prop (DYN_PROP_DATA_LOCATION, prop, type, objfile);
Jan Kratochvil 32f92b2
 
Jan Kratochvil 32f92b2
   if (dwarf2_per_objfile->die_type_hash == NULL)
Jan Kratochvil 2116e53
Index: gdb-7.10.50.20160106/gdb/f-typeprint.c
Jan Kratochvil b132e8a
===================================================================
Jan Kratochvil 2116e53
--- gdb-7.10.50.20160106.orig/gdb/f-typeprint.c	2016-01-08 19:15:35.080582443 +0100
Jan Kratochvil 2116e53
+++ gdb-7.10.50.20160106/gdb/f-typeprint.c	2016-01-08 19:15:44.980637663 +0100
Jan Kratochvil 23f398e
@@ -31,6 +31,7 @@
Jan Kratochvil cec9297
 #include "target.h"
Jan Kratochvil cec9297
 #include "f-lang.h"
Jan Kratochvil 23f398e
 #include "typeprint.h"
Jan Kratochvil cec9297
+#include "valprint.h"
Jan Kratochvil cec9297
 
Jan Kratochvil 2f7f533
 #if 0				/* Currently unused.  */
Jan Kratochvil 2f7f533
 static void f_type_print_args (struct type *, struct ui_file *);
Jan Kratochvil 2116e53
@@ -64,6 +65,17 @@
Jan Kratochvil 23f398e
     {
Jan Kratochvil 23f398e
       val_print_not_allocated (stream);
Jan Kratochvil 23f398e
       return;
Jan Kratochvil 23f398e
+    }
Jan Kratochvil 23f398e
+
Jan Kratochvil cec9297
+  if (TYPE_NOT_ASSOCIATED (type))
Jan Kratochvil cec9297
+    {
Jan Kratochvil cec9297
+      val_print_not_associated (stream);
Jan Kratochvil cec9297
+      return;
Jan Kratochvil cec9297
+    }
Jan Kratochvil cec9297
+  if (TYPE_NOT_ALLOCATED (type))
Jan Kratochvil cec9297
+    {
Jan Kratochvil cec9297
+      val_print_not_allocated (stream);
Jan Kratochvil cec9297
+      return;
Jan Kratochvil 23f398e
     }
Jan Kratochvil 23f398e
 
Jan Kratochvil cec9297
   f_type_print_base (type, stream, show, level);
Jan Kratochvil 2116e53
Index: gdb-7.10.50.20160106/gdb/f-valprint.c
Jan Kratochvil b132e8a
===================================================================
Jan Kratochvil 2116e53
--- gdb-7.10.50.20160106.orig/gdb/f-valprint.c	2016-01-08 19:15:35.081582448 +0100
Jan Kratochvil 2116e53
+++ gdb-7.10.50.20160106/gdb/f-valprint.c	2016-01-08 19:15:44.981637669 +0100
Jan Kratochvil 2f7f533
@@ -36,8 +36,6 @@
Jan Kratochvil cec9297
 
Jan Kratochvil cec9297
 extern void _initialize_f_valprint (void);
Jan Kratochvil cec9297
 static void info_common_command (char *, int);
Jan Kratochvil cec9297
-static void f77_create_arrayprint_offset_tbl (struct type *,
Jan Kratochvil cec9297
-					      struct ui_file *);
Jan Kratochvil cec9297
 static void f77_get_dynamic_length_of_aggregate (struct type *);
Jan Kratochvil cec9297
 
Jan Kratochvil cec9297
 int f77_array_offset_tbl[MAX_FORTRAN_DIMS + 1][2];
Jan Kratochvil 2116e53
@@ -45,15 +43,6 @@
Jan Kratochvil cec9297
 /* Array which holds offsets to be applied to get a row's elements
Jan Kratochvil cec9297
    for a given array.  Array also holds the size of each subarray.  */
Jan Kratochvil cec9297
 
Jan Kratochvil cec9297
-/* The following macro gives us the size of the nth dimension, Where 
Jan Kratochvil cec9297
-   n is 1 based.  */
Jan Kratochvil cec9297
-
Jan Kratochvil cec9297
-#define F77_DIM_SIZE(n) (f77_array_offset_tbl[n][1])
Jan Kratochvil cec9297
-
Jan Kratochvil cec9297
-/* The following gives us the offset for row n where n is 1-based.  */
Jan Kratochvil cec9297
-
Jan Kratochvil cec9297
-#define F77_DIM_OFFSET(n) (f77_array_offset_tbl[n][0])
Jan Kratochvil cec9297
-
Jan Kratochvil cec9297
 int
Jan Kratochvil cec9297
 f77_get_lowerbound (struct type *type)
Jan Kratochvil cec9297
 {
Jan Kratochvil 2116e53
@@ -111,47 +100,6 @@
Jan Kratochvil cec9297
     * TYPE_LENGTH (check_typedef (TYPE_TARGET_TYPE (type)));
Jan Kratochvil cec9297
 }
Jan Kratochvil cec9297
 
Jan Kratochvil cec9297
-/* Function that sets up the array offset,size table for the array 
Jan Kratochvil cec9297
-   type "type".  */
Jan Kratochvil cec9297
-
Jan Kratochvil cec9297
-static void
Jan Kratochvil cec9297
-f77_create_arrayprint_offset_tbl (struct type *type, struct ui_file *stream)
Jan Kratochvil cec9297
-{
Jan Kratochvil cec9297
-  struct type *tmp_type;
Jan Kratochvil cec9297
-  int eltlen;
Jan Kratochvil cec9297
-  int ndimen = 1;
Jan Kratochvil cec9297
-  int upper, lower;
Jan Kratochvil cec9297
-
Jan Kratochvil cec9297
-  tmp_type = type;
Jan Kratochvil cec9297
-
Jan Kratochvil cec9297
-  while (TYPE_CODE (tmp_type) == TYPE_CODE_ARRAY)
Jan Kratochvil cec9297
-    {
Jan Kratochvil cec9297
-      upper = f77_get_upperbound (tmp_type);
Jan Kratochvil cec9297
-      lower = f77_get_lowerbound (tmp_type);
Jan Kratochvil cec9297
-
Jan Kratochvil cec9297
-      F77_DIM_SIZE (ndimen) = upper - lower + 1;
Jan Kratochvil cec9297
-
Jan Kratochvil cec9297
-      tmp_type = TYPE_TARGET_TYPE (tmp_type);
Jan Kratochvil cec9297
-      ndimen++;
Jan Kratochvil cec9297
-    }
Jan Kratochvil cec9297
-
Jan Kratochvil cec9297
-  /* Now we multiply eltlen by all the offsets, so that later we 
Jan Kratochvil cec9297
-     can print out array elements correctly.  Up till now we 
Jan Kratochvil cec9297
-     know an offset to apply to get the item but we also 
Jan Kratochvil cec9297
-     have to know how much to add to get to the next item.  */
Jan Kratochvil cec9297
-
Jan Kratochvil cec9297
-  ndimen--;
Jan Kratochvil cec9297
-  eltlen = TYPE_LENGTH (tmp_type);
Jan Kratochvil cec9297
-  F77_DIM_OFFSET (ndimen) = eltlen;
Jan Kratochvil cec9297
-  while (--ndimen > 0)
Jan Kratochvil cec9297
-    {
Jan Kratochvil cec9297
-      eltlen *= F77_DIM_SIZE (ndimen + 1);
Jan Kratochvil cec9297
-      F77_DIM_OFFSET (ndimen) = eltlen;
Jan Kratochvil cec9297
-    }
Jan Kratochvil cec9297
-}
Jan Kratochvil cec9297
-
Jan Kratochvil cec9297
-
Jan Kratochvil cec9297
-
Jan Kratochvil cec9297
 /* Actual function which prints out F77 arrays, Valaddr == address in 
Jan Kratochvil cec9297
    the superior.  Address == the address in the inferior.  */
Jan Kratochvil cec9297
 
Jan Kratochvil 2116e53
@@ -164,41 +112,62 @@
Jan Kratochvil cec9297
 		   const struct value_print_options *options,
Jan Kratochvil cec9297
 		   int *elts)
Jan Kratochvil cec9297
 {
Jan Kratochvil cec9297
+  struct type *range_type = TYPE_INDEX_TYPE (check_typedef (type));
Jan Kratochvil cec9297
+  CORE_ADDR addr = address + embedded_offset;
Jan Kratochvil cec9297
+  LONGEST lowerbound, upperbound;
Jan Kratochvil cec9297
   int i;
Jan Kratochvil cec9297
 
Jan Kratochvil cec9297
+  get_discrete_bounds (range_type, &lowerbound, &upperbound);
Jan Kratochvil cec9297
+
Jan Kratochvil cec9297
   if (nss != ndimensions)
Jan Kratochvil cec9297
     {
Jan Kratochvil cec9297
-      for (i = 0;
Jan Kratochvil cec9297
-	   (i < F77_DIM_SIZE (nss) && (*elts) < options->print_max);
Jan Kratochvil cec9297
+      size_t dim_size;
Jan Kratochvil cec9297
+      size_t offs = 0;
Jan Kratochvil cec9297
+      LONGEST byte_stride = abs (TYPE_BYTE_STRIDE (range_type));
Jan Kratochvil cec9297
+
Jan Kratochvil cec9297
+      if (byte_stride)
Jan Kratochvil cec9297
+        dim_size = byte_stride;
Jan Kratochvil cec9297
+      else
Jan Kratochvil cec9297
+        dim_size = TYPE_LENGTH (TYPE_TARGET_TYPE (type));
Jan Kratochvil cec9297
+
Jan Kratochvil cec9297
+      for (i = lowerbound;
Jan Kratochvil cec9297
+	   (i < upperbound + 1 && (*elts) < options->print_max);
Jan Kratochvil cec9297
 	   i++)
Jan Kratochvil cec9297
 	{
Jan Kratochvil cec9297
+	  struct value *subarray = value_from_contents_and_address
Jan Kratochvil cec9297
+	    (TYPE_TARGET_TYPE (type), value_contents_for_printing_const (val)
Jan Kratochvil cec9297
+	     + offs, addr + offs);
Jan Kratochvil cec9297
+
Jan Kratochvil cec9297
 	  fprintf_filtered (stream, "( ");
Jan Kratochvil cec9297
-	  f77_print_array_1 (nss + 1, ndimensions, TYPE_TARGET_TYPE (type),
Jan Kratochvil cec9297
-			     valaddr,
Jan Kratochvil cec9297
-			     embedded_offset + i * F77_DIM_OFFSET (nss),
Jan Kratochvil cec9297
-			     address,
Jan Kratochvil cec9297
-			     stream, recurse, val, options, elts);
Jan Kratochvil cec9297
+	  f77_print_array_1 (nss + 1, ndimensions, value_type (subarray),
Jan Kratochvil cec9297
+			     value_contents_for_printing (subarray),
Jan Kratochvil cec9297
+			     value_embedded_offset (subarray),
Jan Kratochvil cec9297
+			     value_address (subarray),
Jan Kratochvil cec9297
+			     stream, recurse, subarray, options, elts);
Jan Kratochvil cec9297
+	  offs += dim_size;
Jan Kratochvil cec9297
 	  fprintf_filtered (stream, ") ");
Jan Kratochvil cec9297
 	}
Jan Kratochvil cec9297
-      if (*elts >= options->print_max && i < F77_DIM_SIZE (nss)) 
Jan Kratochvil cec9297
+      if (*elts >= options->print_max && i < upperbound)
Jan Kratochvil cec9297
 	fprintf_filtered (stream, "...");
Jan Kratochvil cec9297
     }
Jan Kratochvil cec9297
   else
Jan Kratochvil cec9297
     {
Jan Kratochvil cec9297
-      for (i = 0; i < F77_DIM_SIZE (nss) && (*elts) < options->print_max;
Jan Kratochvil cec9297
+      for (i = lowerbound; i < upperbound + 1 && (*elts) < options->print_max;
Jan Kratochvil cec9297
 	   i++, (*elts)++)
Jan Kratochvil cec9297
 	{
Jan Kratochvil cec9297
-	  val_print (TYPE_TARGET_TYPE (type),
Jan Kratochvil cec9297
-		     valaddr,
Jan Kratochvil cec9297
-		     embedded_offset + i * F77_DIM_OFFSET (ndimensions),
Jan Kratochvil cec9297
-		     address, stream, recurse,
Jan Kratochvil cec9297
-		     val, options, current_language);
Jan Kratochvil cec9297
+	  struct value *elt = value_subscript ((struct value *)val, i);
Jan Kratochvil cec9297
+
Jan Kratochvil cec9297
+	  val_print (value_type (elt),
Jan Kratochvil cec9297
+		     value_contents_for_printing (elt),
Jan Kratochvil cec9297
+		     value_embedded_offset (elt),
Jan Kratochvil cec9297
+		     value_address (elt), stream, recurse,
Jan Kratochvil cec9297
+		     elt, options, current_language);
Jan Kratochvil cec9297
 
Jan Kratochvil cec9297
-	  if (i != (F77_DIM_SIZE (nss) - 1))
Jan Kratochvil cec9297
+	  if (i != upperbound)
Jan Kratochvil cec9297
 	    fprintf_filtered (stream, ", ");
Jan Kratochvil cec9297
 
Jan Kratochvil cec9297
 	  if ((*elts == options->print_max - 1)
Jan Kratochvil cec9297
-	      && (i != (F77_DIM_SIZE (nss) - 1)))
Jan Kratochvil cec9297
+	      && (i != upperbound))
Jan Kratochvil cec9297
 	    fprintf_filtered (stream, "...");
Jan Kratochvil cec9297
 	}
Jan Kratochvil cec9297
     }
Jan Kratochvil 2116e53
@@ -225,12 +194,6 @@
Jan Kratochvil cec9297
 Type node corrupt! F77 arrays cannot have %d subscripts (%d Max)"),
Jan Kratochvil cec9297
 	   ndimensions, MAX_FORTRAN_DIMS);
Jan Kratochvil cec9297
 
Jan Kratochvil cec9297
-  /* Since F77 arrays are stored column-major, we set up an 
Jan Kratochvil cec9297
-     offset table to get at the various row's elements.  The 
Jan Kratochvil cec9297
-     offset table contains entries for both offset and subarray size.  */
Jan Kratochvil cec9297
-
Jan Kratochvil cec9297
-  f77_create_arrayprint_offset_tbl (type, stream);
Jan Kratochvil cec9297
-
Jan Kratochvil cec9297
   f77_print_array_1 (1, ndimensions, type, valaddr, embedded_offset,
Jan Kratochvil cec9297
 		     address, stream, recurse, val, options, &elts);
Jan Kratochvil cec9297
 }
Jan Kratochvil 2116e53
@@ -375,12 +338,15 @@
Jan Kratochvil cec9297
       fprintf_filtered (stream, "( ");
Jan Kratochvil cec9297
       for (index = 0; index < TYPE_NFIELDS (type); index++)
Jan Kratochvil cec9297
         {
Jan Kratochvil cec9297
-          int offset = TYPE_FIELD_BITPOS (type, index) / 8;
Jan Kratochvil cec9297
+	  struct value *field = value_field
Jan Kratochvil cec9297
+	    ((struct value *)original_value, index);
Jan Kratochvil cec9297
+
Jan Kratochvil cec9297
+          val_print (value_type (field),
Jan Kratochvil cec9297
+		     value_contents_for_printing (field),
Jan Kratochvil cec9297
+		     value_embedded_offset (field),
Jan Kratochvil cec9297
+		     value_address (field), stream, recurse + 1,
Jan Kratochvil cec9297
+		     field, options, current_language);
Jan Kratochvil cec9297
 
Jan Kratochvil cec9297
-          val_print (TYPE_FIELD_TYPE (type, index), valaddr,
Jan Kratochvil cec9297
-		     embedded_offset + offset,
Jan Kratochvil cec9297
-		     address, stream, recurse + 1,
Jan Kratochvil cec9297
-		     original_value, options, current_language);
Jan Kratochvil cec9297
           if (index != TYPE_NFIELDS (type) - 1)
Jan Kratochvil cec9297
             fputs_filtered (", ", stream);
Jan Kratochvil cec9297
         }
Jan Kratochvil 2116e53
Index: gdb-7.10.50.20160106/gdb/gdbtypes.c
Jan Kratochvil b132e8a
===================================================================
Jan Kratochvil 2116e53
--- gdb-7.10.50.20160106.orig/gdb/gdbtypes.c	2016-01-08 19:15:35.083582459 +0100
Jan Kratochvil 2116e53
+++ gdb-7.10.50.20160106/gdb/gdbtypes.c	2016-01-08 19:15:44.982637674 +0100
Jan Kratochvil 2116e53
@@ -836,7 +836,8 @@
Jan Kratochvil cec9297
 struct type *
Jan Kratochvil cec9297
 create_range_type (struct type *result_type, struct type *index_type,
Jan Kratochvil cec9297
 		   const struct dynamic_prop *low_bound,
Jan Kratochvil cec9297
-		   const struct dynamic_prop *high_bound)
Jan Kratochvil cec9297
+		   const struct dynamic_prop *high_bound,
Jan Kratochvil cec9297
+		   const struct dynamic_prop *stride)
Jan Kratochvil cec9297
 {
Jan Kratochvil cec9297
   if (result_type == NULL)
Jan Kratochvil cec9297
     result_type = alloc_type_copy (index_type);
Jan Kratochvil 2116e53
@@ -851,6 +852,7 @@
Jan Kratochvil cec9297
     TYPE_ZALLOC (result_type, sizeof (struct range_bounds));
Jan Kratochvil cec9297
   TYPE_RANGE_DATA (result_type)->low = *low_bound;
Jan Kratochvil cec9297
   TYPE_RANGE_DATA (result_type)->high = *high_bound;
Jan Kratochvil cec9297
+  TYPE_RANGE_DATA (result_type)->stride = *stride;
Jan Kratochvil cec9297
 
Jan Kratochvil cec9297
   if (low_bound->kind == PROP_CONST && low_bound->data.const_val >= 0)
Jan Kratochvil cec9297
     TYPE_UNSIGNED (result_type) = 1;
Jan Kratochvil 2116e53
@@ -879,7 +881,7 @@
Jan Kratochvil cec9297
 create_static_range_type (struct type *result_type, struct type *index_type,
Jan Kratochvil cec9297
 			  LONGEST low_bound, LONGEST high_bound)
Jan Kratochvil cec9297
 {
Jan Kratochvil cec9297
-  struct dynamic_prop low, high;
Jan Kratochvil cec9297
+  struct dynamic_prop low, high, stride;
Jan Kratochvil cec9297
 
Jan Kratochvil cec9297
   low.kind = PROP_CONST;
Jan Kratochvil cec9297
   low.data.const_val = low_bound;
Jan Kratochvil 2116e53
@@ -887,7 +889,11 @@
Jan Kratochvil cec9297
   high.kind = PROP_CONST;
Jan Kratochvil cec9297
   high.data.const_val = high_bound;
Jan Kratochvil cec9297
 
Jan Kratochvil cec9297
-  result_type = create_range_type (result_type, index_type, &low, &high);
Jan Kratochvil cec9297
+  stride.kind = PROP_CONST;
Jan Kratochvil cec9297
+  stride.data.const_val = 0;
Jan Kratochvil cec9297
+
Jan Kratochvil cec9297
+  result_type = create_range_type (result_type, index_type,
Jan Kratochvil cec9297
+                                   &low, &high, &stride);
Jan Kratochvil cec9297
 
Jan Kratochvil cec9297
   return result_type;
Jan Kratochvil cec9297
 }
Jan Kratochvil 2116e53
@@ -1084,16 +1090,21 @@
Jan Kratochvil 2116e53
       && (!type_not_associated (result_type)
Jan Kratochvil 2116e53
 	  && !type_not_allocated (result_type)))
Jan Kratochvil cec9297
     {
Jan Kratochvil cec9297
-      LONGEST low_bound, high_bound;
Jan Kratochvil cec9297
+      LONGEST low_bound, high_bound, byte_stride;
Jan Kratochvil cec9297
 
Jan Kratochvil cec9297
       if (get_discrete_bounds (range_type, &low_bound, &high_bound) < 0)
Jan Kratochvil cec9297
 	low_bound = high_bound = 0;
Jan Kratochvil 23f398e
       element_type = check_typedef (element_type);
Jan Kratochvil cec9297
+
Jan Kratochvil cec9297
+      byte_stride = abs (TYPE_BYTE_STRIDE (range_type));
Jan Kratochvil cec9297
+
Jan Kratochvil cec9297
       /* Be careful when setting the array length.  Ada arrays can be
Jan Kratochvil cec9297
 	 empty arrays with the high_bound being smaller than the low_bound.
Jan Kratochvil cec9297
 	 In such cases, the array length should be zero.  */
Jan Kratochvil cec9297
       if (high_bound < low_bound)
Jan Kratochvil cec9297
 	TYPE_LENGTH (result_type) = 0;
Jan Kratochvil cec9297
+      else if (byte_stride > 0)
Jan Kratochvil cec9297
+	TYPE_LENGTH (result_type) = byte_stride * (high_bound - low_bound + 1);
Jan Kratochvil cec9297
       else if (bit_stride > 0)
Jan Kratochvil cec9297
 	TYPE_LENGTH (result_type) =
Jan Kratochvil cec9297
 	  (bit_stride * (high_bound - low_bound + 1) + 7) / 8;
Jan Kratochvil 2116e53
@@ -1804,12 +1815,31 @@
Jan Kratochvil a972d47
 static int
Jan Kratochvil a972d47
 is_dynamic_type_internal (struct type *type, int top_level)
Jan Kratochvil cec9297
 {
Jan Kratochvil cec9297
+  int index;
Jan Kratochvil cec9297
+
Jan Kratochvil cec9297
+  if (!type)
Jan Kratochvil cec9297
+    return 0;
Jan Kratochvil cec9297
+
Jan Kratochvil cec9297
   type = check_typedef (type);
Jan Kratochvil cec9297
 
Jan Kratochvil a972d47
   /* We only want to recognize references at the outermost level.  */
Jan Kratochvil a972d47
   if (top_level && TYPE_CODE (type) == TYPE_CODE_REF)
Jan Kratochvil cec9297
     type = check_typedef (TYPE_TARGET_TYPE (type));
Jan Kratochvil cec9297
 
Jan Kratochvil cec9297
+  if (TYPE_ASSOCIATED_PROP (type))
Jan Kratochvil cec9297
+    return 1;
Jan Kratochvil cec9297
+
Jan Kratochvil cec9297
+  if (TYPE_ALLOCATED_PROP (type))
Jan Kratochvil cec9297
+    return 1;
Jan Kratochvil cec9297
+
Jan Kratochvil cec9297
+  /* Scan field types in the Fortran case for nested dynamic types.
Jan Kratochvil cec9297
+     This will be done only for Fortran as in the C++ case an endless recursion
Jan Kratochvil cec9297
+     can occur in the area of classes.  */
Jan Kratochvil cec9297
+  if (current_language->la_language == language_fortran)
Jan Kratochvil cec9297
+    for (index = 0; index < TYPE_NFIELDS (type); index++)
Jan Kratochvil cec9297
+      if (is_dynamic_type (TYPE_FIELD_TYPE (type, index)))
Jan Kratochvil cec9297
+        return 1;
Jan Kratochvil cec9297
+
Jan Kratochvil 2f7f533
   /* Types that have a dynamic TYPE_DATA_LOCATION are considered
Jan Kratochvil 2f7f533
      dynamic, even if the type itself is statically defined.
Jan Kratochvil 2f7f533
      From a user's point of view, this may appear counter-intuitive;
Jan Kratochvil 2116e53
@@ -1844,11 +1874,19 @@
Jan Kratochvil cec9297
       {
Jan Kratochvil cec9297
 	gdb_assert (TYPE_NFIELDS (type) == 1);
Jan Kratochvil cec9297
 
Jan Kratochvil cec9297
-	/* The array is dynamic if either the bounds are dynamic,
Jan Kratochvil cec9297
-	   or the elements it contains have a dynamic contents.  */
Jan Kratochvil cec9297
+	/* The array is dynamic if either
Jan Kratochvil cec9297
+     - the bounds are dynamic,
Jan Kratochvil cec9297
+	   - the elements it contains have a dynamic contents
Jan Kratochvil cec9297
+     - a data_locaton attribute was found.  */
Jan Kratochvil a972d47
 	if (is_dynamic_type_internal (TYPE_INDEX_TYPE (type), 0))
Jan Kratochvil cec9297
 	  return 1;
Jan Kratochvil a972d47
-	return is_dynamic_type_internal (TYPE_TARGET_TYPE (type), 0);
Jan Kratochvil cec9297
+	else if (TYPE_DATA_LOCATION (type) != NULL
Jan Kratochvil cec9297
+	         && (TYPE_DATA_LOCATION_KIND (type) == PROP_LOCEXPR
Jan Kratochvil cec9297
+	             || TYPE_DATA_LOCATION_KIND (type) == PROP_LOCLIST))
Jan Kratochvil cec9297
+    return 1;
Jan Kratochvil cec9297
+  else
Jan Kratochvil a972d47
+    return is_dynamic_type_internal (TYPE_TARGET_TYPE (type), 0);
Jan Kratochvil cec9297
+	break;
Jan Kratochvil cec9297
       }
Jan Kratochvil cec9297
 
Jan Kratochvil cec9297
     case TYPE_CODE_STRUCT:
Jan Kratochvil 2116e53
@@ -1861,6 +1899,18 @@
Jan Kratochvil a972d47
 	      && is_dynamic_type_internal (TYPE_FIELD_TYPE (type, i), 0))
Jan Kratochvil cec9297
 	    return 1;
Jan Kratochvil cec9297
       }
Jan Kratochvil cec9297
+    case TYPE_CODE_PTR:
Jan Kratochvil cec9297
+      {
Jan Kratochvil cec9297
+        if (TYPE_TARGET_TYPE (type)
Jan Kratochvil 32f92b2
+            && (TYPE_CODE (TYPE_TARGET_TYPE (type)) == TYPE_CODE_STRING
Jan Kratochvil 32f92b2
+                || TYPE_CODE (TYPE_TARGET_TYPE (type)) == TYPE_CODE_ARRAY))
Jan Kratochvil cec9297
+          return is_dynamic_type (check_typedef (TYPE_TARGET_TYPE (type)));
Jan Kratochvil cec9297
+
Jan Kratochvil cec9297
+        return 0;
Jan Kratochvil cec9297
+        break;
Jan Kratochvil cec9297
+      }
Jan Kratochvil cec9297
+    default:
Jan Kratochvil cec9297
+      return 0;
Jan Kratochvil cec9297
       break;
Jan Kratochvil cec9297
     }
Jan Kratochvil cec9297
 
Jan Kratochvil 2116e53
@@ -1890,7 +1940,8 @@
Jan Kratochvil 32f92b2
   struct type *static_range_type, *static_target_type;
Jan Kratochvil cec9297
   const struct dynamic_prop *prop;
Jan Kratochvil cec9297
   const struct dwarf2_locexpr_baton *baton;
Jan Kratochvil cec9297
-  struct dynamic_prop low_bound, high_bound;
Jan Kratochvil cec9297
+  struct dynamic_prop low_bound, high_bound, stride;
Jan Kratochvil cec9297
+  struct type *range_copy = copy_type (dyn_range_type);
Jan Kratochvil cec9297
 
Jan Kratochvil cec9297
   gdb_assert (TYPE_CODE (dyn_range_type) == TYPE_CODE_RANGE);
Jan Kratochvil cec9297
 
Jan Kratochvil 2116e53
@@ -1922,12 +1973,19 @@
Jan Kratochvil cec9297
       high_bound.data.const_val = 0;
Jan Kratochvil cec9297
     }
Jan Kratochvil 32f92b2
 
Jan Kratochvil cec9297
+  prop = &TYPE_RANGE_DATA (dyn_range_type)->stride;
Jan Kratochvil 23f398e
+  if (dwarf2_evaluate_property (prop, NULL, addr_stack, &value))
Jan Kratochvil cec9297
+    {
Jan Kratochvil cec9297
+      stride.kind = PROP_CONST;
Jan Kratochvil cec9297
+      stride.data.const_val = value;
Jan Kratochvil cec9297
+    }
Jan Kratochvil 32f92b2
+
Jan Kratochvil 32f92b2
   static_target_type
Jan Kratochvil 32f92b2
-    = resolve_dynamic_type_internal (TYPE_TARGET_TYPE (dyn_range_type),
Jan Kratochvil 32f92b2
+    = resolve_dynamic_type_internal (TYPE_TARGET_TYPE (range_copy),
Jan Kratochvil 32f92b2
 				     addr_stack, 0);
Jan Kratochvil cec9297
-  static_range_type = create_range_type (copy_type (dyn_range_type),
Jan Kratochvil cec9297
+  static_range_type = create_range_type (range_copy,
Jan Kratochvil 32f92b2
 					 static_target_type,
Jan Kratochvil 32f92b2
-					 &low_bound, &high_bound);
Jan Kratochvil cec9297
+					 &low_bound, &high_bound, &stride);
Jan Kratochvil cec9297
   TYPE_RANGE_DATA (static_range_type)->flag_bound_evaluated = 1;
Jan Kratochvil cec9297
   return static_range_type;
Jan Kratochvil cec9297
 }
Jan Kratochvil 2116e53
@@ -1946,7 +2004,8 @@
Jan Kratochvil cec9297
   struct type *ary_dim;
Jan Kratochvil 23f398e
   struct dynamic_prop *prop;
Jan Kratochvil cec9297
 
Jan Kratochvil cec9297
-  gdb_assert (TYPE_CODE (type) == TYPE_CODE_ARRAY);
Jan Kratochvil cec9297
+  gdb_assert (TYPE_CODE (type) == TYPE_CODE_ARRAY
Jan Kratochvil 2f7f533
+	      || TYPE_CODE (type) == TYPE_CODE_STRING);
Jan Kratochvil cec9297
 
Jan Kratochvil 23f398e
   type = copy_type (type);
Jan Kratochvil 23f398e
 
Jan Kratochvil 2116e53
@@ -1971,13 +2030,18 @@
Jan Kratochvil 2f7f533
 
Jan Kratochvil cec9297
   ary_dim = check_typedef (TYPE_TARGET_TYPE (elt_type));
Jan Kratochvil cec9297
 
Jan Kratochvil cec9297
-  if (ary_dim != NULL && TYPE_CODE (ary_dim) == TYPE_CODE_ARRAY)
Jan Kratochvil cec9297
+  if (ary_dim != NULL && (TYPE_CODE (ary_dim) == TYPE_CODE_ARRAY
Jan Kratochvil 23f398e
+			  || TYPE_CODE (ary_dim) == TYPE_CODE_STRING))
Jan Kratochvil 23f398e
     elt_type = resolve_dynamic_array (ary_dim, addr_stack);
Jan Kratochvil cec9297
   else
Jan Kratochvil cec9297
     elt_type = TYPE_TARGET_TYPE (type);
Jan Kratochvil cec9297
 
Jan Kratochvil 23f398e
-  return create_array_type_with_stride (type, elt_type, range_type,
Jan Kratochvil 23f398e
-                                        TYPE_FIELD_BITSIZE (type, 0));
Jan Kratochvil 32f92b2
+  if (TYPE_CODE (type) == TYPE_CODE_STRING
Jan Kratochvil 32f92b2
+      && TYPE_FIELD_BITSIZE (type, 0) == 0)
Jan Kratochvil 23f398e
+    return create_string_type (type, elt_type, range_type);
Jan Kratochvil cec9297
+  else
Jan Kratochvil 23f398e
+    return create_array_type_with_stride (type, elt_type, range_type,
Jan Kratochvil 23f398e
+					  TYPE_FIELD_BITSIZE (type, 0));
Jan Kratochvil cec9297
 }
Jan Kratochvil cec9297
 
Jan Kratochvil cec9297
 /* Resolve dynamic bounds of members of the union TYPE to static
Jan Kratochvil 2116e53
Index: gdb-7.10.50.20160106/gdb/gdbtypes.h
Jan Kratochvil b132e8a
===================================================================
Jan Kratochvil 2116e53
--- gdb-7.10.50.20160106.orig/gdb/gdbtypes.h	2016-01-08 19:15:35.085582471 +0100
Jan Kratochvil 2116e53
+++ gdb-7.10.50.20160106/gdb/gdbtypes.h	2016-01-08 19:15:44.983637680 +0100
Jan Kratochvil 2116e53
@@ -577,6 +577,10 @@
Jan Kratochvil cec9297
 
Jan Kratochvil 32f92b2
   struct dynamic_prop high;
Jan Kratochvil cec9297
 
Jan Kratochvil 32f92b2
+  /* * Stride of range.  */
Jan Kratochvil cec9297
+
Jan Kratochvil 32f92b2
+  struct dynamic_prop stride;
Jan Kratochvil cec9297
+
Jan Kratochvil 32f92b2
   /* True if HIGH range bound contains the number of elements in the
Jan Kratochvil 32f92b2
      subrange. This affects how the final hight bound is computed.  */
Jan Kratochvil cec9297
 
Jan Kratochvil 2116e53
@@ -749,6 +753,18 @@
Jan Kratochvil cec9297
 
Jan Kratochvil 32f92b2
   /* * Contains all dynamic type properties.  */
Jan Kratochvil 32f92b2
   struct dynamic_prop_list *dyn_prop_list;
Jan Kratochvil cec9297
+
Jan Kratochvil cec9297
+  /* Structure for DW_AT_allocated.
Jan Kratochvil cec9297
+     The presence of this attribute indicates that the object of the type
Jan Kratochvil cec9297
+     can be allocated/deallocated.  The value can be a dwarf expression,
Jan Kratochvil cec9297
+     reference, or a constant.  */
Jan Kratochvil cec9297
+  struct dynamic_prop *allocated;
Jan Kratochvil cec9297
+
Jan Kratochvil cec9297
+  /* Structure for DW_AT_associated.
Jan Kratochvil cec9297
+     The presence of this attribute indicated that the object of the type
Jan Kratochvil cec9297
+     can be associated.  The value can be a dwarf expression,
Jan Kratochvil cec9297
+     reference, or a constant.  */
Jan Kratochvil cec9297
+  struct dynamic_prop *associated;
Jan Kratochvil cec9297
 };
Jan Kratochvil cec9297
 
Jan Kratochvil cec9297
 /* * A ``struct type'' describes a particular instance of a type, with
Jan Kratochvil 2116e53
@@ -1255,6 +1271,15 @@
Jan Kratochvil cec9297
   TYPE_RANGE_DATA(range_type)->high.kind
Jan Kratochvil cec9297
 #define TYPE_LOW_BOUND_KIND(range_type) \
Jan Kratochvil cec9297
   TYPE_RANGE_DATA(range_type)->low.kind
Jan Kratochvil cec9297
+#define TYPE_BYTE_STRIDE(range_type) \
Jan Kratochvil cec9297
+  TYPE_RANGE_DATA(range_type)->stride.data.const_val
Jan Kratochvil cec9297
+#define TYPE_BYTE_STRIDE_BLOCK(range_type) \
Jan Kratochvil cec9297
+  TYPE_RANGE_DATA(range_type)->stride.data.locexpr
Jan Kratochvil cec9297
+#define TYPE_BYTE_STRIDE_LOCLIST(range_type) \
Jan Kratochvil cec9297
+  TYPE_RANGE_DATA(range_type)->stride.data.loclist
Jan Kratochvil cec9297
+#define TYPE_BYTE_STRIDE_KIND(range_type) \
Jan Kratochvil cec9297
+  TYPE_RANGE_DATA(range_type)->stride.kind
Jan Kratochvil cec9297
+
Jan Kratochvil 32f92b2
 
Jan Kratochvil 32f92b2
 /* Property accessors for the type data location.  */
Jan Kratochvil 32f92b2
 #define TYPE_DATA_LOCATION(thistype) \
Jan Kratochvil 2116e53
@@ -1266,6 +1291,18 @@
Jan Kratochvil 32f92b2
 #define TYPE_DATA_LOCATION_KIND(thistype) \
Jan Kratochvil 32f92b2
   TYPE_DATA_LOCATION (thistype)->kind
Jan Kratochvil 23f398e
 
Jan Kratochvil cec9297
+/* Allocated status of type object.  If set to non-zero it means the object
Jan Kratochvil cec9297
+   is allocated. A zero value means it is not allocated.  */
Jan Kratochvil cec9297
+#define TYPE_NOT_ALLOCATED(t)  (TYPE_ALLOCATED_PROP (t) \
Jan Kratochvil cec9297
+  && TYPE_ALLOCATED_PROP (t)->kind == PROP_CONST \
Jan Kratochvil cec9297
+  && !TYPE_ALLOCATED_PROP (t)->data.const_val)
Jan Kratochvil cec9297
+
Jan Kratochvil cec9297
+/* Associated status of type object.  If set to non-zero it means the object
Jan Kratochvil cec9297
+   is associated. A zero value means it is not associated.  */
Jan Kratochvil cec9297
+#define TYPE_NOT_ASSOCIATED(t)  (TYPE_ASSOCIATED_PROP (t) \
Jan Kratochvil cec9297
+  && TYPE_ASSOCIATED_PROP (t)->kind == PROP_CONST \
Jan Kratochvil cec9297
+  && !TYPE_ASSOCIATED_PROP (t)->data.const_val)
Jan Kratochvil 23f398e
+
Jan Kratochvil 23f398e
 /* Property accessors for the type allocated/associated.  */
Jan Kratochvil 23f398e
 #define TYPE_ALLOCATED_PROP(thistype) \
Jan Kratochvil 23f398e
   get_dyn_prop (DYN_PROP_ALLOCATED, thistype)
Jan Kratochvil 2116e53
@@ -1289,6 +1326,9 @@
Jan Kratochvil cec9297
    TYPE_HIGH_BOUND_UNDEFINED(TYPE_INDEX_TYPE(arraytype))
Jan Kratochvil cec9297
 #define TYPE_ARRAY_LOWER_BOUND_IS_UNDEFINED(arraytype) \
Jan Kratochvil cec9297
    TYPE_LOW_BOUND_UNDEFINED(TYPE_INDEX_TYPE(arraytype))
Jan Kratochvil cec9297
+#define TYPE_ARRAY_STRIDE_IS_UNDEFINED(arraytype) \
Jan Kratochvil cec9297
+   (TYPE_BYTE_STRIDE(TYPE_INDEX_TYPE(arraytype)) == 0)
Jan Kratochvil cec9297
+
Jan Kratochvil cec9297
 
Jan Kratochvil cec9297
 #define TYPE_ARRAY_UPPER_BOUND_VALUE(arraytype) \
Jan Kratochvil cec9297
    (TYPE_HIGH_BOUND(TYPE_INDEX_TYPE((arraytype))))
Jan Kratochvil 2116e53
@@ -1775,6 +1815,7 @@
Jan Kratochvil cec9297
 
Jan Kratochvil cec9297
 extern struct type *create_range_type (struct type *, struct type *,
Jan Kratochvil cec9297
 				       const struct dynamic_prop *,
Jan Kratochvil cec9297
+				       const struct dynamic_prop *,
Jan Kratochvil cec9297
 				       const struct dynamic_prop *);
Jan Kratochvil cec9297
 
Jan Kratochvil cec9297
 extern struct type *create_array_type (struct type *, struct type *,
Jan Kratochvil 2116e53
Index: gdb-7.10.50.20160106/gdb/testsuite/gdb.fortran/vla-func.exp
Jan Kratochvil b132e8a
===================================================================
Jan Kratochvil b132e8a
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
Jan Kratochvil 2116e53
+++ gdb-7.10.50.20160106/gdb/testsuite/gdb.fortran/vla-func.exp	2016-01-08 19:15:44.983637680 +0100
Jan Kratochvil cec9297
@@ -0,0 +1,61 @@
Jan Kratochvil cec9297
+# Copyright 2014 Free Software Foundation, Inc.
Jan Kratochvil cec9297
+
Jan Kratochvil cec9297
+# This program is free software; you can redistribute it and/or modify
Jan Kratochvil cec9297
+# it under the terms of the GNU General Public License as published by
Jan Kratochvil cec9297
+# the Free Software Foundation; either version 3 of the License, or
Jan Kratochvil cec9297
+# (at your option) any later version.
Jan Kratochvil cec9297
+#
Jan Kratochvil cec9297
+# This program is distributed in the hope that it will be useful,
Jan Kratochvil cec9297
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
Jan Kratochvil cec9297
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Jan Kratochvil cec9297
+# GNU General Public License for more details.
Jan Kratochvil cec9297
+#
Jan Kratochvil cec9297
+# You should have received a copy of the GNU General Public License
Jan Kratochvil cec9297
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
Jan Kratochvil cec9297
+
Jan Kratochvil cec9297
+standard_testfile ".f90"
Jan Kratochvil cec9297
+
Jan Kratochvil cec9297
+if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} \
Jan Kratochvil cec9297
+    {debug f90 quiet}] } {
Jan Kratochvil cec9297
+    return -1
Jan Kratochvil cec9297
+}
Jan Kratochvil cec9297
+
Jan Kratochvil cec9297
+if ![runto MAIN__] then {
Jan Kratochvil cec9297
+    perror "couldn't run to breakpoint MAIN__"
Jan Kratochvil cec9297
+    continue
Jan Kratochvil cec9297
+}
Jan Kratochvil cec9297
+
Jan Kratochvil cec9297
+# Check VLA passed to first Fortran function.
Jan Kratochvil cec9297
+gdb_breakpoint [gdb_get_line_number "func1-vla-passed"]
Jan Kratochvil cec9297
+gdb_continue_to_breakpoint "func1-vla-passed"
Jan Kratochvil cec9297
+gdb_test "print vla" " = \\( *\\( *22, *22, *22,\[()22, .\]*\\)" \
Jan Kratochvil cec9297
+  "print vla (func1)"
Jan Kratochvil cec9297
+gdb_test "ptype vla" "type = integer\\\(kind=4\\\) \\\(10,10\\\)" \
Jan Kratochvil cec9297
+  "ptype vla (func1)"
Jan Kratochvil cec9297
+
Jan Kratochvil cec9297
+gdb_breakpoint [gdb_get_line_number "func1-vla-modified"]
Jan Kratochvil cec9297
+gdb_continue_to_breakpoint "func1-vla-modified"
Jan Kratochvil cec9297
+gdb_test "print vla(5,5)" " = 55" "print vla(5,5) (func1)"
Jan Kratochvil cec9297
+gdb_test "print vla(7,7)" " = 77" "print vla(5,5) (func1)"
Jan Kratochvil cec9297
+
Jan Kratochvil cec9297
+# Check if the values are correct after returning from func1
Jan Kratochvil cec9297
+gdb_breakpoint [gdb_get_line_number "func1-returned"]
Jan Kratochvil cec9297
+gdb_continue_to_breakpoint "func1-returned"
Jan Kratochvil cec9297
+gdb_test "print ret" " = .TRUE." "print ret after func1 returned"
Jan Kratochvil cec9297
+
Jan Kratochvil cec9297
+# Check VLA passed to second Fortran function
Jan Kratochvil cec9297
+gdb_breakpoint [gdb_get_line_number "func2-vla-passed"]
Jan Kratochvil cec9297
+gdb_continue_to_breakpoint "func2-vla-passed"
Jan Kratochvil cec9297
+gdb_test "print vla" \
Jan Kratochvil cec9297
+  " = \\\(44, 44, 44, 44, 44, 44, 44, 44, 44, 44\\\)" \
Jan Kratochvil cec9297
+  "print vla (func2)"
Jan Kratochvil cec9297
+gdb_test "ptype vla" "type = integer\\\(kind=4\\\) \\\(10\\\)" \
Jan Kratochvil cec9297
+  "ptype vla (func2)"
Jan Kratochvil cec9297
+
Jan Kratochvil cec9297
+# Check if the returned VLA has the correct values and ptype.
Jan Kratochvil cec9297
+gdb_breakpoint [gdb_get_line_number "func2-returned"]
Jan Kratochvil cec9297
+gdb_continue_to_breakpoint "func2-returned"
Jan Kratochvil cec9297
+gdb_test "print vla3" " = \\\(1, 2, 44, 4, 44, 44, 44, 8, 44, 44\\\)" \
Jan Kratochvil cec9297
+  "print vla3 (after func2)"
Jan Kratochvil cec9297
+gdb_test "ptype vla3" "type = integer\\\(kind=4\\\) \\\(10\\\)" \
Jan Kratochvil cec9297
+  "ptype vla3 (after func2)"
Jan Kratochvil 2116e53
Index: gdb-7.10.50.20160106/gdb/testsuite/gdb.fortran/vla-func.f90
Jan Kratochvil b132e8a
===================================================================
Jan Kratochvil b132e8a
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
Jan Kratochvil 2116e53
+++ gdb-7.10.50.20160106/gdb/testsuite/gdb.fortran/vla-func.f90	2016-01-08 19:15:44.983637680 +0100
Jan Kratochvil cec9297
@@ -0,0 +1,71 @@
Jan Kratochvil cec9297
+! Copyright 2014 Free Software Foundation, Inc.
Jan Kratochvil cec9297
+!
Jan Kratochvil cec9297
+! This program is free software; you can redistribute it and/or modify
Jan Kratochvil cec9297
+! it under the terms of the GNU General Public License as published by
Jan Kratochvil cec9297
+! the Free Software Foundation; either version 2 of the License, or
Jan Kratochvil cec9297
+! (at your option) any later version.
Jan Kratochvil cec9297
+!
Jan Kratochvil cec9297
+! This program is distributed in the hope that it will be useful,
Jan Kratochvil cec9297
+! but WITHOUT ANY WARRANTY; without even the implied warranty of
Jan Kratochvil cec9297
+! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Jan Kratochvil cec9297
+! GNU General Public License for more details.
Jan Kratochvil cec9297
+!
Jan Kratochvil cec9297
+! You should have received a copy of the GNU General Public License
Jan Kratochvil cec9297
+! along with this program; if not, write to the Free Software
Jan Kratochvil cec9297
+! Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
Jan Kratochvil cec9297
+
Jan Kratochvil cec9297
+logical function func1 (vla)
Jan Kratochvil cec9297
+  implicit none
Jan Kratochvil cec9297
+  integer, allocatable :: vla (:, :)
Jan Kratochvil cec9297
+  func1 = allocated(vla)
Jan Kratochvil cec9297
+  vla(5,5) = 55               ! func1-vla-passed
Jan Kratochvil cec9297
+  vla(7,7) = 77
Jan Kratochvil cec9297
+  return                      ! func1-vla-modified
Jan Kratochvil cec9297
+end function func1
Jan Kratochvil cec9297
+
Jan Kratochvil cec9297
+function func2(vla)
Jan Kratochvil cec9297
+  implicit none
Jan Kratochvil cec9297
+  integer :: vla (:)
Jan Kratochvil cec9297
+  integer :: func2(size(vla))
Jan Kratochvil cec9297
+  integer :: k
Jan Kratochvil cec9297
+
Jan Kratochvil cec9297
+  vla(1) = 1                    ! func2-vla-passed
Jan Kratochvil cec9297
+  vla(2) = 2
Jan Kratochvil cec9297
+  vla(4) = 4
Jan Kratochvil cec9297
+  vla(8) = 8
Jan Kratochvil cec9297
+
Jan Kratochvil cec9297
+  func2 = vla
Jan Kratochvil cec9297
+end function func2
Jan Kratochvil cec9297
+
Jan Kratochvil cec9297
+program vla_func
Jan Kratochvil cec9297
+  implicit none
Jan Kratochvil cec9297
+  interface
Jan Kratochvil cec9297
+    logical function func1 (vla)
Jan Kratochvil cec9297
+      integer :: vla (:, :)
Jan Kratochvil cec9297
+    end function
Jan Kratochvil cec9297
+  end interface
Jan Kratochvil cec9297
+  interface
Jan Kratochvil cec9297
+    function func2 (vla)
Jan Kratochvil cec9297
+      integer :: vla (:)
Jan Kratochvil cec9297
+      integer func2(size(vla))
Jan Kratochvil cec9297
+    end function
Jan Kratochvil cec9297
+  end interface
Jan Kratochvil cec9297
+
Jan Kratochvil cec9297
+  logical :: ret
Jan Kratochvil cec9297
+  integer, allocatable :: vla1 (:, :)
Jan Kratochvil cec9297
+  integer, allocatable :: vla2 (:)
Jan Kratochvil cec9297
+  integer, allocatable :: vla3 (:)
Jan Kratochvil cec9297
+
Jan Kratochvil cec9297
+  ret = .FALSE.
Jan Kratochvil cec9297
+
Jan Kratochvil cec9297
+  allocate (vla1 (10,10))
Jan Kratochvil cec9297
+  vla1(:,:) = 22
Jan Kratochvil cec9297
+
Jan Kratochvil cec9297
+  allocate (vla2 (10))
Jan Kratochvil cec9297
+  vla2(:) = 44
Jan Kratochvil cec9297
+
Jan Kratochvil cec9297
+  ret = func1(vla1)
Jan Kratochvil cec9297
+  vla3 = func2(vla2)          ! func1-returned
Jan Kratochvil cec9297
+
Jan Kratochvil cec9297
+  ret = .TRUE.                ! func2-returned
Jan Kratochvil cec9297
+end program vla_func
Jan Kratochvil 2116e53
Index: gdb-7.10.50.20160106/gdb/testsuite/gdb.fortran/vla-stride.exp
Jan Kratochvil b132e8a
===================================================================
Jan Kratochvil b132e8a
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
Jan Kratochvil 2116e53
+++ gdb-7.10.50.20160106/gdb/testsuite/gdb.fortran/vla-stride.exp	2016-01-08 19:15:44.984637686 +0100
Jan Kratochvil 23f398e
@@ -0,0 +1,44 @@
Jan Kratochvil cec9297
+# Copyright 2014 Free Software Foundation, Inc.
Jan Kratochvil cec9297
+
Jan Kratochvil cec9297
+# This program is free software; you can redistribute it and/or modify
Jan Kratochvil cec9297
+# it under the terms of the GNU General Public License as published by
Jan Kratochvil cec9297
+# the Free Software Foundation; either version 3 of the License, or
Jan Kratochvil cec9297
+# (at your option) any later version.
Jan Kratochvil cec9297
+#
Jan Kratochvil cec9297
+# This program is distributed in the hope that it will be useful,
Jan Kratochvil cec9297
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
Jan Kratochvil cec9297
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Jan Kratochvil cec9297
+# GNU General Public License for more details.
Jan Kratochvil cec9297
+#
Jan Kratochvil cec9297
+# You should have received a copy of the GNU General Public License
Jan Kratochvil cec9297
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
Jan Kratochvil cec9297
+
Jan Kratochvil 23f398e
+standard_testfile ".f90"
Jan Kratochvil cec9297
+
Jan Kratochvil cec9297
+if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} \
Jan Kratochvil cec9297
+    {debug f90 quiet}] } {
Jan Kratochvil cec9297
+    return -1
Jan Kratochvil cec9297
+}
Jan Kratochvil cec9297
+
Jan Kratochvil cec9297
+if ![runto MAIN__] then {
Jan Kratochvil cec9297
+    perror "couldn't run to breakpoint MAIN__"
Jan Kratochvil cec9297
+    continue
Jan Kratochvil cec9297
+}
Jan Kratochvil cec9297
+
Jan Kratochvil 23f398e
+gdb_breakpoint [gdb_get_line_number "re-reverse-elements"]
Jan Kratochvil 23f398e
+gdb_continue_to_breakpoint "re-reverse-elements"
Jan Kratochvil 23f398e
+gdb_test "print pvla" " = \\\(1, 2, 3, 4, 5, 6, 7, 8, 9, 10\\\)" \
Jan Kratochvil 23f398e
+  "print re-reverse-elements"
Jan Kratochvil 23f398e
+gdb_test "print pvla(1)" " = 1" "print first re-reverse-element"
Jan Kratochvil 23f398e
+gdb_test "print pvla(10)" " = 10" "print last re-reverse-element"
Jan Kratochvil cec9297
+
Jan Kratochvil 23f398e
+gdb_breakpoint [gdb_get_line_number "odd-elements"]
Jan Kratochvil 23f398e
+gdb_continue_to_breakpoint "odd-elements"
Jan Kratochvil 23f398e
+gdb_test "print pvla" " = \\\(1, 3, 5, 7, 9\\\)" "print odd-elements"
Jan Kratochvil 23f398e
+gdb_test "print pvla(1)" " = 1" "print first odd-element"
Jan Kratochvil 23f398e
+gdb_test "print pvla(5)" " = 9" "print last odd-element"
Jan Kratochvil cec9297
+
Jan Kratochvil 23f398e
+gdb_breakpoint [gdb_get_line_number "single-element"]
Jan Kratochvil 23f398e
+gdb_continue_to_breakpoint "single-element"
Jan Kratochvil 23f398e
+gdb_test "print pvla" " = \\\(5\\\)" "print single-element"
Jan Kratochvil 23f398e
+gdb_test "print pvla(1)" " = 5" "print one single-element"
Jan Kratochvil 2116e53
Index: gdb-7.10.50.20160106/gdb/testsuite/gdb.fortran/vla-stride.f90
Jan Kratochvil b132e8a
===================================================================
Jan Kratochvil b132e8a
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
Jan Kratochvil 2116e53
+++ gdb-7.10.50.20160106/gdb/testsuite/gdb.fortran/vla-stride.f90	2016-01-08 19:15:44.984637686 +0100
Jan Kratochvil 23f398e
@@ -0,0 +1,30 @@
Jan Kratochvil 23f398e
+! Copyright 2014 Free Software Foundation, Inc.
Jan Kratochvil 23f398e
+!
Jan Kratochvil 23f398e
+! This program is free software; you can redistribute it and/or modify
Jan Kratochvil 23f398e
+! it under the terms of the GNU General Public License as published by
Jan Kratochvil 23f398e
+! the Free Software Foundation; either version 2 of the License, or
Jan Kratochvil 23f398e
+! (at your option) any later version.
Jan Kratochvil 23f398e
+!
Jan Kratochvil 23f398e
+! This program is distributed in the hope that it will be useful,
Jan Kratochvil 23f398e
+! but WITHOUT ANY WARRANTY; without even the implied warranty of
Jan Kratochvil 23f398e
+! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Jan Kratochvil 23f398e
+! GNU General Public License for more details.
Jan Kratochvil 23f398e
+!
Jan Kratochvil 23f398e
+! You should have received a copy of the GNU General Public License
Jan Kratochvil 23f398e
+! along with this program; if not, write to the Free Software
Jan Kratochvil 23f398e
+! Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
Jan Kratochvil cec9297
+
Jan Kratochvil 23f398e
+program vla_stride
Jan Kratochvil 23f398e
+  integer, target, allocatable :: vla (:)
Jan Kratochvil 23f398e
+  integer, pointer :: pvla (:)
Jan Kratochvil cec9297
+
Jan Kratochvil 23f398e
+  allocate(vla(10))
Jan Kratochvil 23f398e
+  vla = (/ (I, I = 1,10) /)
Jan Kratochvil cec9297
+
Jan Kratochvil 23f398e
+  pvla => vla(10:1:-1)
Jan Kratochvil 23f398e
+  pvla => pvla(10:1:-1)
Jan Kratochvil 23f398e
+  pvla => vla(1:10:2)   ! re-reverse-elements
Jan Kratochvil 23f398e
+  pvla => vla(5:4:-2)   ! odd-elements
Jan Kratochvil cec9297
+
Jan Kratochvil 23f398e
+  pvla => null()        ! single-element
Jan Kratochvil 23f398e
+end program vla_stride
Jan Kratochvil 2116e53
Index: gdb-7.10.50.20160106/gdb/testsuite/gdb.fortran/vla-strings.exp
Jan Kratochvil b132e8a
===================================================================
Jan Kratochvil b132e8a
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
Jan Kratochvil 2116e53
+++ gdb-7.10.50.20160106/gdb/testsuite/gdb.fortran/vla-strings.exp	2016-01-08 19:15:44.984637686 +0100
Jan Kratochvil 23f398e
@@ -0,0 +1,101 @@
Jan Kratochvil cec9297
+# Copyright 2014 Free Software Foundation, Inc.
Jan Kratochvil cec9297
+
Jan Kratochvil cec9297
+# This program is free software; you can redistribute it and/or modify
Jan Kratochvil cec9297
+# it under the terms of the GNU General Public License as published by
Jan Kratochvil cec9297
+# the Free Software Foundation; either version 3 of the License, or
Jan Kratochvil cec9297
+# (at your option) any later version.
Jan Kratochvil cec9297
+#
Jan Kratochvil cec9297
+# This program is distributed in the hope that it will be useful,
Jan Kratochvil cec9297
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
Jan Kratochvil cec9297
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Jan Kratochvil cec9297
+# GNU General Public License for more details.
Jan Kratochvil cec9297
+#
Jan Kratochvil cec9297
+# You should have received a copy of the GNU General Public License
Jan Kratochvil cec9297
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
Jan Kratochvil cec9297
+
Jan Kratochvil 23f398e
+standard_testfile ".f90"
Jan Kratochvil cec9297
+
Jan Kratochvil cec9297
+if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} \
Jan Kratochvil cec9297
+    {debug f90 quiet}] } {
Jan Kratochvil cec9297
+    return -1
Jan Kratochvil cec9297
+}
Jan Kratochvil 23f398e
+
Jan Kratochvil 23f398e
+# check that all fortran standard datatypes will be
Jan Kratochvil 23f398e
+# handled correctly when using as VLA's
Jan Kratochvil cec9297
+
Jan Kratochvil cec9297
+if ![runto MAIN__] then {
Jan Kratochvil cec9297
+    perror "couldn't run to breakpoint MAIN__"
Jan Kratochvil cec9297
+    continue
Jan Kratochvil cec9297
+}
Jan Kratochvil cec9297
+
Jan Kratochvil cec9297
+gdb_breakpoint [gdb_get_line_number "var_char-allocated-1"]
Jan Kratochvil cec9297
+gdb_continue_to_breakpoint "var_char-allocated-1"
Jan Kratochvil cec9297
+gdb_test "print var_char" \
Jan Kratochvil cec9297
+  " = \\(PTR TO -> \\( character\\*10 \\)\\) ${hex}" \
Jan Kratochvil cec9297
+  "print var_char after allocated first time"
Jan Kratochvil cec9297
+gdb_test "whatis var_char" "type = PTR TO -> \\( character\\*10 \\)" \
Jan Kratochvil cec9297
+  "whatis var_char first time"
Jan Kratochvil cec9297
+gdb_test "ptype var_char" "type = PTR TO -> \\( character\\*10 \\)" \
Jan Kratochvil cec9297
+  "ptype var_char first time"
Jan Kratochvil cec9297
+gdb_test "next" "\\d+.*var_char = 'foo'.*" \
Jan Kratochvil cec9297
+  "next to allocation status of var_char"
Jan Kratochvil cec9297
+gdb_test "print l" " = .TRUE." "print allocation status first time"
Jan Kratochvil cec9297
+
Jan Kratochvil cec9297
+gdb_breakpoint [gdb_get_line_number "var_char-filled-1"]
Jan Kratochvil cec9297
+gdb_continue_to_breakpoint "var_char-filled-1"
Jan Kratochvil cec9297
+gdb_test "print var_char" \
Jan Kratochvil cec9297
+  " = \\(PTR TO -> \\( character\\*3 \\)\\) ${hex}" \
Jan Kratochvil cec9297
+  "print var_char after filled first time"
Jan Kratochvil cec9297
+gdb_test "print *var_char" " = 'foo'" \
Jan Kratochvil cec9297
+  "print *var_char after filled first time"
Jan Kratochvil cec9297
+gdb_test "whatis var_char" "type = PTR TO -> \\( character\\*3 \\)" \
Jan Kratochvil cec9297
+  "whatis var_char after filled first time"
Jan Kratochvil cec9297
+gdb_test "ptype var_char" "type = PTR TO -> \\( character\\*3 \\)" \
Jan Kratochvil cec9297
+  "ptype var_char after filled first time"
Jan Kratochvil cec9297
+gdb_test "print var_char(1)" " = 102 'f'" "print var_char(1)"
Jan Kratochvil cec9297
+gdb_test "print var_char(3)" " = 111 'o'" "print var_char(3)"
Jan Kratochvil cec9297
+
Jan Kratochvil cec9297
+gdb_breakpoint [gdb_get_line_number "var_char-filled-2"]
Jan Kratochvil cec9297
+gdb_continue_to_breakpoint "var_char-filled-2"
Jan Kratochvil cec9297
+gdb_test "print var_char" \
Jan Kratochvil cec9297
+  " = \\(PTR TO -> \\( character\\*6 \\)\\) ${hex}" \
Jan Kratochvil cec9297
+  "print var_char after allocated second time"
Jan Kratochvil cec9297
+gdb_test "print *var_char" " = 'foobar'" \
Jan Kratochvil cec9297
+  "print *var_char after allocated second time"
Jan Kratochvil cec9297
+gdb_test "whatis var_char" "type = PTR TO -> \\( character\\*6 \\)" \
Jan Kratochvil cec9297
+  "whatis var_char second time"
Jan Kratochvil cec9297
+gdb_test "ptype var_char" "type = PTR TO -> \\( character\\*6 \\)" \
Jan Kratochvil cec9297
+  "ptype var_char second time"
Jan Kratochvil cec9297
+
Jan Kratochvil cec9297
+gdb_breakpoint [gdb_get_line_number "var_char-empty"]
Jan Kratochvil cec9297
+gdb_continue_to_breakpoint "var_char-empty"
Jan Kratochvil cec9297
+gdb_test "print var_char" \
Jan Kratochvil cec9297
+  " = \\(PTR TO -> \\( character\\*0 \\)\\) ${hex}" \
Jan Kratochvil cec9297
+  "print var_char after set empty"
Jan Kratochvil cec9297
+gdb_test "print *var_char" " = \"\"" "print *var_char after set empty"
Jan Kratochvil cec9297
+gdb_test "whatis var_char" "type = PTR TO -> \\( character\\*0 \\)" \
Jan Kratochvil cec9297
+  "whatis var_char after set empty"
Jan Kratochvil cec9297
+gdb_test "ptype var_char" "type = PTR TO -> \\( character\\*0 \\)" \
Jan Kratochvil cec9297
+  "ptype var_char after set empty"
Jan Kratochvil cec9297
+
Jan Kratochvil cec9297
+gdb_breakpoint [gdb_get_line_number "var_char-allocated-3"]
Jan Kratochvil cec9297
+gdb_continue_to_breakpoint "var_char-allocated-3"
Jan Kratochvil cec9297
+gdb_test "print var_char" \
Jan Kratochvil cec9297
+  " = \\(PTR TO -> \\( character\\*21 \\)\\) ${hex}" \
Jan Kratochvil cec9297
+  "print var_char after allocated third time"
Jan Kratochvil cec9297
+gdb_test "whatis var_char" "type = PTR TO -> \\( character\\*21 \\)" \
Jan Kratochvil cec9297
+  "whatis var_char after allocated third time"
Jan Kratochvil cec9297
+gdb_test "ptype var_char" "type = PTR TO -> \\( character\\*21 \\)" \
Jan Kratochvil cec9297
+  "ptype var_char after allocated third time"
Jan Kratochvil cec9297
+
Jan Kratochvil cec9297
+gdb_breakpoint [gdb_get_line_number "var_char_p-associated"]
Jan Kratochvil cec9297
+gdb_continue_to_breakpoint "var_char_p-associated"
Jan Kratochvil cec9297
+gdb_test "print var_char_p" \
Jan Kratochvil cec9297
+  " = \\(PTR TO -> \\( character\\*7 \\)\\) ${hex}" \
Jan Kratochvil cec9297
+  "print var_char_p after associated"
Jan Kratochvil cec9297
+gdb_test "print *var_char_p" " = 'johndoe'" \
Jan Kratochvil cec9297
+  "print *var_char_ after associated"
Jan Kratochvil cec9297
+gdb_test "whatis var_char_p" "type = PTR TO -> \\( character\\*7 \\)" \
Jan Kratochvil cec9297
+  "whatis var_char_p after associated"
Jan Kratochvil cec9297
+gdb_test "ptype var_char_p" "type = PTR TO -> \\( character\\*7 \\)" \
Jan Kratochvil cec9297
+  "ptype var_char_p after associated"
Jan Kratochvil 2116e53
Index: gdb-7.10.50.20160106/gdb/testsuite/gdb.fortran/vla-strings.f90
Jan Kratochvil b132e8a
===================================================================
Jan Kratochvil b132e8a
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
Jan Kratochvil 2116e53
+++ gdb-7.10.50.20160106/gdb/testsuite/gdb.fortran/vla-strings.f90	2016-01-08 19:15:44.984637686 +0100
Jan Kratochvil cec9297
@@ -0,0 +1,40 @@
Jan Kratochvil cec9297
+! Copyright 2014 Free Software Foundation, Inc.
Jan Kratochvil cec9297
+!
Jan Kratochvil cec9297
+! This program is free software; you can redistribute it and/or modify
Jan Kratochvil cec9297
+! it under the terms of the GNU General Public License as published by
Jan Kratochvil cec9297
+! the Free Software Foundation; either version 2 of the License, or
Jan Kratochvil cec9297
+! (at your option) any later version.
Jan Kratochvil cec9297
+!
Jan Kratochvil cec9297
+! This program is distributed in the hope that it will be useful,
Jan Kratochvil cec9297
+! but WITHOUT ANY WARRANTY; without even the implied warranty of
Jan Kratochvil cec9297
+! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Jan Kratochvil cec9297
+! GNU General Public License for more details.
Jan Kratochvil cec9297
+!
Jan Kratochvil cec9297
+! You should have received a copy of the GNU General Public License
Jan Kratochvil cec9297
+! along with this program; if not, write to the Free Software
Jan Kratochvil cec9297
+! Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
Jan Kratochvil cec9297
+
Jan Kratochvil cec9297
+program vla_strings
Jan Kratochvil cec9297
+  character(len=:), target, allocatable   :: var_char
Jan Kratochvil cec9297
+  character(len=:), pointer               :: var_char_p
Jan Kratochvil cec9297
+  logical                                 :: l
Jan Kratochvil cec9297
+
Jan Kratochvil cec9297
+  allocate(character(len=10) :: var_char)
Jan Kratochvil cec9297
+  l = allocated(var_char)                 ! var_char-allocated-1
Jan Kratochvil cec9297
+  var_char = 'foo'
Jan Kratochvil cec9297
+  deallocate(var_char)                    ! var_char-filled-1
Jan Kratochvil cec9297
+  l = allocated(var_char)                 ! var_char-deallocated
Jan Kratochvil cec9297
+  allocate(character(len=42) :: var_char)
Jan Kratochvil cec9297
+  l = allocated(var_char)
Jan Kratochvil cec9297
+  var_char = 'foobar'
Jan Kratochvil cec9297
+  var_char = ''                           ! var_char-filled-2
Jan Kratochvil cec9297
+  var_char = 'bar'                        ! var_char-empty
Jan Kratochvil cec9297
+  deallocate(var_char)
Jan Kratochvil cec9297
+  allocate(character(len=21) :: var_char)
Jan Kratochvil cec9297
+  l = allocated(var_char)                 ! var_char-allocated-3
Jan Kratochvil cec9297
+  var_char = 'johndoe'
Jan Kratochvil cec9297
+  var_char_p => var_char
Jan Kratochvil cec9297
+  l = associated(var_char_p)              ! var_char_p-associated
Jan Kratochvil cec9297
+  var_char_p => null()
Jan Kratochvil cec9297
+  l = associated(var_char_p)              ! var_char_p-not-associated
Jan Kratochvil cec9297
+end program vla_strings
Jan Kratochvil 2116e53
Index: gdb-7.10.50.20160106/gdb/typeprint.c
Jan Kratochvil b132e8a
===================================================================
Jan Kratochvil 2116e53
--- gdb-7.10.50.20160106.orig/gdb/typeprint.c	2016-01-08 19:15:35.086582476 +0100
Jan Kratochvil 2116e53
+++ gdb-7.10.50.20160106/gdb/typeprint.c	2016-01-08 19:15:44.984637686 +0100
Jan Kratochvil 2116e53
@@ -460,6 +460,13 @@
Jan Kratochvil cec9297
 
Jan Kratochvil cec9297
   type = value_type (val);
Jan Kratochvil cec9297
 
Jan Kratochvil cec9297
+  if (TYPE_CODE (type) == TYPE_CODE_PTR)
Jan Kratochvil cec9297
+    if (is_dynamic_type (TYPE_TARGET_TYPE (type)))
Jan Kratochvil cec9297
+      {
Jan Kratochvil cec9297
+	val = value_addr (value_ind (val));
Jan Kratochvil cec9297
+	type = value_type (val);
Jan Kratochvil cec9297
+      }
Jan Kratochvil cec9297
+
Jan Kratochvil cec9297
   get_user_print_options (&opts);
Jan Kratochvil cec9297
   if (opts.objectprint)
Jan Kratochvil cec9297
     {
Jan Kratochvil 2116e53
Index: gdb-7.10.50.20160106/gdb/valarith.c
Jan Kratochvil b132e8a
===================================================================
Jan Kratochvil 2116e53
--- gdb-7.10.50.20160106.orig/gdb/valarith.c	2016-01-08 19:15:35.087582482 +0100
Jan Kratochvil 2116e53
+++ gdb-7.10.50.20160106/gdb/valarith.c	2016-01-08 19:15:44.985637691 +0100
Jan Kratochvil 2116e53
@@ -193,9 +193,21 @@
Jan Kratochvil cec9297
   struct type *array_type = check_typedef (value_type (array));
Jan Kratochvil cec9297
   struct type *elt_type = check_typedef (TYPE_TARGET_TYPE (array_type));
Jan Kratochvil 23f398e
   unsigned int elt_size = type_length_units (elt_type);
Jan Kratochvil cec9297
-  unsigned int elt_offs = elt_size * longest_to_int (index - lowerbound);
Jan Kratochvil cec9297
+  unsigned int elt_offs = longest_to_int (index - lowerbound);
Jan Kratochvil cec9297
+  LONGEST elt_stride = TYPE_BYTE_STRIDE (TYPE_INDEX_TYPE (array_type));
Jan Kratochvil cec9297
   struct value *v;
Jan Kratochvil cec9297
 
Jan Kratochvil cec9297
+  if (elt_stride > 0)
Jan Kratochvil cec9297
+    elt_offs *= elt_stride;
Jan Kratochvil cec9297
+  else if (elt_stride < 0)
Jan Kratochvil cec9297
+    {
Jan Kratochvil cec9297
+      int offs = (elt_offs + 1) * elt_stride;
Jan Kratochvil cec9297
+
Jan Kratochvil cec9297
+      elt_offs = TYPE_LENGTH (array_type) + offs;
Jan Kratochvil cec9297
+    }
Jan Kratochvil cec9297
+  else
Jan Kratochvil cec9297
+    elt_offs *= elt_size;
Jan Kratochvil cec9297
+
Jan Kratochvil cec9297
   if (index < lowerbound || (!TYPE_ARRAY_UPPER_BOUND_IS_UNDEFINED (array_type)
Jan Kratochvil 23f398e
 			     && elt_offs >= type_length_units (array_type)))
Jan Kratochvil 23f398e
     {
Jan Kratochvil 2116e53
Index: gdb-7.10.50.20160106/gdb/valprint.c
Jan Kratochvil b132e8a
===================================================================
Jan Kratochvil 2116e53
--- gdb-7.10.50.20160106.orig/gdb/valprint.c	2016-01-08 19:15:35.088582487 +0100
Jan Kratochvil 2116e53
+++ gdb-7.10.50.20160106/gdb/valprint.c	2016-01-08 19:15:44.986637697 +0100
Jan Kratochvil 2116e53
@@ -316,6 +316,18 @@
Jan Kratochvil 23f398e
       return 0;
Jan Kratochvil 23f398e
     }
Jan Kratochvil cec9297
 
Jan Kratochvil cec9297
+  if (TYPE_NOT_ASSOCIATED (type))
Jan Kratochvil cec9297
+    {
Jan Kratochvil cec9297
+      val_print_not_associated (stream);
Jan Kratochvil cec9297
+      return 0;
Jan Kratochvil cec9297
+    }
Jan Kratochvil cec9297
+
Jan Kratochvil cec9297
+  if (TYPE_NOT_ALLOCATED (type))
Jan Kratochvil cec9297
+    {
Jan Kratochvil cec9297
+      val_print_not_allocated (stream);
Jan Kratochvil cec9297
+      return 0;
Jan Kratochvil cec9297
+    }
Jan Kratochvil cec9297
+
Jan Kratochvil cec9297
   if (TYPE_CODE (type) != TYPE_CODE_UNION
Jan Kratochvil cec9297
       && TYPE_CODE (type) != TYPE_CODE_STRUCT
Jan Kratochvil cec9297
       && TYPE_CODE (type) != TYPE_CODE_ARRAY)
Jan Kratochvil 2116e53
@@ -1025,12 +1037,16 @@
Jan Kratochvil cec9297
 value_check_printable (struct value *val, struct ui_file *stream,
Jan Kratochvil cec9297
 		       const struct value_print_options *options)
Jan Kratochvil cec9297
 {
Jan Kratochvil cec9297
+  const struct type *type;
Jan Kratochvil cec9297
+
Jan Kratochvil cec9297
   if (val == 0)
Jan Kratochvil cec9297
     {
Jan Kratochvil cec9297
       fprintf_filtered (stream, _("<address of value unknown>"));
Jan Kratochvil cec9297
       return 0;
Jan Kratochvil cec9297
     }
Jan Kratochvil cec9297
 
Jan Kratochvil cec9297
+  type = value_type (val);
Jan Kratochvil cec9297
+
Jan Kratochvil cec9297
   if (value_entirely_optimized_out (val))
Jan Kratochvil cec9297
     {
Jan Kratochvil cec9297
       if (options->summary && !val_print_scalar_type_p (value_type (val)))
Jan Kratochvil 2116e53
@@ -1066,6 +1082,18 @@
Jan Kratochvil 23f398e
     {
Jan Kratochvil 23f398e
       val_print_not_allocated (stream);
Jan Kratochvil cec9297
       return 0;
Jan Kratochvil 23f398e
+    }
Jan Kratochvil 23f398e
+
Jan Kratochvil cec9297
+  if (TYPE_NOT_ASSOCIATED (type))
Jan Kratochvil cec9297
+    {
Jan Kratochvil cec9297
+      val_print_not_associated (stream);
Jan Kratochvil cec9297
+      return 0;
Jan Kratochvil cec9297
+    }
Jan Kratochvil cec9297
+
Jan Kratochvil cec9297
+  if (TYPE_NOT_ALLOCATED (type))
Jan Kratochvil cec9297
+    {
Jan Kratochvil cec9297
+      val_print_not_allocated (stream);
Jan Kratochvil cec9297
+      return 0;
Jan Kratochvil 23f398e
     }
Jan Kratochvil cec9297
 
Jan Kratochvil 23f398e
   return 1;
Jan Kratochvil 2116e53
Index: gdb-7.10.50.20160106/gdb/valprint.h
Jan Kratochvil b132e8a
===================================================================
Jan Kratochvil 2116e53
--- gdb-7.10.50.20160106.orig/gdb/valprint.h	2016-01-08 19:15:35.088582487 +0100
Jan Kratochvil 2116e53
+++ gdb-7.10.50.20160106/gdb/valprint.h	2016-01-08 19:15:44.986637697 +0100
Jan Kratochvil 2116e53
@@ -232,4 +232,8 @@
Jan Kratochvil 32f92b2
 					struct format_data *fmtp);
Jan Kratochvil 32f92b2
 extern void print_value (struct value *val, const struct format_data *fmtp);
Jan Kratochvil cec9297
 
Jan Kratochvil cec9297
+extern void val_print_not_allocated (struct ui_file *stream);
Jan Kratochvil cec9297
+
Jan Kratochvil cec9297
+extern void val_print_not_associated (struct ui_file *stream);
Jan Kratochvil cec9297
+
Jan Kratochvil cec9297
 #endif
Jan Kratochvil 2116e53
Index: gdb-7.10.50.20160106/gdb/value.c
Jan Kratochvil b132e8a
===================================================================
Jan Kratochvil 2116e53
--- gdb-7.10.50.20160106.orig/gdb/value.c	2016-01-08 19:15:35.090582499 +0100
Jan Kratochvil 2116e53
+++ gdb-7.10.50.20160106/gdb/value.c	2016-01-08 19:15:44.987637702 +0100
Jan Kratochvil 2f7f533
@@ -40,6 +40,7 @@
Jan Kratochvil cec9297
 #include "tracepoint.h"
Jan Kratochvil cec9297
 #include "cp-abi.h"
Jan Kratochvil cec9297
 #include "user-regs.h"
Jan Kratochvil cec9297
+#include "dwarf2loc.h"
Jan Kratochvil cec9297
 
Jan Kratochvil cec9297
 /* Prototypes for exported functions.  */
Jan Kratochvil cec9297
 
Jan Kratochvil 2116e53
@@ -1788,6 +1789,25 @@
Jan Kratochvil cec9297
       if (funcs->copy_closure)
Jan Kratochvil cec9297
         component->location.computed.closure = funcs->copy_closure (whole);
Jan Kratochvil cec9297
     }
Jan Kratochvil cec9297
+
Jan Kratochvil cec9297
+  /* For dynamic types compute the address of the component value location in
Jan Kratochvil cec9297
+     sub range types based on the location of the sub range type, if not being
Jan Kratochvil cec9297
+     an internal GDB variable or parts of it.  */
Jan Kratochvil cec9297
+  if (VALUE_LVAL (component) != lval_internalvar
Jan Kratochvil cec9297
+      && VALUE_LVAL (component) != lval_internalvar_component)
Jan Kratochvil cec9297
+    {
Jan Kratochvil cec9297
+      CORE_ADDR addr;
Jan Kratochvil cec9297
+      struct type *type = value_type (whole);
Jan Kratochvil cec9297
+
Jan Kratochvil cec9297
+      addr = value_raw_address (component);
Jan Kratochvil cec9297
+
Jan Kratochvil cec9297
+      if (TYPE_DATA_LOCATION (type)
Jan Kratochvil cec9297
+          && TYPE_DATA_LOCATION_KIND (type) == PROP_CONST)
Jan Kratochvil cec9297
+        {
Jan Kratochvil cec9297
+          addr = TYPE_DATA_LOCATION_ADDR (type);
Jan Kratochvil cec9297
+          set_value_address (component, addr);
Jan Kratochvil cec9297
+        }
Jan Kratochvil cec9297
+    }
Jan Kratochvil cec9297
 }
Jan Kratochvil cec9297
 
Jan Kratochvil cec9297
 
Jan Kratochvil 2116e53
@@ -3095,13 +3115,22 @@
Jan Kratochvil cec9297
 	v = allocate_value_lazy (type);
Jan Kratochvil cec9297
       else
Jan Kratochvil cec9297
 	{
Jan Kratochvil cec9297
-	  v = allocate_value (type);
Jan Kratochvil cec9297
-	  value_contents_copy_raw (v, value_embedded_offset (v),
Jan Kratochvil cec9297
-				   arg1, value_embedded_offset (arg1) + offset,
Jan Kratochvil 23f398e
-				   type_length_units (type));
Jan Kratochvil cec9297
+	  if (TYPE_DATA_LOCATION (type)
Jan Kratochvil cec9297
+	      && TYPE_DATA_LOCATION_KIND (type) == PROP_CONST)
Jan Kratochvil cec9297
+	    v = value_at_lazy (type, value_address (arg1) + offset);
Jan Kratochvil cec9297
+	  else
Jan Kratochvil cec9297
+	    {
Jan Kratochvil cec9297
+	      v = allocate_value (type);
Jan Kratochvil cec9297
+	      value_contents_copy_raw (v, value_embedded_offset (v),
Jan Kratochvil cec9297
+				       arg1, value_embedded_offset (arg1) + offset,
Jan Kratochvil 23f398e
+				       type_length_units (type));
Jan Kratochvil cec9297
+	    }
Jan Kratochvil cec9297
 	}
Jan Kratochvil cec9297
-      v->offset = (value_offset (arg1) + offset
Jan Kratochvil cec9297
-		   + value_embedded_offset (arg1));
Jan Kratochvil cec9297
+
Jan Kratochvil cec9297
+      if (!TYPE_DATA_LOCATION (type)
Jan Kratochvil cec9297
+          || !TYPE_DATA_LOCATION_KIND (type) == PROP_CONST)
Jan Kratochvil cec9297
+	v->offset = (value_offset (arg1) + offset
Jan Kratochvil cec9297
+		     + value_embedded_offset (arg1));
Jan Kratochvil cec9297
     }
Jan Kratochvil cec9297
   set_value_component_location (v, arg1);
Jan Kratochvil cec9297
   VALUE_REGNUM (v) = VALUE_REGNUM (arg1);
Jan Kratochvil 2116e53
@@ -3689,7 +3718,8 @@
Jan Kratochvil cec9297
 			      struct value *original_value)
Jan Kratochvil cec9297
 {
Jan Kratochvil cec9297
   /* Re-adjust type.  */
Jan Kratochvil cec9297
-  deprecated_set_value_type (value, TYPE_TARGET_TYPE (original_type));
Jan Kratochvil cec9297
+  if (!is_dynamic_type (TYPE_TARGET_TYPE (original_type)))
Jan Kratochvil cec9297
+    deprecated_set_value_type (value, TYPE_TARGET_TYPE (original_type));
Jan Kratochvil cec9297
 
Jan Kratochvil cec9297
   /* Add embedding info.  */
Jan Kratochvil cec9297
   set_value_enclosing_type (value, enc_type);
Jan Kratochvil 2116e53
@@ -3706,6 +3736,12 @@
Jan Kratochvil cec9297
   struct value *retval;
Jan Kratochvil cec9297
   struct type *enc_type;
Jan Kratochvil cec9297
 
Jan Kratochvil cec9297
+  if (current_language->la_language != language_fortran
Jan Kratochvil cec9297
+      && TYPE_DATA_LOCATION (value_type_arg_tmp) != NULL
Jan Kratochvil cec9297
+      && TYPE_DATA_LOCATION_KIND (value_type_arg_tmp) == PROP_CONST)
Jan Kratochvil cec9297
+    arg = value_at_lazy (value_type_arg_tmp,
Jan Kratochvil cec9297
+                         TYPE_DATA_LOCATION_ADDR (value_type_arg_tmp));
Jan Kratochvil cec9297
+
Jan Kratochvil cec9297
   retval = coerce_ref_if_computed (arg);
Jan Kratochvil cec9297
   if (retval)
Jan Kratochvil cec9297
     return retval;
Jan Kratochvil 2116e53
@@ -3834,8 +3870,14 @@
Jan Kratochvil cec9297
     }
Jan Kratochvil cec9297
   else if (VALUE_LVAL (val) == lval_memory)
Jan Kratochvil cec9297
     {
Jan Kratochvil cec9297
-      CORE_ADDR addr = value_address (val);
Jan Kratochvil cec9297
       struct type *type = check_typedef (value_enclosing_type (val));
Jan Kratochvil cec9297
+      CORE_ADDR addr;
Jan Kratochvil cec9297
+
Jan Kratochvil cec9297
+      if (TYPE_DATA_LOCATION (type) != NULL
Jan Kratochvil cec9297
+	  && TYPE_DATA_LOCATION_KIND (type) == PROP_CONST)
Jan Kratochvil cec9297
+	addr = TYPE_DATA_LOCATION_ADDR (type);
Jan Kratochvil cec9297
+      else
Jan Kratochvil cec9297
+	addr = value_address (val);
Jan Kratochvil cec9297
 
Jan Kratochvil cec9297
       if (TYPE_LENGTH (type))
Jan Kratochvil cec9297
 	read_value_memory (val, 0, value_stack (val),
Jan Kratochvil 2116e53
Index: gdb-7.10.50.20160106/gdb/dwarf2loc.c
Jan Kratochvil 2f7f533
===================================================================
Jan Kratochvil 2116e53
--- gdb-7.10.50.20160106.orig/gdb/dwarf2loc.c	2016-01-08 19:15:35.091582504 +0100
Jan Kratochvil 2116e53
+++ gdb-7.10.50.20160106/gdb/dwarf2loc.c	2016-01-08 19:15:44.988637708 +0100
Jan Kratochvil 2116e53
@@ -2368,6 +2368,11 @@
Jan Kratochvil 2116e53
 	    address = value_as_address (value_from_pointer (ptr_type, address));
Jan Kratochvil 2f7f533
 
Jan Kratochvil 2f7f533
 	    do_cleanups (value_chain);
Jan Kratochvil 2f7f533
+
Jan Kratochvil 2f7f533
+	    /* Select right frame to correctly evaluate VLA's during a backtrace.  */
Jan Kratochvil 2f7f533
+	    if (is_dynamic_type (type))
Jan Kratochvil 2f7f533
+	      select_frame (frame);
Jan Kratochvil 2f7f533
+
Jan Kratochvil 2f7f533
 	    retval = value_at_lazy (type, address + byte_offset);
Jan Kratochvil 2f7f533
 	    if (in_stack_memory)
Jan Kratochvil 2f7f533
 	      set_value_stack (retval, 1);
Jan Kratochvil 2116e53
@@ -2660,6 +2665,19 @@
Jan Kratochvil 2f7f533
 			     data, data + size, per_cu);
Jan Kratochvil 2f7f533
 }
Jan Kratochvil 2f7f533
 
Jan Kratochvil 2f7f533
+/* See dwarf2loc.h.  */
Jan Kratochvil 2f7f533
+
Jan Kratochvil 2f7f533
+int
Jan Kratochvil 2f7f533
+dwarf2_address_data_valid (const struct type *type)
Jan Kratochvil 2f7f533
+{
Jan Kratochvil 2f7f533
+  if (TYPE_NOT_ASSOCIATED (type))
Jan Kratochvil 2f7f533
+    return 0;
Jan Kratochvil 2f7f533
+
Jan Kratochvil 2f7f533
+  if (TYPE_NOT_ALLOCATED (type))
Jan Kratochvil 2f7f533
+    return 0;
Jan Kratochvil 2f7f533
+
Jan Kratochvil 2f7f533
+  return 1;
Jan Kratochvil 2f7f533
+}
Jan Kratochvil 2f7f533
 
Jan Kratochvil 2f7f533
 /* Helper functions and baton for dwarf2_loc_desc_needs_frame.  */
Jan Kratochvil 2f7f533