aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/gcc-interface/misc.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/ada/gcc-interface/misc.c')
-rw-r--r--gcc/ada/gcc-interface/misc.c53
1 files changed, 53 insertions, 0 deletions
diff --git a/gcc/ada/gcc-interface/misc.c b/gcc/ada/gcc-interface/misc.c
index ef0fe3f..e9df63c 100644
--- a/gcc/ada/gcc-interface/misc.c
+++ b/gcc/ada/gcc-interface/misc.c
@@ -524,6 +524,10 @@ gnat_print_type (FILE *file, tree node, int indent)
default:
break;
}
+
+ if (TYPE_DEBUG_TYPE (node) != NULL_TREE)
+ print_node_brief (file, "debug type", TYPE_DEBUG_TYPE (node),
+ indent + 4);
}
/* Return the name to be printed for DECL. */
@@ -565,6 +569,15 @@ gnat_descriptive_type (const_tree type)
return NULL_TREE;
}
+/* Return the type to used for debugging information instead of TYPE, if any.
+ NULL_TREE if TYPE is fine. */
+
+static tree
+gnat_get_debug_type (const_tree type)
+{
+ return TYPE_DEBUG_TYPE (type);
+}
+
/* Return true if types T1 and T2 are identical for type hashing purposes.
Called only after doing all language independent checks. At present,
this function is only called when both types are FUNCTION_TYPE. */
@@ -697,6 +710,33 @@ gnat_get_array_descr_info (const_tree type, struct array_descr_info *info)
info->element_type = TREE_TYPE (last_dimen);
+ /* When arrays contain dynamically-sized elements, we usually wrap them in
+ padding types, or we create constrained types for them. Then, if such
+ types are stripped in the debugging information output, the debugger needs
+ a way to know the size that is reserved for each element. This is why we
+ emit a stride in such situations. */
+ if (gnat_encodings == DWARF_GNAT_ENCODINGS_MINIMAL)
+ {
+ tree source_element_type = info->element_type;
+
+ while (1)
+ {
+ if (TYPE_DEBUG_TYPE (source_element_type) != NULL_TREE)
+ source_element_type = TYPE_DEBUG_TYPE (source_element_type);
+ else if (TYPE_IS_PADDING_P (source_element_type))
+ source_element_type
+ = TREE_TYPE (TYPE_FIELDS (source_element_type));
+ else
+ break;
+ }
+
+ if (TREE_CODE (TYPE_SIZE_UNIT (source_element_type)) != INTEGER_CST)
+ {
+ info->stride = TYPE_SIZE_UNIT (info->element_type);
+ info->stride_in_bits = false;
+ }
+ }
+
return true;
}
@@ -947,6 +987,17 @@ gnat_init_ts (void)
MARK_TS_TYPED (EXIT_STMT);
}
+/* Return the lang specific structure attached to NODE. Allocate it (cleared)
+ if needed. */
+
+struct lang_type *
+get_lang_specific (tree node)
+{
+ if (!TYPE_LANG_SPECIFIC (node))
+ TYPE_LANG_SPECIFIC (node) = ggc_cleared_alloc<struct lang_type> ();
+ return TYPE_LANG_SPECIFIC (node);
+}
+
/* Definitions for our language-specific hooks. */
#undef LANG_HOOKS_NAME
@@ -999,6 +1050,8 @@ gnat_init_ts (void)
#define LANG_HOOKS_GET_SUBRANGE_BOUNDS gnat_get_subrange_bounds
#undef LANG_HOOKS_DESCRIPTIVE_TYPE
#define LANG_HOOKS_DESCRIPTIVE_TYPE gnat_descriptive_type
+#undef LANG_HOOKS_GET_DEBUG_TYPE
+#define LANG_HOOKS_GET_DEBUG_TYPE gnat_get_debug_type
#undef LANG_HOOKS_ATTRIBUTE_TABLE
#define LANG_HOOKS_ATTRIBUTE_TABLE gnat_internal_attribute_table
#undef LANG_HOOKS_BUILTIN_FUNCTION