keiths / rpms / gdb

Forked from rpms/gdb 12 days ago
Clone
a8767b3
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
f524ac5
From: Fedora GDB patches <invalid@email.com>
f524ac5
Date: Fri, 27 Oct 2017 21:07:50 +0200
f524ac5
Subject: gdb-vla-intel-fortran-vla-strings.patch
f524ac5
f637971
;;=push
f637971
Jan Kratochvil d258670
git diff --stat -p gdb/master...gdb/users/bheckel/fortran-vla-strings
Jan Kratochvil d258670
0ad7d8d1a3a36c6e04e3b6d37d8825f18d595723
Jan Kratochvil d258670
Jan Kratochvil d258670
 gdb/NEWS                                  |   2 +
Jan Kratochvil d258670
 gdb/c-valprint.c                          |  22 +++++
Jan Kratochvil d258670
 gdb/dwarf2read.c                          | 158 +++++++++++++++++++++++++-----
Jan Kratochvil d258670
 gdb/f-typeprint.c                         |  93 +++++++++---------
Jan Kratochvil d258670
 gdb/gdbtypes.c                            |  44 ++++++++-
Jan Kratochvil d258670
 gdb/testsuite/gdb.cp/vla-cxx.cc           |   9 ++
Jan Kratochvil d258670
 gdb/testsuite/gdb.cp/vla-cxx.exp          |   9 ++
Jan Kratochvil d258670
 gdb/testsuite/gdb.fortran/pointers.exp    | 143 +++++++++++++++++++++++++++
Jan Kratochvil d258670
 gdb/testsuite/gdb.fortran/pointers.f90    | 109 +++++++++++++++++++++
Jan Kratochvil d258670
 gdb/testsuite/gdb.fortran/print_type.exp  | 100 +++++++++++++++++++
Jan Kratochvil d258670
 gdb/testsuite/gdb.fortran/vla-ptype.exp   |  12 +--
Jan Kratochvil d258670
 gdb/testsuite/gdb.fortran/vla-strings.exp | 103 +++++++++++++++++++
Jan Kratochvil d258670
 gdb/testsuite/gdb.fortran/vla-strings.f90 |  39 ++++++++
Jan Kratochvil d258670
 gdb/testsuite/gdb.fortran/vla-type.exp    |   7 +-
Jan Kratochvil d258670
 gdb/testsuite/gdb.fortran/vla-value.exp   |  12 ++-
Jan Kratochvil d258670
 gdb/testsuite/gdb.mi/mi-var-child-f.exp   |   7 +-
Jan Kratochvil d258670
 gdb/testsuite/gdb.mi/mi-vla-fortran.exp   |  27 ++---
Jan Kratochvil d258670
 gdb/typeprint.c                           |  19 ++++
Jan Kratochvil d258670
 gdb/valops.c                              |  16 ++-
Jan Kratochvil d258670
 gdb/valprint.c                            |   6 --
Jan Kratochvil d258670
 20 files changed, 827 insertions(+), 110 deletions(-)
Jan Kratochvil d258670
f637971
diff --git a/gdb/NEWS b/gdb/NEWS
f637971
--- a/gdb/NEWS
f637971
+++ b/gdb/NEWS
8ac0647
@@ -660,6 +660,8 @@ SH-5/SH64 running OpenBSD 	SH-5/SH64 support in sh*-*-openbsd*
6f7202e
 
6f7202e
 *** Changes in GDB 8.1
Jan Kratochvil d258670
 
Jan Kratochvil d258670
+* Fortran: Support pointers to dynamic types.
Jan Kratochvil d258670
+
c42f029
 * GDB now supports dynamically creating arbitrary register groups specified
6f7202e
   in XML target descriptions.  This allows for finer grain grouping of
6f7202e
   registers on systems with a large amount of registers.
f637971
diff --git a/gdb/c-valprint.c b/gdb/c-valprint.c
f637971
--- a/gdb/c-valprint.c
f637971
+++ b/gdb/c-valprint.c
e90857f
@@ -651,6 +651,28 @@ c_value_print (struct value *val, struct ui_file *stream,
Jan Kratochvil d258670
       else
Jan Kratochvil d258670
 	{
Jan Kratochvil d258670
 	  /* normal case */
Jan Kratochvil d258670
+	  if (TYPE_CODE (type) == TYPE_CODE_PTR
Jan Kratochvil d258670
+	      && 1 == is_dynamic_type (type))
Jan Kratochvil d258670
+	    {
Jan Kratochvil d258670
+	      CORE_ADDR addr;
Jan Kratochvil d258670
+	      if (NULL != TYPE_DATA_LOCATION (TYPE_TARGET_TYPE (type)))
Jan Kratochvil d258670
+		addr = value_address (val);
Jan Kratochvil d258670
+	      else
Jan Kratochvil d258670
+		addr = value_as_address (val);
Jan Kratochvil d258670
+
Jan Kratochvil d258670
+	      /* We resolve the target-type only when the
Jan Kratochvil d258670
+	         pointer is associated.  */
Jan Kratochvil d258670
+	      if ((addr != 0)
Jan Kratochvil d258670
+		  && (0 == type_not_associated (type)))
Jan Kratochvil d258670
+		  TYPE_TARGET_TYPE (type) =
Jan Kratochvil d258670
+		      resolve_dynamic_type (TYPE_TARGET_TYPE (type),
Jan Kratochvil d258670
+					    NULL, addr);
Jan Kratochvil d258670
+	    }
Jan Kratochvil d258670
+	  else
Jan Kratochvil d258670
+	    {
Jan Kratochvil d258670
+	      /* Do nothing. References are already resolved from the beginning,
Jan Kratochvil d258670
+	         only pointers are resolved when we actual need the target.  */
Jan Kratochvil d258670
+	    }
Jan Kratochvil d258670
 	  fprintf_filtered (stream, "(");
Jan Kratochvil d258670
 	  type_print (value_type (val), "", stream, -1);
Jan Kratochvil d258670
 	  fprintf_filtered (stream, ") ");
f637971
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
f637971
--- a/gdb/dwarf2read.c
f637971
+++ b/gdb/dwarf2read.c
f7760f8
@@ -1810,7 +1810,10 @@ static void read_signatured_type (struct signatured_type *);
Jan Kratochvil d258670
 
Jan Kratochvil d258670
 static int attr_to_dynamic_prop (const struct attribute *attr,
Jan Kratochvil d258670
 				 struct die_info *die, struct dwarf2_cu *cu,
f7760f8
-				 struct dynamic_prop *prop, struct type *type);
f7760f8
+				 struct dynamic_prop *prop,
f7760f8
+				 struct type *default_type,
f7760f8
+				 const gdb_byte *additional_data,
Jan Kratochvil d258670
+				 int additional_data_size);
Jan Kratochvil d258670
 
Jan Kratochvil d258670
 /* memory allocation interface */
Jan Kratochvil d258670
 
9c37e8a
@@ -13661,7 +13664,7 @@ read_func_scope (struct die_info *die, struct dwarf2_cu *cu)
Jan Kratochvil d258670
       newobj->static_link
Jan Kratochvil d258670
 	= XOBNEW (&objfile->objfile_obstack, struct dynamic_prop);
f7760f8
       attr_to_dynamic_prop (attr, die, cu, newobj->static_link,
f7760f8
-			    dwarf2_per_cu_addr_type (cu->per_cu));
f7760f8
+			    dwarf2_per_cu_addr_type (cu->per_cu), NULL, 0);
Jan Kratochvil d258670
     }
Jan Kratochvil d258670
 
31f5b96
   cu->list_in_scope = cu->get_builder ()->get_local_symbols ();
9c37e8a
@@ -16423,7 +16426,7 @@ read_array_type (struct die_info *die, struct dwarf2_cu *cu)
c42f029
       byte_stride_prop
c42f029
 	= (struct dynamic_prop *) alloca (sizeof (struct dynamic_prop));
f7760f8
       stride_ok = attr_to_dynamic_prop (attr, die, cu, byte_stride_prop,
f7760f8
-					prop_type);
f7760f8
+					prop_type, NULL, 0);
c42f029
       if (!stride_ok)
