dwarf2out.c (dwarf_attr_name): Map DW_AT_GNAT_descriptive_type.
authorOlivier Hainque <hainque@adacore.com>
Fri, 1 Apr 2011 23:38:57 +0000 (23:38 +0000)
committerEric Botcazou <ebotcazou@gcc.gnu.org>
Fri, 1 Apr 2011 23:38:57 +0000 (23:38 +0000)
* dwarf2out.c (dwarf_attr_name): Map DW_AT_GNAT_descriptive_type.
(add_gnat_descriptive_type_attribute): New function.
(gen_array_type_die): Call it.
(gen_enumeration_type_die): Likewise.
(gen_struct_or_union_type_die): Likewise.
(modified_type_die): Likewise.
* langhooks.h (lang_hooks_for_types): New descriptive_type hook.
* langhooks-def.h (LANG_HOOKS_DESCRIPTIVE_TYPE): Default to NULL.
(LANG_HOOKS_FOR_TYPES_INITIALIZER): Add LANG_HOOKS_DESCRIPTIVE_TYPE.
ada/
* gcc-interface/misc.c (gnat_descriptive_type): New function.
(LANG_HOOKS_DESCRIPTIVE_TYPE): Redefine to gnat_descriptive_type.

Co-Authored-By: Eric Botcazou <ebotcazou@adacore.com>
Co-Authored-By: Nicolas Setton <setton@adacore.com>
From-SVN: r171862

gcc/ChangeLog
gcc/ada/ChangeLog
gcc/ada/gcc-interface/misc.c
gcc/dwarf2out.c
gcc/langhooks-def.h
gcc/langhooks.h

index ab0b3f5..d7f82f8 100644 (file)
@@ -1,3 +1,17 @@
+2011-04-01  Olivier Hainque  <hainque@adacore.com>
+            Nicolas Setton  <setton@adacore.com>
+            Eric Botcazou  <ebotcazou@adacore.com>
+
+       * dwarf2out.c (dwarf_attr_name): Map DW_AT_GNAT_descriptive_type.
+       (add_gnat_descriptive_type_attribute): New function.
+       (gen_array_type_die): Call it.
+       (gen_enumeration_type_die): Likewise.
+       (gen_struct_or_union_type_die): Likewise.
+       (modified_type_die): Likewise.
+       * langhooks.h (lang_hooks_for_types): New descriptive_type hook.
+       * langhooks-def.h (LANG_HOOKS_DESCRIPTIVE_TYPE): Default to NULL.
+       (LANG_HOOKS_FOR_TYPES_INITIALIZER): Add LANG_HOOKS_DESCRIPTIVE_TYPE.
+
 2011-04-01  Jakub Jelinek  <jakub@redhat.com>
 
        PR bootstrap/48148
index 03eb136..7d51728 100644 (file)
@@ -1,3 +1,10 @@
+2011-04-01  Olivier Hainque  <hainque@adacore.com>
+            Nicolas Setton  <setton@adacore.com>
+            Eric Botcazou  <ebotcazou@adacore.com>
+
+       * gcc-interface/misc.c (gnat_descriptive_type): New function.
+       (LANG_HOOKS_DESCRIPTIVE_TYPE): Redefine to gnat_descriptive_type.
+
 2011-03-28  Kai Tietz  <ktietz@redhat.com>
 
        * gcc-interface/Makefile.in (SO_LIB): Handle multilib build for native
index 4f7a5e1..a109982 100644 (file)
@@ -6,7 +6,7 @@
  *                                                                          *
  *                           C Implementation File                          *
  *                                                                          *
- *          Copyright (C) 1992-2010, Free Software Foundation, Inc.         *
+ *          Copyright (C) 1992-2011, Free Software Foundation, Inc.         *
  *                                                                          *
  * GNAT is free software;  you can  redistribute it  and/or modify it under *
  * terms of the  GNU General Public License as published  by the Free Soft- *
