Jan Kratochvil 7306e88
From a879b2501e61ee3d3efadbdb6b33212b57d3a2e1 Mon Sep 17 00:00:00 2001
Jan Kratochvil 7306e88
From: Bernhard Heckel <bernhard.heckel@intel.com>
Jan Kratochvil 7306e88
Date: Tue, 12 Jul 2016 08:19:34 +0200
Jan Kratochvil 7306e88
Subject: [PATCH 2/7] Fortran: Resolve dynamic properties of pointer types.
Jan Kratochvil 7306e88
Jan Kratochvil 7306e88
In Fortran a pointer may have a dynamic associated property.
Jan Kratochvil 7306e88
Jan Kratochvil 7306e88
2016-07-08  Bernhard Heckel  <bernhard.heckel@intel.com>
Jan Kratochvil 7306e88
Jan Kratochvil 7306e88
gdb/Changelog:
Jan Kratochvil 7306e88
	* gdbtypes.c (resolve_dynamic_types_internal): Resolve pointer types.
Jan Kratochvil 7306e88
	  (resolve_dynamic_pointer): New.
Jan Kratochvil 7306e88
Jan Kratochvil 7306e88
Change-Id: Ie4b9d6397cfa089ee2e0db02beb18415a751c1c0
Jan Kratochvil 7306e88
---
Jan Kratochvil 7306e88
 gdb/gdbtypes.c | 29 ++++++++++++++++++++++++++++-
Jan Kratochvil 7306e88
 1 file changed, 28 insertions(+), 1 deletion(-)
Jan Kratochvil 7306e88
Jan Kratochvil 7306e88
diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c
Jan Kratochvil 7306e88
index ec5c17a..b53e649 100644
Jan Kratochvil 7306e88
--- a/gdb/gdbtypes.c
Jan Kratochvil 7306e88
+++ b/gdb/gdbtypes.c
Jan Kratochvil 7306e88
@@ -1806,7 +1806,8 @@ is_dynamic_type_internal (struct type *type, int top_level)
Jan Kratochvil 7306e88
   type = check_typedef (type);
Jan Kratochvil 7306e88
 
Jan Kratochvil 7306e88
   /* We only want to recognize references at the outermost level.  */
Jan Kratochvil 7306e88
-  if (top_level && TYPE_CODE (type) == TYPE_CODE_REF)
Jan Kratochvil 7306e88
+  if (top_level &&
Jan Kratochvil 7306e88
+      (TYPE_CODE (type) == TYPE_CODE_REF || TYPE_CODE (type) == TYPE_CODE_PTR))
Jan Kratochvil 7306e88
     type = check_typedef (TYPE_TARGET_TYPE (type));
Jan Kratochvil 7306e88
 
Jan Kratochvil 7306e88
   /* Types that have a dynamic TYPE_DATA_LOCATION are considered
Jan Kratochvil 7306e88
@@ -2105,6 +2106,28 @@ resolve_dynamic_struct (struct type *type,
Jan Kratochvil 7306e88
   return resolved_type;
Jan Kratochvil 7306e88
 }
Jan Kratochvil 7306e88
 
Jan Kratochvil 7306e88
+/* Worker for pointer types.  */
Jan Kratochvil 7306e88
+
Jan Kratochvil 7306e88
+static struct type *
Jan Kratochvil 7306e88
+resolve_dynamic_pointer (struct type *type,
Jan Kratochvil 7306e88
+			 struct property_addr_info *addr_stack)
Jan Kratochvil 7306e88
+{
Jan Kratochvil 7306e88
+  struct dynamic_prop *prop;
Jan Kratochvil 7306e88
+  CORE_ADDR value;
Jan Kratochvil 7306e88
+
Jan Kratochvil 7306e88
+  type = copy_type (type);
Jan Kratochvil 7306e88
+
Jan Kratochvil 7306e88
+  /* Resolve associated property.  */
Jan Kratochvil 7306e88
+  prop = TYPE_ASSOCIATED_PROP (type);
Jan Kratochvil 7306e88
+  if (prop != NULL && dwarf2_evaluate_property (prop, NULL, addr_stack, &value))
Jan Kratochvil 7306e88
+    {
Jan Kratochvil 7306e88
+      TYPE_DYN_PROP_ADDR (prop) = value;
Jan Kratochvil 7306e88
+      TYPE_DYN_PROP_KIND (prop) = PROP_CONST;
Jan Kratochvil 7306e88
+    }
Jan Kratochvil 7306e88
+
Jan Kratochvil 7306e88
+  return type;
Jan Kratochvil 7306e88
+}
Jan Kratochvil 7306e88
+
Jan Kratochvil 7306e88
 /* Worker for resolved_dynamic_type.  */
Jan Kratochvil 7306e88
 
Jan Kratochvil 7306e88
 static struct type *
Jan Kratochvil 7306e88
@@ -2153,6 +2176,10 @@ resolve_dynamic_type_internal (struct type *type,
Jan Kratochvil 7306e88
 	    break;
Jan Kratochvil 7306e88
 	  }
Jan Kratochvil 7306e88
 
Jan Kratochvil 7306e88
+        case TYPE_CODE_PTR:
Jan Kratochvil 7306e88
+ 	  resolved_type = resolve_dynamic_pointer (type, addr_stack);
Jan Kratochvil 7306e88
+ 	  break;
Jan Kratochvil 7306e88
+
Jan Kratochvil 7306e88
 	case TYPE_CODE_ARRAY:
Jan Kratochvil 7306e88
 	  resolved_type = resolve_dynamic_array (type, addr_stack);
Jan Kratochvil 7306e88
 	  break;
Jan Kratochvil 7306e88
-- 
Jan Kratochvil 7306e88
2.7.4
Jan Kratochvil 7306e88