c42f029
 	{
9e41188
 	  complaint (_("unable to read array DW_AT_byte_stride "
9c37e8a
@@ -17181,29 +17184,90 @@ read_tag_string_type (struct die_info *die, struct dwarf2_cu *cu)
Jan Kratochvil d258670
   struct gdbarch *gdbarch = get_objfile_arch (objfile);
Jan Kratochvil d258670
   struct type *type, *range_type, *index_type, *char_type;
Jan Kratochvil d258670
   struct attribute *attr;
Jan Kratochvil d258670
-  unsigned int length;
Jan Kratochvil d258670
+  unsigned int length = UINT_MAX;
f637971
+
Jan Kratochvil d258670
+  index_type = objfile_type (objfile)->builtin_int;
Jan Kratochvil d258670
+  range_type = create_static_range_type (NULL, index_type, 1, length);
f637971
 
Jan Kratochvil d258670
+  /* If DW_AT_string_length is defined, the length is stored in memory.  */
Jan Kratochvil d258670
   attr = dwarf2_attr (die, DW_AT_string_length, cu);
Jan Kratochvil d258670
   if (attr)
Jan Kratochvil d258670
     {
Jan Kratochvil d258670
-      length = DW_UNSND (attr);
Jan Kratochvil d258670
+      if (attr_form_is_block (attr))
Jan Kratochvil d258670
+	{
Jan Kratochvil d258670
+	  struct attribute *byte_size, *bit_size;
Jan Kratochvil d258670
+	  struct dynamic_prop high;
Jan Kratochvil d258670
+
Jan Kratochvil d258670
+	  byte_size = dwarf2_attr (die, DW_AT_byte_size, cu);
Jan Kratochvil d258670
+	  bit_size = dwarf2_attr (die, DW_AT_bit_size, cu);
Jan Kratochvil d258670
+
Jan Kratochvil d258670
+	  /* DW_AT_byte_size should never occur in combination with
Jan Kratochvil d258670
+	     DW_AT_bit_size.  */
Jan Kratochvil d258670
+	  if (byte_size != NULL && bit_size != NULL)
9e41188
+	    complaint (_("DW_AT_byte_size AND "
Jan Kratochvil d258670
+			 "DW_AT_bit_size found together at the same time."));
Jan Kratochvil d258670
+
Jan Kratochvil d258670
+	  /* If DW_AT_string_length AND DW_AT_byte_size exist together,
Jan Kratochvil d258670
+	     DW_AT_byte_size describes the number of bytes that should be read
Jan Kratochvil d258670
+	     from the length memory location.  */
Jan Kratochvil d258670
+	  if (byte_size != NULL)
Jan Kratochvil d258670
+	    {
Jan Kratochvil d258670
+	      /* Build new dwarf2_locexpr_baton structure with additions to the
Jan Kratochvil d258670
+		 data attribute, to reflect DWARF specialities to get address
Jan Kratochvil d258670
+		 sizes.  */
Jan Kratochvil d258670
+	      const gdb_byte append_ops[] =
Jan Kratochvil d258670
+		{
Jan Kratochvil d258670
+		/* DW_OP_deref_size: size of an address on the target machine
Jan Kratochvil d258670
+		   (bytes), where the size will be specified by the next
Jan Kratochvil d258670
+		   operand.  */
Jan Kratochvil d258670
+		DW_OP_deref_size,
Jan Kratochvil d258670
+		/* Operand for DW_OP_deref_size.  */
0702d0d
+		(gdb_byte) DW_UNSND(byte_size) };
Jan Kratochvil d258670
+
f7760f8
+	      if (!attr_to_dynamic_prop (attr, die, cu, &high, index_type,
f7760f8
+					 append_ops, ARRAY_SIZE(append_ops)))
9e41188
+		complaint (_("Could not parse DW_AT_byte_size"));
Jan Kratochvil d258670
+	    }
Jan Kratochvil d258670
+	  else if (bit_size != NULL)
9e41188
+	    complaint (_("DW_AT_string_length AND "
Jan Kratochvil d258670
+			 "DW_AT_bit_size found but not supported yet."));
Jan Kratochvil d258670
+	  /* If DW_AT_string_length WITHOUT DW_AT_byte_size exist, the default
Jan Kratochvil d258670
+	     is the address size of the target machine.  */
Jan Kratochvil d258670
+	  else
Jan Kratochvil d258670
+	    {
Jan Kratochvil d258670
+	      const gdb_byte append_ops[] =
Jan Kratochvil d258670
+		{ DW_OP_deref };
Jan Kratochvil d258670
+
f7760f8
+	      if (!attr_to_dynamic_prop (attr, die, cu, &high, index_type,
f7760f8
+					 append_ops, ARRAY_SIZE(append_ops)))
9e41188
+		complaint (_("Could not parse DW_AT_string_length"));
Jan Kratochvil d258670
+	    }
Jan Kratochvil d258670
+
Jan Kratochvil d258670
+	  TYPE_RANGE_DATA (range_type)->high = high;
Jan Kratochvil d258670
+	}
Jan Kratochvil d258670
+      else
Jan Kratochvil d258670
+	{
Jan Kratochvil d258670
+	  TYPE_HIGH_BOUND (range_type) = DW_UNSND(attr);
Jan Kratochvil d258670
+	  TYPE_HIGH_BOUND_KIND (range_type) = PROP_CONST;
Jan Kratochvil d258670
+	}
Jan Kratochvil d258670
     }
Jan Kratochvil d258670
   else
Jan Kratochvil d258670
     {
Jan Kratochvil d258670
-      /* Check for the DW_AT_byte_size attribute.  */
Jan Kratochvil d258670
+      /* Check for the DW_AT_byte_size attribute, which represents the length
Jan Kratochvil d258670
+	 in this case.  */
Jan Kratochvil d258670
       attr = dwarf2_attr (die, DW_AT_byte_size, cu);
Jan Kratochvil d258670
       if (attr)
Jan Kratochvil d258670
-        {
Jan Kratochvil d258670
-          length = DW_UNSND (attr);
Jan Kratochvil d258670
-        }
Jan Kratochvil d258670
+	{
Jan Kratochvil d258670
+	  TYPE_HIGH_BOUND (range_type) = DW_UNSND(attr);
Jan Kratochvil d258670
+	  TYPE_HIGH_BOUND_KIND (range_type) = PROP_CONST;
Jan Kratochvil d258670
+	}
Jan Kratochvil d258670
       else
Jan Kratochvil d258670
-        {
Jan Kratochvil d258670
-          length = 1;
Jan Kratochvil d258670
-        }
Jan Kratochvil d258670
+	{
Jan Kratochvil d258670
+	  TYPE_HIGH_BOUND (range_type) = 1;
Jan Kratochvil d258670
+	  TYPE_HIGH_BOUND_KIND (range_type) = PROP_CONST;
Jan Kratochvil d258670
+	}
Jan Kratochvil d258670
     }
Jan Kratochvil d258670
 
Jan Kratochvil d258670
-  index_type = objfile_type (objfile)->builtin_int;
Jan Kratochvil d258670
-  range_type = create_static_range_type (NULL, index_type, 1, length);
Jan Kratochvil d258670
   char_type = language_string_char_type (cu->language_defn, gdbarch);
Jan Kratochvil d258670
   type = create_string_type (NULL, char_type, range_type);
Jan Kratochvil d258670
 
9c37e8a
@@ -17636,7 +17700,8 @@ read_base_type (struct die_info *die, struct dwarf2_cu *cu)
Jan Kratochvil d258670
 static int
Jan Kratochvil d258670
 attr_to_dynamic_prop (const struct attribute *attr, struct die_info *die,
f7760f8
 		      struct dwarf2_cu *cu, struct dynamic_prop *prop,
f7760f8
-		      struct type *default_type)
f7760f8
+		      struct type *default_type,
Jan Kratochvil d258670
+		      const gdb_byte *additional_data, int additional_data_size)
Jan Kratochvil d258670
 {
Jan Kratochvil d258670
   struct dwarf2_property_baton *baton;
2bcd68d
   struct obstack *obstack
9c37e8a
@@ -17655,9 +17720,30 @@ attr_to_dynamic_prop (const struct attribute *attr, struct die_info *die,
f7760f8
       baton->locexpr.size = DW_BLOCK (attr)->size;
f7760f8
       baton->locexpr.data = DW_BLOCK (attr)->data;
f7760f8
       baton->locexpr.is_reference = false;
Jan Kratochvil d258670
+
Jan Kratochvil d258670
+      if (additional_data != NULL && additional_data_size > 0)
Jan Kratochvil d258670
+	{
Jan Kratochvil d258670
+	  gdb_byte *data;
Jan Kratochvil d258670
+
Jan Kratochvil d258670
+	  data = (gdb_byte *) obstack_alloc(
2bcd68d
+	      &cu->per_cu->dwarf2_per_objfile->objfile->objfile_obstack,
Jan Kratochvil d258670
+	      DW_BLOCK (attr)->size + additional_data_size);
Jan Kratochvil d258670
+	  memcpy (data, DW_BLOCK (attr)->data, DW_BLOCK (attr)->size);
Jan Kratochvil d258670
+	  memcpy (data + DW_BLOCK (attr)->size, additional_data,
Jan Kratochvil d258670
+		  additional_data_size);
Jan Kratochvil d258670
+
Jan Kratochvil d258670
+	  baton->locexpr.data = data;
Jan Kratochvil d258670
+	  baton->locexpr.size = DW_BLOCK (attr)->size + additional_data_size;
Jan Kratochvil d258670
+	}
Jan Kratochvil d258670
+      else
Jan Kratochvil d258670
+	{
Jan Kratochvil d258670
+	  baton->locexpr.data = DW_BLOCK (attr)->data;
Jan Kratochvil d258670
+	  baton->locexpr.size = DW_BLOCK (attr)->size;
Jan Kratochvil d258670
+	}
Jan Kratochvil d258670
+
Jan Kratochvil d258670
       prop->data.baton = baton;
Jan Kratochvil d258670
       prop->kind = PROP_LOCEXPR;
Jan Kratochvil d258670
-      gdb_assert (prop->data.baton != NULL);
Jan Kratochvil d258670
+      gdb_assert(prop->data.baton != NULL);
Jan Kratochvil d258670
     }
Jan Kratochvil d258670
   else if (attr_form_is_ref (attr))
Jan Kratochvil d258670
     {
9c37e8a
@@ -17690,9 +17776,29 @@ attr_to_dynamic_prop (const struct attribute *attr, struct die_info *die,
Jan Kratochvil d258670
 		baton = XOBNEW (obstack, struct dwarf2_property_baton);
f7760f8
 		baton->property_type = die_type (target_die, target_cu);
Jan Kratochvil d258670
 		baton->locexpr.per_cu = cu->per_cu;
Jan Kratochvil d258670
-		baton->locexpr.size = DW_BLOCK (target_attr)->size;
Jan Kratochvil d258670
-		baton->locexpr.data = DW_BLOCK (target_attr)->data;
f7760f8
 		baton->locexpr.is_reference = true;
Jan Kratochvil d258670
+
Jan Kratochvil d258670
+		if (additional_data != NULL && additional_data_size > 0)
Jan Kratochvil d258670
+		  {
Jan Kratochvil d258670
+		    gdb_byte *data;
Jan Kratochvil d258670
+
2bcd68d
+		    data = (gdb_byte *) obstack_alloc (&cu->per_cu->dwarf2_per_objfile->objfile->objfile_obstack,
Jan Kratochvil d258670
+			    DW_BLOCK (target_attr)->size + additional_data_size);
Jan Kratochvil d258670
+		    memcpy (data, DW_BLOCK (target_attr)->data,
Jan Kratochvil d258670
+			    DW_BLOCK (target_attr)->size);
Jan Kratochvil d258670
+		    memcpy (data + DW_BLOCK (target_attr)->size,
Jan Kratochvil d258670
+			    additional_data, additional_data_size);
Jan Kratochvil d258670
+
Jan Kratochvil d258670
+		    baton->locexpr.data = data;
Jan Kratochvil d258670
+		    baton->locexpr.size = (DW_BLOCK (target_attr)->size
Jan Kratochvil d258670
+					   + additional_data_size);
Jan Kratochvil d258670
+		  }
Jan Kratochvil d258670
+		else
Jan Kratochvil d258670
+		  {
Jan Kratochvil d258670
+		    baton->locexpr.data = DW_BLOCK (target_attr)->data;
Jan Kratochvil d258670
+		    baton->locexpr.size = DW_BLOCK (target_attr)->size;
Jan Kratochvil d258670
+		  }
Jan Kratochvil d258670
+
Jan Kratochvil d258670
 		prop->data.baton = baton;
Jan Kratochvil d258670
 		prop->kind = PROP_LOCEXPR;
Jan Kratochvil d258670
 		gdb_assert (prop->data.baton != NULL);
9c37e8a
@@ -17862,7 +17968,8 @@ read_subrange_type (struct die_info *die, struct dwarf2_cu *cu)
Jan Kratochvil d258670
 
Jan Kratochvil d258670
   attr = dwarf2_attr (die, DW_AT_byte_stride, cu);
Jan Kratochvil d258670
   if (attr)
f7760f8
-    if (!attr_to_dynamic_prop (attr, die, cu, &stride, base_type))
f7760f8
+    if (!attr_to_dynamic_prop (attr, die, cu, &stride, base_type,
f7760f8
+			       NULL, 0))
9e41188
         complaint (_("Missing DW_AT_byte_stride "
9e41188
 		     "- DIE at 0x%s [in module %s]"),
2bcd68d
 		   sect_offset_str (die->sect_off),
9c37e8a
@@ -17870,7 +17977,7 @@ read_subrange_type (struct die_info *die, struct dwarf2_cu *cu)
Jan Kratochvil d258670
 
Jan Kratochvil d258670
   attr = dwarf2_attr (die, DW_AT_lower_bound, cu);
Jan Kratochvil d258670
   if (attr)
f7760f8
-    attr_to_dynamic_prop (attr, die, cu, &low, base_type);
f7760f8
+    attr_to_dynamic_prop (attr, die, cu, &low, base_type, NULL, 0);
Jan Kratochvil d258670
   else if (!low_default_is_valid)
9e41188
     complaint (_("Missing DW_AT_lower_bound "
2bcd68d
 				      "- DIE at %s [in module %s]"),
9c37e8a
@@ -17879,10 +17986,10 @@ read_subrange_type (struct die_info *die, struct dwarf2_cu *cu)
Jan Kratochvil d258670
 
0702d0d
   struct attribute *attr_ub, *attr_count;
0702d0d
   attr = attr_ub = dwarf2_attr (die, DW_AT_upper_bound, cu);
f7760f8
-  if (!attr_to_dynamic_prop (attr, die, cu, &high, base_type))
f7760f8
+  if (!attr_to_dynamic_prop (attr, die, cu, &high, base_type, NULL, 0))
Jan Kratochvil d258670
     {
0702d0d
       attr = attr_count = dwarf2_attr (die, DW_AT_count, cu);
f7760f8
-      if (attr_to_dynamic_prop (attr, die, cu, &high, base_type))
f7760f8
+      if (attr_to_dynamic_prop (attr, die, cu, &high, base_type, NULL, 0))
Jan Kratochvil d258670
 	{
Jan Kratochvil d258670
 	  /* If bounds are constant do the final calculation here.  */
Jan Kratochvil d258670
 	  if (low.kind == PROP_CONST && high.kind == PROP_CONST)
9c37e8a
@@ -25528,7 +25635,7 @@ set_die_type (struct die_info *die, struct type *type, struct dwarf2_cu *cu)
Jan Kratochvil d258670
     {
f7760f8
       struct type *prop_type
f7760f8
 	= dwarf2_per_cu_addr_sized_int_type (cu->per_cu, false);
f7760f8
-      if (attr_to_dynamic_prop (attr, die, cu, &prop, prop_type))
f7760f8
+      if (attr_to_dynamic_prop (attr, die, cu, &prop, prop_type, NULL, 0))
2bcd68d
         add_dyn_prop (DYN_PROP_ALLOCATED, prop, type);
Jan Kratochvil d258670
     }
Jan Kratochvil d258670
   else if (attr != NULL)
9c37e8a
@@ -25544,7 +25651,7 @@ set_die_type (struct die_info *die, struct type *type, struct dwarf2_cu *cu)
Jan Kratochvil d258670
     {
f7760f8
       struct type *prop_type
f7760f8
 	= dwarf2_per_cu_addr_sized_int_type (cu->per_cu, false);
f7760f8
-      if (attr_to_dynamic_prop (attr, die, cu, &prop, prop_type))
f7760f8
+      if (attr_to_dynamic_prop (attr, die, cu, &prop, prop_type, NULL, 0))
2bcd68d
         add_dyn_prop (DYN_PROP_ASSOCIATED, prop, type);
Jan Kratochvil d258670
     }
Jan Kratochvil d258670
   else if (attr != NULL)
9c37e8a
@@ -25557,7 +25664,7 @@ set_die_type (struct die_info *die, struct type *type, struct dwarf2_cu *cu)
Jan Kratochvil d258670
   /* Read DW_AT_data_location and set in type.  */
Jan Kratochvil d258670
   attr = dwarf2_attr (die, DW_AT_data_location, cu);
f7760f8
   if (attr_to_dynamic_prop (attr, die, cu, &prop,
f7760f8
-			    dwarf2_per_cu_addr_type (cu->per_cu)))
f7760f8
+			    dwarf2_per_cu_addr_type (cu->per_cu), NULL, 0))
2bcd68d
     add_dyn_prop (DYN_PROP_DATA_LOCATION, prop, type);
Jan Kratochvil d258670
 
Jan Kratochvil d258670
   if (dwarf2_per_objfile->die_type_hash == NULL)
f637971
diff --git a/gdb/f-typeprint.c b/gdb/f-typeprint.c
f637971
--- a/gdb/f-typeprint.c
f637971
+++ b/gdb/f-typeprint.c
292cb41
@@ -186,15 +186,14 @@ f_type_print_varspec_suffix (struct type *type, struct ui_file *stream,
292cb41
 	print_rank_only = true;
292cb41
       else if ((TYPE_ASSOCIATED_PROP (type)
292cb41
 		&& PROP_CONST != TYPE_DYN_PROP_KIND (TYPE_ASSOCIATED_PROP (type)))
292cb41
-	       || (TYPE_ALLOCATED_PROP (type)
292cb41
-		   && PROP_CONST != TYPE_DYN_PROP_KIND (TYPE_ALLOCATED_PROP (type)))
292cb41
-	       || (TYPE_DATA_LOCATION (type)
292cb41
-		   && PROP_CONST != TYPE_DYN_PROP_KIND (TYPE_DATA_LOCATION (type))))
292cb41
-	{
292cb41
-	  /* This case exist when we ptype a typename which has the dynamic
292cb41
-	     properties but cannot be resolved as there is no object.  */
292cb41
-	  print_rank_only = true;
292cb41
-	}
Jan Kratochvil d258670
+	      || (TYPE_ALLOCATED_PROP (type)
Jan Kratochvil d258670
+		&& PROP_CONST != TYPE_DYN_PROP_KIND (TYPE_ALLOCATED_PROP (type)))
Jan Kratochvil d258670
+	      || (TYPE_DATA_LOCATION (type)
Jan Kratochvil d258670
+		  && PROP_CONST != TYPE_DYN_PROP_KIND (TYPE_DATA_LOCATION (type))))
Jan Kratochvil d258670
+	/* This case exist when we ptype a typename which has the
Jan Kratochvil d258670
+	   dynamic properties but cannot be resolved as there is
Jan Kratochvil d258670
+	   no object.  */
292cb41
+	print_rank_only = true;
e90857f
 
292cb41
       if (TYPE_CODE (TYPE_TARGET_TYPE (type)) == TYPE_CODE_ARRAY)
292cb41
 	f_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, 0,
292cb41
@@ -206,8 +205,9 @@ f_type_print_varspec_suffix (struct type *type, struct ui_file *stream,
292cb41
       else
292cb41
 	{
292cb41
 	  LONGEST lower_bound = f77_get_lowerbound (type);
292cb41
+
292cb41
 	  if (lower_bound != 1)	/* Not the default.  */
e90857f
-            fprintf_filtered (stream, "%s:", plongest (lower_bound));
292cb41
+	    fprintf_filtered (stream, "%s:", plongest (lower_bound));
e90857f
 
292cb41
 	  /* Make sure that, if we have an assumed size array, we
292cb41
 	       print out a warning and print the upperbound as '*'.  */
292cb41
@@ -218,7 +218,7 @@ f_type_print_varspec_suffix (struct type *type, struct ui_file *stream,
292cb41
 	    {
292cb41
 	      LONGEST upper_bound = f77_get_upperbound (type);
e90857f
 
e90857f
-              fputs_filtered (plongest (upper_bound), stream);
292cb41
+	      fprintf_filtered (stream, "%s", plongest (upper_bound));
292cb41
 	    }
292cb41
 	}
e90857f
 
292cb41
@@ -238,7 +238,7 @@ f_type_print_varspec_suffix (struct type *type, struct ui_file *stream,
Jan Kratochvil d258670
     case TYPE_CODE_REF:
Jan Kratochvil d258670
       f_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, 0, 1, 0,
292cb41
 				   arrayprint_recurse_level, false);
654fb50
-      fprintf_filtered (stream, " )");
654fb50
+      fprintf_filtered (stream, ")");
Jan Kratochvil d258670
       break;
Jan Kratochvil d258670
 
Jan Kratochvil d258670
     case TYPE_CODE_FUNC:
f637971
diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c
f637971
--- a/gdb/gdbtypes.c
f637971
+++ b/gdb/gdbtypes.c
f7760f8
@@ -1903,7 +1903,8 @@ is_dynamic_type_internal (struct type *type, int top_level)
Jan Kratochvil d258670
   type = check_typedef (type);
Jan Kratochvil d258670
 
Jan Kratochvil d258670
   /* We only want to recognize references at the outermost level.  */
Jan Kratochvil d258670
-  if (top_level && TYPE_CODE (type) == TYPE_CODE_REF)
Jan Kratochvil d258670
+  if (top_level &&
Jan Kratochvil d258670
+      (TYPE_CODE (type) == TYPE_CODE_REF || TYPE_CODE (type) == TYPE_CODE_PTR))
Jan Kratochvil d258670
     type = check_typedef (TYPE_TARGET_TYPE (type));
Jan Kratochvil d258670
 
Jan Kratochvil d258670
   /* Types that have a dynamic TYPE_DATA_LOCATION are considered
f7760f8
@@ -1937,6 +1938,7 @@ is_dynamic_type_internal (struct type *type, int top_level)
Jan Kratochvil d258670
       }
Jan Kratochvil d258670
 
Jan Kratochvil d258670
     case TYPE_CODE_ARRAY:
Jan Kratochvil d258670
+    case TYPE_CODE_STRING:
Jan Kratochvil d258670
       {
Jan Kratochvil d258670
 	gdb_assert (TYPE_NFIELDS (type) == 1);
Jan Kratochvil d258670
 
f7760f8
@@ -2055,7 +2057,8 @@ resolve_dynamic_array (struct type *type,
Jan Kratochvil d258670
   struct dynamic_prop *prop;
c42f029
   unsigned int bit_stride = 0;
Jan Kratochvil d258670
 
Jan Kratochvil d258670
-  gdb_assert (TYPE_CODE (type) == TYPE_CODE_ARRAY);
Jan Kratochvil d258670
+  gdb_assert (TYPE_CODE (type) == TYPE_CODE_ARRAY
Jan Kratochvil d258670
+	      || TYPE_CODE (type) == TYPE_CODE_STRING);
Jan Kratochvil d258670
 
Jan Kratochvil d258670
   type = copy_type (type);
Jan Kratochvil d258670
 
f7760f8
@@ -2080,11 +2083,15 @@ resolve_dynamic_array (struct type *type,
Jan Kratochvil d258670
 
Jan Kratochvil d258670
   ary_dim = check_typedef (TYPE_TARGET_TYPE (elt_type));
Jan Kratochvil d258670
 
Jan Kratochvil d258670
-  if (ary_dim != NULL && TYPE_CODE (ary_dim) == TYPE_CODE_ARRAY)
Jan Kratochvil d258670
+  if (ary_dim != NULL && (TYPE_CODE (ary_dim) == TYPE_CODE_ARRAY
Jan Kratochvil d258670
+      || TYPE_CODE (ary_dim) == TYPE_CODE_STRING))
Jan Kratochvil d258670
     elt_type = resolve_dynamic_array (ary_dim, addr_stack);
Jan Kratochvil d258670
   else
Jan Kratochvil d258670
     elt_type = TYPE_TARGET_TYPE (type);
Jan Kratochvil d258670
 
Jan Kratochvil d258670
+  if (TYPE_CODE (type) == TYPE_CODE_STRING)
Jan Kratochvil d258670
+    return create_string_type (type, elt_type, range_type);
c42f029
+
c42f029
   prop = get_dyn_prop (DYN_PROP_BYTE_STRIDE, type);
c42f029
   if (prop != NULL)
c42f029
     {
f7760f8
@@ -2236,6 +2243,28 @@ resolve_dynamic_struct (struct type *type,
Jan Kratochvil d258670
   return resolved_type;
Jan Kratochvil d258670
 }
Jan Kratochvil d258670
 
Jan Kratochvil d258670
+/* Worker for pointer types.  */
Jan Kratochvil d258670
+
Jan Kratochvil d258670
+static struct type *
Jan Kratochvil d258670
+resolve_dynamic_pointer (struct type *type,
Jan Kratochvil d258670
+			 struct property_addr_info *addr_stack)
Jan Kratochvil d258670
+{
Jan Kratochvil d258670
+  struct dynamic_prop *prop;
Jan Kratochvil d258670
+  CORE_ADDR value;
Jan Kratochvil d258670
+
Jan Kratochvil d258670
+  type = copy_type (type);
Jan Kratochvil d258670
+
Jan Kratochvil d258670
+  /* Resolve associated property.  */
Jan Kratochvil d258670
+  prop = TYPE_ASSOCIATED_PROP (type);
Jan Kratochvil d258670
+  if (prop != NULL && dwarf2_evaluate_property (prop, NULL, addr_stack, &value))
Jan Kratochvil d258670
+    {
Jan Kratochvil d258670
+      TYPE_DYN_PROP_ADDR (prop) = value;
Jan Kratochvil d258670
+      TYPE_DYN_PROP_KIND (prop) = PROP_CONST;
Jan Kratochvil d258670
+    }
Jan Kratochvil d258670
+
Jan Kratochvil d258670
+  return type;
Jan Kratochvil d258670
+}
Jan Kratochvil d258670
+
Jan Kratochvil d258670
 /* Worker for resolved_dynamic_type.  */
Jan Kratochvil d258670
 
Jan Kratochvil d258670
 static struct type *
f7760f8
@@ -2284,7 +2313,12 @@ resolve_dynamic_type_internal (struct type *type,
Jan Kratochvil d258670
 	    break;
Jan Kratochvil d258670
 	  }
Jan Kratochvil d258670
 
Jan Kratochvil d258670
+        case TYPE_CODE_PTR:
Jan Kratochvil d258670
+ 	  resolved_type = resolve_dynamic_pointer (type, addr_stack);
Jan Kratochvil d258670
+ 	  break;
Jan Kratochvil d258670
+
Jan Kratochvil d258670
 	case TYPE_CODE_ARRAY:
Jan Kratochvil d258670
+	case TYPE_CODE_STRING:
Jan Kratochvil d258670
 	  resolved_type = resolve_dynamic_array (type, addr_stack);
Jan Kratochvil d258670
 	  break;
Jan Kratochvil d258670
 
f637971
diff --git a/gdb/testsuite/gdb.cp/vla-cxx.cc b/gdb/testsuite/gdb.cp/vla-cxx.cc
f637971
--- a/gdb/testsuite/gdb.cp/vla-cxx.cc
f637971
+++ b/gdb/testsuite/gdb.cp/vla-cxx.cc
Jan Kratochvil d258670
@@ -15,6 +15,10 @@
Jan Kratochvil d258670
    You should have received a copy of the GNU General Public License
Jan Kratochvil d258670
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
Jan Kratochvil d258670
 
Jan Kratochvil d258670
+extern "C" {
Jan Kratochvil d258670
+#include <stddef.h>
Jan Kratochvil d258670
+}
Jan Kratochvil d258670
+
Jan Kratochvil d258670
 struct container;
Jan Kratochvil d258670
 
Jan Kratochvil d258670
 struct element
f637971
@@ -40,11 +44,16 @@ int main(int argc, char **argv)
Jan Kratochvil d258670
   typedef typeof (vla) &vlareftypedef;
Jan Kratochvil d258670
   vlareftypedef vlaref2 (vla);
Jan Kratochvil d258670
   container c;
Jan Kratochvil d258670
+  typeof (vla) *ptr = NULL;
Jan Kratochvil d258670
+
Jan Kratochvil d258670
+  // Before pointer assignment
Jan Kratochvil d258670
+  ptr = &vla;
Jan Kratochvil d258670
 
Jan Kratochvil d258670
   for (int i = 0; i < z; ++i)
Jan Kratochvil d258670
     vla[i] = 5 + 2 * i;
Jan Kratochvil d258670
 
Jan Kratochvil d258670
   // vlas_filled
Jan Kratochvil d258670
   vla[0] = 2 * vla[0];
Jan Kratochvil d258670
+
Jan Kratochvil d258670
   return vla[2];
Jan Kratochvil d258670
 }
f637971
diff --git a/gdb/testsuite/gdb.cp/vla-cxx.exp b/gdb/testsuite/gdb.cp/vla-cxx.exp
f637971
--- a/gdb/testsuite/gdb.cp/vla-cxx.exp
f637971
+++ b/gdb/testsuite/gdb.cp/vla-cxx.exp
f637971
@@ -23,6 +23,12 @@ if ![runto_main] {
Jan Kratochvil d258670
     return -1
Jan Kratochvil d258670
 }
Jan Kratochvil d258670
 
Jan Kratochvil d258670
+gdb_breakpoint [gdb_get_line_number "Before pointer assignment"]
Jan Kratochvil d258670
+gdb_continue_to_breakpoint "Before pointer assignment"
Jan Kratochvil d258670
+gdb_test "ptype ptr" "int \\(\\*\\)\\\[variable length\\\]" "ptype ptr, Before pointer assignment"
Jan Kratochvil d258670
+gdb_test "print ptr" "\\(int \\(\\*\\)\\\[variable length\\\]\\) 0x0" "print ptr, Before pointer assignment"
Jan Kratochvil d258670
+gdb_test "print *ptr" "Cannot access memory at address 0x0" "print *ptr, Before pointer assignment"
Jan Kratochvil d258670
+
Jan Kratochvil d258670
 gdb_breakpoint [gdb_get_line_number "vlas_filled"]
Jan Kratochvil d258670
 gdb_continue_to_breakpoint "vlas_filled"
Jan Kratochvil d258670
 
f637971
@@ -33,3 +39,6 @@ gdb_test "print vlaref" " = \\(int \\(&\\)\\\[3\\\]\\) @$hex: \\{5, 7, 9\\}"
Jan Kratochvil d258670
 # bug being tested, it's better not to depend on the exact spelling.
Jan Kratochvil d258670
 gdb_test "print vlaref2" " = \\(.*\\) @$hex: \\{5, 7, 9\\}"
Jan Kratochvil d258670
 gdb_test "print c" " = \\{e = \\{c = @$hex\\}\\}"
Jan Kratochvil d258670
+gdb_test "ptype ptr" "int \\(\\*\\)\\\[3\\\]"
Jan Kratochvil d258670
+gdb_test "print ptr" "\\(int \\(\\*\\)\\\[3\\\]\\) $hex"
Jan Kratochvil d258670
+gdb_test "print *ptr" " = \\{5, 7, 9\\}"
f637971
diff --git a/gdb/testsuite/gdb.fortran/pointers.exp b/gdb/testsuite/gdb.fortran/pointers.exp
f637971
new file mode 100644
f637971
--- /dev/null
f637971
+++ b/gdb/testsuite/gdb.fortran/pointers.exp
Jan Kratochvil d258670
@@ -0,0 +1,143 @@
Jan Kratochvil d258670
+# Copyright 2016 Free Software Foundation, Inc.
Jan Kratochvil d258670
+
Jan Kratochvil d258670
+# This program is free software; you can redistribute it and/or modify
Jan Kratochvil d258670
+# it under the terms of the GNU General Public License as published by
Jan Kratochvil d258670
+# the Free Software Foundation; either version 3 of the License, or
Jan Kratochvil d258670
+# (at your option) any later version.
Jan Kratochvil d258670
+#
Jan Kratochvil d258670
+# This program is distributed in the hope that it will be useful,
Jan Kratochvil d258670
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
Jan Kratochvil d258670
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Jan Kratochvil d258670
+# GNU General Public License for more details.
Jan Kratochvil d258670
+#
Jan Kratochvil d258670
+# You should have received a copy of the GNU General Public License
Jan Kratochvil d258670
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
Jan Kratochvil d258670
+
Jan Kratochvil d258670
+standard_testfile "pointers.f90"
Jan Kratochvil d258670
+load_lib fortran.exp
Jan Kratochvil d258670
+
Jan Kratochvil d258670
+if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} \
Jan Kratochvil d258670
+    {debug f90 quiet}] } {
Jan Kratochvil d258670
+    return -1
Jan Kratochvil d258670
+}
Jan Kratochvil d258670
+
Jan Kratochvil d258670
+if ![runto_main] {
Jan Kratochvil d258670
+    untested "could not run to main"
Jan Kratochvil d258670
+    return -1
Jan Kratochvil d258670
+}
Jan Kratochvil d258670
+
Jan Kratochvil d258670
+# Depending on the compiler being used, the type names can be printed differently.
Jan Kratochvil d258670
+set logical [fortran_logical4]
Jan Kratochvil d258670
+set real [fortran_real4]
Jan Kratochvil d258670
+set int [fortran_int4]
Jan Kratochvil d258670
+set complex [fortran_complex4]
Jan Kratochvil d258670
+
Jan Kratochvil d258670
+
Jan Kratochvil d258670
+gdb_breakpoint [gdb_get_line_number "Before pointer assignment"]
Jan Kratochvil d258670
+gdb_continue_to_breakpoint "Before pointer assignment"
865e2df
+gdb_test "print logp" "= \\(PTR TO -> \\( $logical\\)\\) 0x0" "print logp, not associated"
Jan Kratochvil d258670
+gdb_test "print *logp" "Cannot access memory at address 0x0" "print *logp, not associated"
865e2df
+gdb_test "print comp" "= \\(PTR TO -> \\( $complex\\)\\) 0x0" "print comp, not associated"
Jan Kratochvil d258670
+gdb_test "print *comp" "Cannot access memory at address 0x0" "print *comp, not associated"
865e2df
+gdb_test "print charp" "= \\(PTR TO -> \\( character\\*1\\)\\) 0x0" "print charp, not associated"
Jan Kratochvil d258670
+gdb_test "print *charp" "Cannot access memory at address 0x0" "print *charp, not associated"
865e2df
+gdb_test "print charap" "= \\(PTR TO -> \\( character\\*3\\)\\) 0x0" "print charap, not associated"
Jan Kratochvil d258670
+gdb_test "print *charap" "Cannot access memory at address 0x0" "print *charap, not associated"
865e2df
+gdb_test "print intp" "= \\(PTR TO -> \\( $int\\)\\) 0x0" "print intp, not associated"
Jan Kratochvil d258670
+gdb_test "print *intp" "Cannot access memory at address 0x0" "print *intp, not associated"
Jan Kratochvil d258670
+set test "print intap, not associated"
Jan Kratochvil d258670
+gdb_test_multiple "print intap" $test {
Jan Kratochvil d258670
+  -re " = \\(PTR TO -> \\( $int \\(:,:\\)\\)\\) <not associated>\r\n$gdb_prompt $" {
Jan Kratochvil d258670
+    pass $test
Jan Kratochvil d258670
+  }
Jan Kratochvil d258670
+  -re " = <not associated>\r\n$gdb_prompt $" {
Jan Kratochvil d258670
+    pass $test
Jan Kratochvil d258670
+  }
Jan Kratochvil d258670
+}
865e2df
+gdb_test "print realp" "= \\(PTR TO -> \\( $real\\)\\) 0x0" "print realp, not associated"
Jan Kratochvil d258670
+gdb_test "print *realp" "Cannot access memory at address 0x0" "print *realp, not associated"
865e2df
+gdb_test "print \$my_var = intp" "= \\(PTR TO -> \\( $int\\)\\) 0x0"
Jan Kratochvil d258670
+set test "print cyclicp1, not associated"
Jan Kratochvil d258670
+gdb_test_multiple "print cyclicp1" $test {
Jan Kratochvil d258670
+  -re "= \\( i = -?\\d+, p = 0x0 \\)\r\n$gdb_prompt $" {
Jan Kratochvil d258670
+    pass $test
Jan Kratochvil d258670
+  }
Jan Kratochvil d258670
+  -re "= \\( i = -?\\d+, p = <not associated> \\)\r\n$gdb_prompt $" {
Jan Kratochvil d258670
+    pass $test
Jan Kratochvil d258670
+  }
Jan Kratochvil d258670
+}
Jan Kratochvil d258670
+set test "print cyclicp1%p, not associated"
Jan Kratochvil d258670
+gdb_test_multiple "print cyclicp1%p" $test {
865e2df
+  -re "= \\(PTR TO -> \\( Type typewithpointer\\)\\) 0x0\r\n$gdb_prompt $" {
Jan Kratochvil d258670
+    pass $test
Jan Kratochvil d258670
+  }
865e2df
+  -re "= \\(PTR TO -> \\( Type typewithpointer\\)\\) <not associated>\r\n$gdb_prompt $" {
Jan Kratochvil d258670
+    pass $test
Jan Kratochvil d258670
+  }
Jan Kratochvil d258670
+}
Jan Kratochvil d258670
+
Jan Kratochvil d258670
+
Jan Kratochvil d258670
+gdb_breakpoint [gdb_get_line_number "Before value assignment"]
Jan Kratochvil d258670
+gdb_continue_to_breakpoint "Before value assignment"
Jan Kratochvil d258670
+gdb_test "print *(twop)%ivla2" "= <not allocated>"
Jan Kratochvil d258670
+
Jan Kratochvil d258670
+
Jan Kratochvil d258670
+gdb_breakpoint [gdb_get_line_number "After value assignment"]
Jan Kratochvil d258670
+gdb_continue_to_breakpoint "After value assignment"
865e2df
+gdb_test "print logp" "= \\(PTR TO -> \\( $logical\\)\\) $hex\( <.*>\)?"
Jan Kratochvil d258670
+gdb_test "print *logp" "= \\.TRUE\\."
865e2df
+gdb_test "print comp" "= \\(PTR TO -> \\( $complex\\)\\) $hex\( <.*>\)?"
Jan Kratochvil d258670
+gdb_test "print *comp" "= \\(1,2\\)"
865e2df
+gdb_test "print charp" "= \\(PTR TO -> \\( character\\*1\\)\\) $hex\( <.*>\)?"
Jan Kratochvil d258670
+gdb_test "print *charp" "= 'a'"
865e2df
+gdb_test "print charap" "= \\(PTR TO -> \\( character\\*3\\)\\) $hex\( <.*>\)?"
Jan Kratochvil d258670
+gdb_test "print *charap" "= 'abc'"
865e2df
+gdb_test "print intp" "= \\(PTR TO -> \\( $int\\)\\) $hex\( <.*>\)?"
Jan Kratochvil d258670
+gdb_test "print *intp" "= 10"
Jan Kratochvil d258670
+set test_name "print intap, associated"
Jan Kratochvil d258670
+gdb_test_multiple "print intap" $test_name {
Jan Kratochvil d258670
+  -re "= \\(\\( 1, 1, 3(, 1){7}\\) \\( 1(, 1){9}\\) \\)\r\n$gdb_prompt $" {
Jan Kratochvil d258670
+    pass $test_name
Jan Kratochvil d258670
+  }
Jan Kratochvil d258670
+  -re "= \\(PTR TO -> \\( $int \\(10,2\\)\\)\\) $hex\( <.*>\)?\r\n$gdb_prompt $" {
Jan Kratochvil d258670
+    gdb_test "print *intap" "= \\(\\( 1, 1, 3(, 1){7}\\) \\( 1(, 1){9}\\) \\)"
Jan Kratochvil d258670
+    pass $test_name
Jan Kratochvil d258670
+  }
Jan Kratochvil d258670
+}
Jan Kratochvil d258670
+set test_name "print intvlap, associated"
Jan Kratochvil d258670
+gdb_test_multiple "print intvlap" $test_name {
Jan Kratochvil d258670
+  -re "= \\(2, 2, 2, 4(, 2){6}\\)\r\n$gdb_prompt $" {
Jan Kratochvil d258670
+    pass $test_name
Jan Kratochvil d258670
+  }
Jan Kratochvil d258670
+  -re "= \\(PTR TO -> \\( $int \\(10\\)\\)\\) $hex\( <.*>\)?\r\n$gdb_prompt $" {
Jan Kratochvil d258670
+    gdb_test "print *intvlap" "= \\(2, 2, 2, 4(, 2){6}\\)"
Jan Kratochvil d258670
+    pass $test_name
Jan Kratochvil d258670
+  }
Jan Kratochvil d258670
+}
865e2df
+gdb_test "print realp" "= \\(PTR TO -> \\( $real\\)\\) $hex\( <.*>\)?"
Jan Kratochvil d258670
+gdb_test "print *realp" "= 3\\.14000\\d+"
865e2df
+gdb_test "print arrayOfPtr(2)%p" "= \\(PTR TO -> \\( Type two\\)\\) $hex\( <.*>\)?"
Jan Kratochvil d258670
+gdb_test "print *(arrayOfPtr(2)%p)" "= \\( ivla1 = \\(11, 12, 13\\), ivla2 = \\(\\( 211, 221\\) \\( 212, 222\\) \\) \\)"
Jan Kratochvil d258670
+set test_name "print arrayOfPtr(3)%p"
Jan Kratochvil d258670
+gdb_test_multiple $test_name $test_name {
865e2df
+  -re "= \\(PTR TO -> \\( Type two\\)\\) <not associated>\r\n$gdb_prompt $" {
Jan Kratochvil d258670
+    pass $test_name
Jan Kratochvil d258670
+  }
865e2df
+  -re "= \\(PTR TO -> \\( Type two\\)\\) 0x0\r\n$gdb_prompt $" {
Jan Kratochvil d258670
+    pass $test_name
Jan Kratochvil d258670
+  }
Jan Kratochvil d258670
+}
Jan Kratochvil d258670
+set test_name "print *(arrayOfPtr(3)%p), associated"
Jan Kratochvil d258670
+gdb_test_multiple "print *(arrayOfPtr(3)%p)" $test_name {
Jan Kratochvil d258670
+  -re "Cannot access memory at address 0x0\r\n$gdb_prompt $" {
Jan Kratochvil d258670
+    pass $test_name
Jan Kratochvil d258670
+  }
Jan Kratochvil d258670
+  -re "Attempt to take contents of a not associated pointer.\r\n$gdb_prompt $" {
Jan Kratochvil d258670
+    pass $test_name
Jan Kratochvil d258670
+  }
Jan Kratochvil d258670
+}
Jan Kratochvil d258670
+gdb_test "print cyclicp1" "= \\( i = 1, p = $hex\( <.*>\)? \\)"
865e2df
+gdb_test "print cyclicp1%p" "= \\(PTR TO -> \\( Type typewithpointer\\)\\) $hex\( <.*>\)?"
Jan Kratochvil d258670
+gdb_test "print *((integer*) &inta + 2)" "= 3" "print temporary pointer, array"
Jan Kratochvil d258670
+gdb_test "print *((integer*) &intvla + 3)" "= 4" "print temporary pointer, allocated vla"
865e2df
+gdb_test "print \$pc" "= \\(PTR TO -> \\( void \\(\\) \\(\\)\\)\\) $hex <pointers\\+\\d+>" "Print program counter"
f637971
diff --git a/gdb/testsuite/gdb.fortran/pointers.f90 b/gdb/testsuite/gdb.fortran/pointers.f90
292cb41
--- a/gdb/testsuite/gdb.fortran/pointers.f90
f637971
+++ b/gdb/testsuite/gdb.fortran/pointers.f90
292cb41
@@ -20,21 +20,34 @@ program pointers
292cb41
     integer, allocatable :: ivla2 (:, :)
292cb41
   end type two
292cb41
 
Jan Kratochvil d258670
+  type :: typeWithPointer
Jan Kratochvil d258670
+    integer i
Jan Kratochvil d258670
+    type(typeWithPointer), pointer:: p
Jan Kratochvil d258670
+  end type typeWithPointer
Jan Kratochvil d258670
+
Jan Kratochvil d258670
+  type :: twoPtr
Jan Kratochvil d258670
+    type (two), pointer :: p
Jan Kratochvil d258670
+  end type twoPtr
Jan Kratochvil d258670
+
292cb41
   logical, target :: logv
292cb41
   complex, target :: comv
292cb41
   character, target :: charv
292cb41
   character (len=3), target :: chara
292cb41
   integer, target :: intv
292cb41
   integer, target, dimension (10,2) :: inta
292cb41
-  real, target :: realv
292cb41
-  type(two), target :: twov
Jan Kratochvil d258670
+  integer, target, allocatable, dimension (:) :: intvla
Jan Kratochvil d258670
+  real, target    :: realv
Jan Kratochvil d258670
+  type(two), target  :: twov
Jan Kratochvil d258670
+  type(twoPtr) :: arrayOfPtr (3)
Jan Kratochvil d258670
+  type(typeWithPointer), target:: cyclicp1,cyclicp2
292cb41
 
292cb41
   logical, pointer :: logp
292cb41
   complex, pointer :: comp
292cb41
-  character, pointer :: charp
292cb41
-  character (len=3), pointer :: charap
Jan Kratochvil d258670
+  character, pointer:: charp
Jan Kratochvil d258670
+  character (len=3), pointer:: charap
292cb41
   integer, pointer :: intp
292cb41
   integer, pointer, dimension (:,:) :: intap
Jan Kratochvil d258670
+  integer, pointer, dimension (:) :: intvlap
292cb41
   real, pointer :: realp
292cb41
   type(two), pointer :: twop
292cb41
 
292cb41
@@ -44,8 +57,14 @@ program pointers
292cb41
   nullify (charap)
292cb41
   nullify (intp)
292cb41
   nullify (intap)
Jan Kratochvil d258670
+  nullify (intvlap)
292cb41
   nullify (realp)
292cb41
   nullify (twop)
Jan Kratochvil d258670
+  nullify (arrayOfPtr(1)%p)
Jan Kratochvil d258670
+  nullify (arrayOfPtr(2)%p)
Jan Kratochvil d258670
+  nullify (arrayOfPtr(3)%p)
Jan Kratochvil d258670
+  nullify (cyclicp1%p)
Jan Kratochvil d258670
+  nullify (cyclicp2%p)
292cb41
 
292cb41
   logp => logv    ! Before pointer assignment
292cb41
   comp => comv
292cb41
@@ -53,8 +72,14 @@ program pointers
292cb41
   charap => chara
292cb41
   intp => intv
292cb41
   intap => inta
Jan Kratochvil d258670
+  intvlap => intvla
292cb41
   realp => realv
292cb41
   twop => twov
Jan Kratochvil d258670
+  arrayOfPtr(2)%p => twov
Jan Kratochvil d258670
+  cyclicp1%i = 1
Jan Kratochvil d258670
+  cyclicp1%p => cyclicp2
Jan Kratochvil d258670
+  cyclicp2%i = 2
Jan Kratochvil d258670
+  cyclicp2%p => cyclicp1
292cb41
 
292cb41
   logv = associated(logp)     ! Before value assignment
292cb41
   comv = cmplx(1,2)
292cb41
@@ -63,6 +88,10 @@ program pointers
292cb41
   intv = 10
292cb41
   inta(:,:) = 1
292cb41
   inta(3,1) = 3
Jan Kratochvil d258670
+  allocate (intvla(10))
Jan Kratochvil d258670
+  intvla(:) = 2
Jan Kratochvil d258670
+  intvla(4) = 4
Jan Kratochvil d258670
+  intvlap => intvla
292cb41
   realv = 3.14
292cb41
 
292cb41
   allocate (twov%ivla1(3))
f637971
diff --git a/gdb/testsuite/gdb.fortran/print_type.exp b/gdb/testsuite/gdb.fortran/print_type.exp
292cb41
--- a/gdb/testsuite/gdb.fortran/print_type.exp
f637971
+++ b/gdb/testsuite/gdb.fortran/print_type.exp
292cb41
@@ -1,5 +1,6 @@
292cb41
 # Copyright 2019 Free Software Foundation, Inc.
292cb41
 #
292cb41
+
292cb41
 # This program is free software; you can redistribute it and/or modify
292cb41
 # it under the terms of the GNU General Public License as published by
292cb41
 # the Free Software Foundation; either version 3 of the License, or
292cb41
@@ -40,7 +41,7 @@ set complex [fortran_complex4]
292cb41
 # matches the string TYPE.
292cb41
 proc check_pointer_type { var_name type } {
292cb41
     gdb_test "ptype ${var_name}" \
292cb41
-	"type = PTR TO -> \\( ${type} \\)"
292cb41
+	"type = PTR TO -> \\( ${type}\\)"
292cb41
 }
292cb41
 
292cb41
 gdb_breakpoint [gdb_get_line_number "Before pointer assignment"]
292cb41
@@ -85,7 +86,8 @@ gdb_test "ptype twop" \
292cb41
     [multi_line "type = PTR TO -> \\( Type two" \
292cb41
                 "    $int, allocatable :: ivla1\\(:\\)" \
292cb41
                 "    $int, allocatable :: ivla2\\(:,:\\)" \
292cb41
-                "End Type two \\)"]
865e2df
+                "End Type two\\)"]
Jan Kratochvil d258670
+
292cb41
 
292cb41
 gdb_breakpoint [gdb_get_line_number "After value assignment"]
292cb41
 gdb_continue_to_breakpoint "After value assignment"
292cb41
@@ -97,11 +99,11 @@ gdb_test "ptype intv" "type = $int"
292cb41
 gdb_test "ptype inta" "type = $int \\(10,2\\)"
292cb41
 gdb_test "ptype realv" "type = $real"
292cb41
 
292cb41
-gdb_test "ptype logp" "type = PTR TO -> \\( $logical \\)"
292cb41
-gdb_test "ptype comp" "type = PTR TO -> \\( $complex \\)"
292cb41
-gdb_test "ptype charp" "type = PTR TO -> \\( character\\*1 \\)"
292cb41
-gdb_test "ptype charap" "type = PTR TO -> \\( character\\*3 \\)"
292cb41
-gdb_test "ptype intp" "type = PTR TO -> \\( $int \\)"
865e2df
+gdb_test "ptype logp" "type = PTR TO -> \\( $logical\\)"
865e2df
+gdb_test "ptype comp" "type = PTR TO -> \\( $complex\\)"
865e2df
+gdb_test "ptype charp" "type = PTR TO -> \\( character\\*1\\)"
865e2df
+gdb_test "ptype charap" "type = PTR TO -> \\( character\\*3\\)"
865e2df
+gdb_test "ptype intp" "type = PTR TO -> \\( $int\\)"
292cb41
 set test "ptype intap"
292cb41
 gdb_test_multiple $test $test {
292cb41
     -re "type = $int \\(10,2\\)\r\n$gdb_prompt $" {
292cb41
@@ -111,4 +113,4 @@ gdb_test_multiple $test $test {
292cb41
         pass $test
292cb41
     }
292cb41
 }
292cb41
-gdb_test "ptype realp" "type = PTR TO -> \\( $real \\)"
865e2df
+gdb_test "ptype realp" "type = PTR TO -> \\( $real\\)"
f637971
diff --git a/gdb/testsuite/gdb.fortran/vla-strings.exp b/gdb/testsuite/gdb.fortran/vla-strings.exp
f637971
new file mode 100644
f637971
--- /dev/null
f637971
+++ b/gdb/testsuite/gdb.fortran/vla-strings.exp
Jan Kratochvil d258670
@@ -0,0 +1,103 @@
Jan Kratochvil d258670
+# Copyright 2016 Free Software Foundation, Inc.
Jan Kratochvil d258670
+
Jan Kratochvil d258670
+# This program is free software; you can redistribute it and/or modify
Jan Kratochvil d258670
+# it under the terms of the GNU General Public License as published by
Jan Kratochvil d258670
+# the Free Software Foundation; either version 3 of the License, or
Jan Kratochvil d258670
+# (at your option) any later version.
Jan Kratochvil d258670
+#
Jan Kratochvil d258670
+# This program is distributed in the hope that it will be useful,
Jan Kratochvil d258670
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
Jan Kratochvil d258670
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Jan Kratochvil d258670
+# GNU General Public License for more details.
Jan Kratochvil d258670
+#
Jan Kratochvil d258670
+# You should have received a copy of the GNU General Public License
Jan Kratochvil d258670
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
Jan Kratochvil d258670
+
Jan Kratochvil d258670
+standard_testfile ".f90"
Jan Kratochvil d258670
+
Jan Kratochvil d258670
+if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} \
Jan Kratochvil d258670
+    {debug f90 quiet}] } {
Jan Kratochvil d258670
+    return -1
Jan Kratochvil d258670
+}
Jan Kratochvil d258670
+
Jan Kratochvil d258670
+# check that all fortran standard datatypes will be
Jan Kratochvil d258670
+# handled correctly when using as VLA's
Jan Kratochvil d258670
+
Jan Kratochvil d258670
+if ![runto_main] {
Jan Kratochvil d258670
+    untested "could not run to main"
Jan Kratochvil d258670
+    return -1
Jan Kratochvil d258670
+}
Jan Kratochvil d258670
+
Jan Kratochvil d258670
+gdb_breakpoint [gdb_get_line_number "var_char-allocated-1"]
Jan Kratochvil d258670
+gdb_continue_to_breakpoint "var_char-allocated-1"
Jan Kratochvil d258670
+set test "whatis var_char first time"
Jan Kratochvil d258670
+gdb_test_multiple "whatis var_char" $test {
865e2df
+    -re "type = PTR TO -> \\( character\\*10\\)\r\n$gdb_prompt $" {
Jan Kratochvil d258670
+	    pass $test
Jan Kratochvil d258670
+    }
Jan Kratochvil d258670
+    -re "type = character\\*10\r\n$gdb_prompt $" {
Jan Kratochvil d258670
+	    pass $test
Jan Kratochvil d258670
+    }
Jan Kratochvil d258670
+}
Jan Kratochvil d258670
+set test "ptype var_char first time"
Jan Kratochvil d258670
+gdb_test_multiple "ptype var_char" $test {
865e2df
+    -re "type = PTR TO -> \\( character\\*10\\)\r\n$gdb_prompt $" {
Jan Kratochvil d258670
+	    pass $test
Jan Kratochvil d258670
+    }
Jan Kratochvil d258670
+    -re "type = character\\*10\r\n$gdb_prompt $" {
Jan Kratochvil d258670
+	    pass $test
Jan Kratochvil d258670
+    }
Jan Kratochvil d258670
+}
Jan Kratochvil d258670
+
Jan Kratochvil d258670
+
Jan Kratochvil d258670
+gdb_test "next" "\\d+.*var_char = 'foo'.*" \
Jan Kratochvil d258670
+  "next to allocation status of var_char"
Jan Kratochvil d258670
+gdb_test "print l" " = \\.TRUE\\." "print allocation status first time"
Jan Kratochvil d258670
+
Jan Kratochvil d258670
+
Jan Kratochvil d258670
+gdb_breakpoint [gdb_get_line_number "var_char-filled-1"]
Jan Kratochvil d258670
+gdb_continue_to_breakpoint "var_char-filled-1"
Jan Kratochvil d258670
+set test "print var_char, var_char-filled-1"
Jan Kratochvil d258670
+gdb_test_multiple "print var_char" $test {
865e2df
+    -re "= \\(PTR TO -> \\( character\\*3\\)\\) $hex\r\n$gdb_prompt $" {
Jan Kratochvil d258670
+        gdb_test "print *var_char" "= 'foo'" "print *var_char, var_char-filled-1"
Jan Kratochvil d258670
+	    pass $test
Jan Kratochvil d258670
+    }
Jan Kratochvil d258670
+    -re "= 'foo'\r\n$gdb_prompt $" {
Jan Kratochvil d258670
+	    pass $test
Jan Kratochvil d258670
+    }
Jan Kratochvil d258670
+}
Jan Kratochvil d258670
+set test "ptype var_char, var_char-filled-1"
Jan Kratochvil d258670
+gdb_test_multiple "ptype var_char" $test {
865e2df
+    -re "type = PTR TO -> \\( character\\*3\\)\r\n$gdb_prompt $" {
Jan Kratochvil d258670
+	    pass $test
Jan Kratochvil d258670
+    }
Jan Kratochvil d258670
+    -re "type = character\\*3\r\n$gdb_prompt $" {
Jan Kratochvil d258670
+	    pass $test
Jan Kratochvil d258670
+    }
Jan Kratochvil d258670
+}
Jan Kratochvil d258670
+gdb_test "print var_char(1)" " = 102 'f'" "print var_char(1)"
Jan Kratochvil d258670
+gdb_test "print var_char(3)" " = 111 'o'" "print var_char(3)"
Jan Kratochvil d258670
+
Jan Kratochvil d258670
+
Jan Kratochvil d258670
+gdb_breakpoint [gdb_get_line_number "var_char-filled-2"]
Jan Kratochvil d258670
+gdb_continue_to_breakpoint "var_char-filled-2"
Jan Kratochvil d258670
+set test "print var_char, var_char-filled-2"
Jan Kratochvil d258670
+gdb_test_multiple "print var_char" $test {
865e2df
+    -re "= \\(PTR TO -> \\( character\\*6\\)\\) $hex\r\n$gdb_prompt $" {
Jan Kratochvil d258670
+        gdb_test "print *var_char" "= 'foobar'" "print *var_char, var_char-filled-2"
Jan Kratochvil d258670
+	    pass $test
Jan Kratochvil d258670
+    }
Jan Kratochvil d258670
+    -re "= 'foobar'\r\n$gdb_prompt $" {
Jan Kratochvil d258670
+	    pass $test
Jan Kratochvil d258670
+    }
Jan Kratochvil d258670
+}
Jan Kratochvil d258670
+set test "ptype var_char, var_char-filled-2"
Jan Kratochvil d258670
+gdb_test_multiple "ptype var_char" $test {
865e2df
+    -re "type = PTR TO -> \\( character\\*6\\)\r\n$gdb_prompt $" {
Jan Kratochvil d258670
+	    pass $test
Jan Kratochvil d258670
+    }
Jan Kratochvil d258670
+    -re "type = character\\*6\r\n$gdb_prompt $" {
Jan Kratochvil d258670
+	    pass $test
Jan Kratochvil d258670
+    }
Jan Kratochvil d258670
+}
f637971
diff --git a/gdb/testsuite/gdb.fortran/vla-strings.f90 b/gdb/testsuite/gdb.fortran/vla-strings.f90
f637971
new file mode 100644
f637971
--- /dev/null
f637971
+++ b/gdb/testsuite/gdb.fortran/vla-strings.f90
Jan Kratochvil d258670
@@ -0,0 +1,39 @@
Jan Kratochvil d258670
+! Copyright 2016 Free Software Foundation, Inc.
Jan Kratochvil d258670
+!
Jan Kratochvil d258670
+! This program is free software; you can redistribute it and/or modify
Jan Kratochvil d258670
+! it under the terms of the GNU General Public License as published by
Jan Kratochvil d258670
+! the Free Software Foundation; either version 3 of the License, or
Jan Kratochvil d258670
+! (at your option) any later version.
Jan Kratochvil d258670
+!
Jan Kratochvil d258670
+! This program is distributed in the hope that it will be useful,
Jan Kratochvil d258670
+! but WITHOUT ANY WARRANTY; without even the implied warranty of
Jan Kratochvil d258670
+! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Jan Kratochvil d258670
+! GNU General Public License for more details.
Jan Kratochvil d258670
+!
Jan Kratochvil d258670
+! You should have received a copy of the GNU General Public License
Jan Kratochvil d258670
+! along with this program.  If not, see <http://www.gnu.org/licenses/>.
Jan Kratochvil d258670
+
Jan Kratochvil d258670
+program vla_strings
Jan Kratochvil d258670
+  character(len=:), target, allocatable   :: var_char
Jan Kratochvil d258670
+  character(len=:), pointer               :: var_char_p
Jan Kratochvil d258670
+  logical                                 :: l
Jan Kratochvil d258670
+
Jan Kratochvil d258670
+  allocate(character(len=10) :: var_char)
Jan Kratochvil d258670
+  l = allocated(var_char)                 ! var_char-allocated-1
Jan Kratochvil d258670
+  var_char = 'foo'
Jan Kratochvil d258670
+  deallocate(var_char)                    ! var_char-filled-1
Jan Kratochvil d258670
+  l = allocated(var_char)                 ! var_char-deallocated
Jan Kratochvil d258670
+  allocate(character(len=42) :: var_char)
Jan Kratochvil d258670
+  l = allocated(var_char)
Jan Kratochvil d258670
+  var_char = 'foobar'
Jan Kratochvil d258670
+  var_char = ''                           ! var_char-filled-2
Jan Kratochvil d258670
+  var_char = 'bar'                        ! var_char-empty
Jan Kratochvil d258670
+  deallocate(var_char)
Jan Kratochvil d258670
+  allocate(character(len=21) :: var_char)
Jan Kratochvil d258670
+  l = allocated(var_char)                 ! var_char-allocated-3
Jan Kratochvil d258670
+  var_char = 'johndoe'
Jan Kratochvil d258670
+  var_char_p => var_char
Jan Kratochvil d258670
+  l = associated(var_char_p)              ! var_char_p-associated
Jan Kratochvil d258670
+  var_char_p => null()
Jan Kratochvil d258670
+  l = associated(var_char_p)              ! var_char_p-not-associated
Jan Kratochvil d258670
+end program vla_strings
f637971
diff --git a/gdb/testsuite/gdb.fortran/vla-value.exp b/gdb/testsuite/gdb.fortran/vla-value.exp
f637971
--- a/gdb/testsuite/gdb.fortran/vla-value.exp
f637971
+++ b/gdb/testsuite/gdb.fortran/vla-value.exp
f637971
@@ -35,7 +35,7 @@ gdb_breakpoint [gdb_get_line_number "vla1-init"]
Jan Kratochvil d258670
 gdb_continue_to_breakpoint "vla1-init"
Jan Kratochvil d258670
 gdb_test "print vla1" " = <not allocated>" "print non-allocated vla1"
Jan Kratochvil d258670
 gdb_test "print &vla1" \
292cb41
-  " = \\\(PTR TO -> \\\( $real, allocatable \\\(:,:,:\\\) \\\)\\\) $hex" \
654fb50
+  " = \\\(PTR TO -> \\\( $real, allocatable \\\(:,:,:\\\)\\\)\\\) $hex" \
Jan Kratochvil d258670
   "print non-allocated &vla1"
Jan Kratochvil d258670
 gdb_test "print vla1(1,1,1)" "no such vector element \\\(vector not allocated\\\)" \
Jan Kratochvil d258670
   "print member in non-allocated vla1 (1)"
654fb50
@@ -56,7 +56,7 @@ with_timeout_factor 15 {
654fb50
 	"step over value assignment of vla1"
654fb50
 }
654fb50
 gdb_test "print &vla1" \
654fb50
-  " = \\\(PTR TO -> \\\( $real, allocatable \\\(10,10,10\\\) \\\)\\\) $hex" \
654fb50
+  " = \\\(PTR TO -> \\\( $real, allocatable \\\(10,10,10\\\)\\\)\\\) $hex" \
654fb50
   "print allocated &vla1"
654fb50
 gdb_test "print vla1(3, 6, 9)" " = 1311" "print allocated vla1(3,6,9)"
654fb50
 gdb_test "print vla1(1, 3, 8)" " = 1311" "print allocated vla1(1,3,8)"
f637971
@@ -76,7 +76,7 @@ gdb_test "print vla1(9, 9, 9)" " = 999" \
Jan Kratochvil d258670
 # Try to access values in undefined pointer to VLA (dangling)
Jan Kratochvil d258670
 gdb_test "print pvla" " = <not associated>" "print undefined pvla"
Jan Kratochvil d258670
 gdb_test "print &pvla" \
292cb41
-  " = \\\(PTR TO -> \\\( $real \\\(:,:,:\\\) \\\)\\\) $hex" \
Jan Kratochvil d258670
+  " = \\\(PTR TO -> \\\( $real \\\(:,:,:\\\)\\\)\\\) $hex" \
Jan Kratochvil d258670
   "print non-associated &pvla"
Jan Kratochvil d258670
 gdb_test "print pvla(1, 3, 8)" "no such vector element \\\(vector not associated\\\)" \
Jan Kratochvil d258670
   "print undefined pvla(1,3,8)"
654fb50
@@ -85,7 +85,7 @@ gdb_test "print pvla(1, 3, 8)" "no such vector element \\\(vector not associated
654fb50
 gdb_breakpoint [gdb_get_line_number "pvla-associated"]
654fb50
 gdb_continue_to_breakpoint "pvla-associated"
654fb50
 gdb_test "print &pvla" \
654fb50
-  " = \\\(PTR TO -> \\\( $real \\\(10,10,10\\\) \\\)\\\) $hex" \
654fb50
+  " = \\\(PTR TO -> \\\( $real \\\(10,10,10\\\)\\\)\\\) $hex" \
654fb50
   "print associated &pvla"
654fb50
 gdb_test "print pvla(3, 6, 9)" " = 42" "print associated pvla(3,6,9)"
654fb50
 gdb_test "print pvla(1, 3, 8)" " = 1001" "print associated pvla(1,3,8)"
f637971
diff --git a/gdb/typeprint.c b/gdb/typeprint.c
f637971
--- a/gdb/typeprint.c
f637971
+++ b/gdb/typeprint.c
9c37e8a
@@ -572,6 +572,25 @@ whatis_exp (const char *exp, int show)
Jan Kratochvil d258670
       printf_filtered (" */\n");    
Jan Kratochvil d258670
     }
Jan Kratochvil d258670
 
Jan Kratochvil d258670
+  /* Resolve any dynamic target type, as we might print
Jan Kratochvil d258670
+     additional information about the target.
Jan Kratochvil d258670
+     For example, in Fortran and C we are printing the dimension of the
Jan Kratochvil d258670
+     dynamic array the pointer is pointing to.  */
Jan Kratochvil d258670
+  if (TYPE_CODE (type) == TYPE_CODE_PTR
Jan Kratochvil d258670
+      && is_dynamic_type (type) == 1)
Jan Kratochvil d258670
+    {
Jan Kratochvil d258670
+      CORE_ADDR addr;
Jan Kratochvil d258670
+      if (NULL != TYPE_DATA_LOCATION (TYPE_TARGET_TYPE(type)))
Jan Kratochvil d258670
+	addr = value_address (val);
Jan Kratochvil d258670
+      else
Jan Kratochvil d258670
+	addr = value_as_address (val);
Jan Kratochvil d258670
+
Jan Kratochvil d258670
+      if (addr != 0
Jan Kratochvil d258670
+	  && type_not_associated (type) == 0)
Jan Kratochvil d258670
+	TYPE_TARGET_TYPE (type) = resolve_dynamic_type (TYPE_TARGET_TYPE (type),
Jan Kratochvil d258670
+							NULL, addr);
Jan Kratochvil d258670
+    }
Jan Kratochvil d258670
+
Jan Kratochvil d258670
   LA_PRINT_TYPE (type, "", gdb_stdout, show, 0, &flags);
Jan Kratochvil d258670
   printf_filtered ("\n");
2bcd68d
 }