@@ -521,6 +521,17 @@ gnat_dwarf_name (tree decl, int verbosity ATTRIBUTE_UNUSED)
   return (const char *) IDENTIFIER_POINTER (DECL_NAME (decl));
 }
 
+/* Return the descriptive type associated with TYPE, if any.  */
+
+static tree
+gnat_descriptive_type (const_tree type)
+{
+  if (TYPE_STUB_DECL (type))
+    return DECL_PARALLEL_TYPE (TYPE_STUB_DECL (type));
+  else
+    return NULL_TREE;
+}
+
 /* 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.  */
@@ -746,6 +757,8 @@ gnat_eh_personality (void)
 #define LANG_HOOKS_TYPES_COMPATIBLE_P  gnat_types_compatible_p
 #undef  LANG_HOOKS_GET_SUBRANGE_BOUNDS
 #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_ATTRIBUTE_TABLE
 #define LANG_HOOKS_ATTRIBUTE_TABLE     gnat_internal_attribute_table
 #undef  LANG_HOOKS_BUILTIN_FUNCTION
index 956e805..222f6bf 100644 (file)
@@ -6499,6 +6499,7 @@ static bool add_location_or_const_value_attribute (dw_die_ref, tree, bool,
 static bool tree_add_const_value_attribute (dw_die_ref, tree);
 static bool tree_add_const_value_attribute_for_decl (dw_die_ref, tree);
 static void add_name_attribute (dw_die_ref, const char *);
+static void add_gnat_descriptive_type_attribute (dw_die_ref, tree, dw_die_ref);
 static void add_comp_dir_attribute (dw_die_ref);
 static void add_bound_info (dw_die_ref, enum dwarf_attribute, tree);
 static void add_subscript_info (dw_die_ref, tree, bool);
@@ -7141,6 +7142,7 @@ dwarf_attr_name (unsigned int attr)
       return "DW_AT_body_begin";
     case DW_AT_body_end:
       return "DW_AT_body_end";
+
     case DW_AT_GNU_vector:
       return "DW_AT_GNU_vector";
     case DW_AT_GNU_guarded_by:
@@ -7178,6 +7180,9 @@ dwarf_attr_name (unsigned int attr)
     case DW_AT_GNU_all_source_call_sites:
       return "DW_AT_GNU_all_source_call_sites";
 
+    case DW_AT_GNAT_descriptive_type:
+      return "DW_AT_GNAT_descriptive_type";
+
     case DW_AT_VMS_rtnbeg_pd_address:
       return "DW_AT_VMS_rtnbeg_pd_address";
 
@@ -12859,6 +12864,7 @@ modified_type_die (tree type, int is_const_type, int is_volatile_type,
           useful source coordinates anyway.  */
        name = DECL_NAME (name);
       add_name_attribute (mod_type_die, IDENTIFIER_POINTER (name));
+      add_gnat_descriptive_type_attribute (mod_type_die, type, context_die);
     }
   /* This probably indicates a bug.  */
   else if (mod_type_die && mod_type_die->die_tag == DW_TAG_base_type)
@@ -17306,6 +17312,38 @@ add_name_attribute (dw_die_ref die, const char *name_string)
     }
 }
 
+/* Retrieve the descriptive type of TYPE, if any, make sure it has a
+   DIE and attach a DW_AT_GNAT_descriptive_type attribute to the DIE
+   of TYPE accordingly.
+
+   ??? This is a temporary measure until after we're able to generate
+   regular DWARF for the complex Ada type system.  */
+
+static void 
+add_gnat_descriptive_type_attribute (dw_die_ref die, tree type,
+                                    dw_die_ref context_die)
+{
+  tree dtype;
+  dw_die_ref dtype_die;
+
+  if (!lang_hooks.types.descriptive_type)
+    return;
+
+  dtype = lang_hooks.types.descriptive_type (type);
+  if (!dtype)
+    return;
+
+  dtype_die = lookup_type_die (dtype);
+  if (!dtype_die)
+    {
+      gen_type_die (dtype, context_die);
+      dtype_die = lookup_type_die (dtype);
+      gcc_assert (dtype_die);
+    }
+
+  add_AT_die_ref (die, DW_AT_GNAT_descriptive_type, dtype_die);
+}
+
 /* Generate a DW_AT_comp_dir attribute for DIE.  */
 
 static void
