From patchwork Fri Apr 1 23:41:05 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Botcazou X-Patchwork-Id: 89370 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id 22D87B6FA0 for ; Sat, 2 Apr 2011 10:42:09 +1100 (EST) Received: (qmail 9117 invoked by alias); 1 Apr 2011 23:42:06 -0000 Received: (qmail 9104 invoked by uid 22791); 1 Apr 2011 23:42:04 -0000 X-SWARE-Spam-Status: No, hits=-1.9 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from mel.act-europe.fr (HELO mel.act-europe.fr) (194.98.77.210) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 01 Apr 2011 23:41:57 +0000 Received: from localhost (localhost [127.0.0.1]) by filtered-smtp.eu.adacore.com (Postfix) with ESMTP id 2BA54CB034A; Sat, 2 Apr 2011 01:41:56 +0200 (CEST) Received: from mel.act-europe.fr ([127.0.0.1]) by localhost (smtp.eu.adacore.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id XlfZ9ZaRxtCU; Sat, 2 Apr 2011 01:41:53 +0200 (CEST) Received: from [192.168.1.2] (bon31-9-83-155-120-49.fbx.proxad.net [83.155.120.49]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mel.act-europe.fr (Postfix) with ESMTP id D15EDCB02DE; Sat, 2 Apr 2011 01:41:52 +0200 (CEST) From: Eric Botcazou To: Olivier Hainque Subject: Re: support for dwarf AT_GNAT_descriptive_type Date: Sat, 2 Apr 2011 01:41:05 +0200 User-Agent: KMail/1.9.9 Cc: gcc-patches@gcc.gnu.org, Jason Merrill , Joel Brobecker , guitton@adacore.com References: <4D65AC93.6020708@redhat.com> <20110224094537.GA11835@mel.act-europe.fr> In-Reply-To: <20110224094537.GA11835@mel.act-europe.fr> MIME-Version: 1.0 Message-Id: <201104020141.05801.ebotcazou@adacore.com> Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org > I suppose this should wait until stage 1 reopens. I've installed the attached slight variant after testing on x86_64-suse-linux. The main change is the default value of LANG_HOOKS_DESCRIPTIVE_TYPE, NULL like other similar debug hooks. Index: langhooks-def.h =================================================================== --- langhooks-def.h (revision 171818) +++ langhooks-def.h (working copy) @@ -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 This file is part of GCC. @@ -176,6 +176,7 @@ extern tree lhd_make_node (enum tree_cod #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_cod 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: langhooks.h =================================================================== --- langhooks.h (revision 171818) +++ langhooks.h (working copy) @@ -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 Index: dwarf2out.c =================================================================== --- dwarf2out.c (revision 171818) +++ dwarf2out.c (working copy) @@ -6497,6 +6497,7 @@ static bool add_location_or_const_value_ 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); @@ -7139,6 +7140,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: @@ -7176,6 +7178,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"; @@ -12857,6 +12862,7 @@ modified_type_die (tree type, int is_con 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) @@ -17304,6 +17310,38 @@ add_name_attribute (dw_die_ref die, cons } } +/* 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 @@ -18183,6 +18221,7 @@ gen_array_type_die (tree type, dw_die_re 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) @@ -18485,6 +18524,7 @@ gen_enumeration_type_die (tree type, dw_ 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)) @@ -20304,7 +20344,10 @@ gen_struct_or_union_type_die (tree type, 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: ada/gcc-interface/misc.c =================================================================== --- ada/gcc-interface/misc.c (revision 171818) +++ ada/gcc-interface/misc.c (working copy) @@ -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 verbosit 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