f637971
diff --git a/gdb/valops.c b/gdb/valops.c
f637971
--- a/gdb/valops.c
f637971
+++ b/gdb/valops.c
9c7d730
@@ -1553,6 +1553,19 @@ value_ind (struct value *arg1)
Jan Kratochvil d258670
   if (TYPE_CODE (base_type) == TYPE_CODE_PTR)
Jan Kratochvil d258670
     {
Jan Kratochvil d258670
       struct type *enc_type;
Jan Kratochvil d258670
+      CORE_ADDR addr;
Jan Kratochvil d258670
+
Jan Kratochvil d258670
+      if (type_not_associated (base_type))
Jan Kratochvil d258670
+        error (_("Attempt to take contents of a not associated pointer."));
Jan Kratochvil d258670
+
Jan Kratochvil d258670
+      if (NULL != TYPE_DATA_LOCATION (TYPE_TARGET_TYPE (base_type)))
Jan Kratochvil d258670
+	addr = value_address (arg1);
Jan Kratochvil d258670
+      else
Jan Kratochvil d258670
+	addr = value_as_address (arg1);
Jan Kratochvil d258670
+
Jan Kratochvil d258670
+      if (addr != 0)
Jan Kratochvil d258670
+	TYPE_TARGET_TYPE (base_type) =
Jan Kratochvil d258670
+	    resolve_dynamic_type (TYPE_TARGET_TYPE (base_type), NULL, addr);
Jan Kratochvil d258670
 
Jan Kratochvil d258670
       /* We may be pointing to something embedded in a larger object.
Jan Kratochvil d258670
          Get the real type of the enclosing object.  */
9c7d730
@@ -1568,8 +1581,7 @@ value_ind (struct value *arg1)
Jan Kratochvil d258670
       else
Jan Kratochvil d258670
 	/* Retrieve the enclosing object pointed to.  */
Jan Kratochvil d258670
 	arg2 = value_at_lazy (enc_type, 
Jan Kratochvil d258670
-			      (value_as_address (arg1)
Jan Kratochvil d258670
-			       - value_pointed_to_offset (arg1)));
Jan Kratochvil d258670
+			      (addr - value_pointed_to_offset (arg1)));
Jan Kratochvil d258670
 
Jan Kratochvil d258670
       enc_type = value_type (arg2);
Jan Kratochvil d258670
       return readjust_indirect_value_type (arg2, enc_type, base_type, arg1);
f637971
diff --git a/gdb/valprint.c b/gdb/valprint.c
f637971
--- a/gdb/valprint.c
f637971
+++ b/gdb/valprint.c
f7760f8
@@ -1144,12 +1144,6 @@ value_check_printable (struct value *val, struct ui_file *stream,
Jan Kratochvil d258670
       return 0;
Jan Kratochvil d258670
     }
Jan Kratochvil d258670
 
Jan Kratochvil d258670
-  if (type_not_associated (value_type (val)))
Jan Kratochvil d258670
-    {
Jan Kratochvil d258670
-      val_print_not_associated (stream);
Jan Kratochvil d258670
-      return 0;
Jan Kratochvil d258670
-    }
Jan Kratochvil d258670
-
Jan Kratochvil d258670
   if (type_not_allocated (value_type (val)))
Jan Kratochvil d258670
     {
Jan Kratochvil d258670
       val_print_not_allocated (stream);