@@ -18185,6 +18223,7 @@ gen_array_type_die (tree type, dw_die_ref context_die)
 
   array_die = new_die (DW_TAG_array_type, scope_die, type);
   add_name_attribute (array_die, type_tag (type));
+  add_gnat_descriptive_type_attribute (array_die, type, context_die);
   equate_type_number_to_die (type, array_die);
 
   if (TREE_CODE (type) == VECTOR_TYPE)
@@ -18487,6 +18526,7 @@ gen_enumeration_type_die (tree type, dw_die_ref context_die)
                          scope_die_for (type, context_die), type);
       equate_type_number_to_die (type, type_die);
       add_name_attribute (type_die, type_tag (type));
+      add_gnat_descriptive_type_attribute (type_die, type, context_die);
       if (dwarf_version >= 4 || !dwarf_strict)
        {
          if (ENUM_IS_SCOPED (type))
@@ -20306,7 +20346,10 @@ gen_struct_or_union_type_die (tree type, dw_die_ref context_die,
       if (old_die)
        add_AT_specification (type_die, old_die);
       else
-       add_name_attribute (type_die, type_tag (type));
+       {
+         add_name_attribute (type_die, type_tag (type));
+         add_gnat_descriptive_type_attribute (type_die, type, context_die);
+       }
     }
   else
     remove_AT (type_die, DW_AT_declaration);
index 961e929..ed3230c 100644 (file)
@@ -1,6 +1,6 @@
 /* Default macros to initialize the lang_hooks data structure.
-   Copyright 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
-   Free Software Foundation, Inc.
+   Copyright 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
+   2011 Free Software Foundation, Inc.
    Contributed by Alexandre Oliva  <aoliva@redhat.com>
 
 This file is part of GCC.
@@ -176,6 +176,7 @@ extern tree lhd_make_node (enum tree_code);
 #define LANG_HOOKS_TYPE_HASH_EQ                NULL
 #define LANG_HOOKS_GET_ARRAY_DESCR_INFO        NULL
 #define LANG_HOOKS_GET_SUBRANGE_BOUNDS NULL
+#define LANG_HOOKS_DESCRIPTIVE_TYPE    NULL
 #define LANG_HOOKS_RECONSTRUCT_COMPLEX_TYPE reconstruct_complex_type
 
 #define LANG_HOOKS_FOR_TYPES_INITIALIZER { \
@@ -193,6 +194,7 @@ extern tree lhd_make_node (enum tree_code);
   LANG_HOOKS_TYPE_HASH_EQ, \
   LANG_HOOKS_GET_ARRAY_DESCR_INFO, \
   LANG_HOOKS_GET_SUBRANGE_BOUNDS, \
+  LANG_HOOKS_DESCRIPTIVE_TYPE, \
   LANG_HOOKS_RECONSTRUCT_COMPLEX_TYPE \
 }
 
index a994729..e0dea01 100644 (file)
@@ -1,6 +1,6 @@
 /* The lang_hooks data structure.
-   Copyright 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
-   Free Software Foundation, Inc.
+   Copyright 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
+   2011 Free Software Foundation, Inc.
 
 This file is part of GCC.
 
@@ -132,6 +132,11 @@ struct lang_hooks_for_types
   /* Fill in information for the debugger about the bounds of TYPE.  */
   void (*get_subrange_bounds) (const_tree, tree *, tree *);
 
+  /* A type descriptive of TYPE's complex layout generated to help the
+     debugger to decode variable-length or self-referential constructs.
+     This is only used for the AT_GNAT_descriptive_type DWARF attribute.  */
+  tree (*descriptive_type) (const_tree);
+
   /* If we requested a pointer to a vector, build up the pointers that
      we stripped off while looking for the inner type.  Similarly for
      return values from functions.  The argument TYPE is the top of the