From patchwork Sun Apr 10 10:26:14 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Botcazou X-Patchwork-Id: 90504 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 AFE96B6F18 for ; Sun, 10 Apr 2011 20:31:58 +1000 (EST) Received: (qmail 10835 invoked by alias); 10 Apr 2011 10:31:55 -0000 Received: (qmail 10823 invoked by uid 22791); 10 Apr 2011 10:31:54 -0000 X-SWARE-Spam-Status: No, hits=-1.1 required=5.0 tests=AWL, BAYES_00, KAM_STOCKGEN, TW_GD 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; Sun, 10 Apr 2011 10:31:47 +0000 Received: from localhost (localhost [127.0.0.1]) by filtered-smtp.eu.adacore.com (Postfix) with ESMTP id BC5CBCB0225 for ; Sun, 10 Apr 2011 12:31:45 +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 nkWC3pVuE7HZ for ; Sun, 10 Apr 2011 12:31:42 +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 A9D78CB01E2 for ; Sun, 10 Apr 2011 12:31:42 +0200 (CEST) From: Eric Botcazou To: gcc-patches@gcc.gnu.org Subject: [patch] Emit DW_AT_artificial for types Date: Sun, 10 Apr 2011 12:26:14 +0200 User-Agent: KMail/1.9.9 MIME-Version: 1.0 Message-Id: <201104101226.14527.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 Hi, as permitted by the DWARF-[234] standards, this patch makes the compiler emit the DW_AT_artificial attribute for compiler-generated types; there are a lot of them in Ada. GDB doesn't use it (yet), but other debuggers do use it to speed up type lookups. Tested on i586-suse-linux, OK for the mainline? 2011-04-10 Eric Botcazou Olivier Hainque Nicolas Setton * tree.h (TYPE_ARTIFICIAL): New flag. * dwarf2out.c (modified_type_die): Add a DW_AT_artificial attribute to the DIE of the type if it is artificial. (gen_array_type_die): Likewise. (gen_enumeration_type_die): Likewise. (gen_struct_or_union_type_die): Likewise. ada/ * gcc-interface/utils.c (record_builtin_type): Set TYPE_ARTIFICIAL on the type according to the ARTIFICIAL_P parameter. (create_type_decl): Likewise. (create_type_stub_decl): Set TYPE_ARTIFICIAL on the type to 1. 2011-04-10 Eric Botcazou * gnat.dg/specs/debug1.ads: New test. Index: tree.h =================================================================== --- tree.h (revision 172224) +++ tree.h (working copy) @@ -631,6 +631,9 @@ struct GTY(()) tree_common { all expressions all decls + TYPE_ARTIFICIAL in + all types + default_def_flag: TYPE_VECTOR_OPAQUE in @@ -1175,6 +1178,9 @@ extern void omp_clause_range_check_faile emitted. */ #define TREE_NO_WARNING(NODE) ((NODE)->base.nowarning_flag) +/* Used to indicate that this TYPE represents a compiler-generated entity. */ +#define TYPE_ARTIFICIAL(NODE) (TYPE_CHECK (NODE)->base.nowarning_flag) + /* In an IDENTIFIER_NODE, this means that assemble_name was called with this string as an argument. */ #define TREE_SYMBOL_REFERENCED(NODE) \ Index: dwarf2out.c =================================================================== --- dwarf2out.c (revision 172224) +++ dwarf2out.c (working copy) @@ -12877,6 +12877,8 @@ modified_type_die (tree type, int is_con name = DECL_NAME (name); add_name_attribute (mod_type_die, IDENTIFIER_POINTER (name)); add_gnat_descriptive_type_attribute (mod_type_die, type, context_die); + if (TYPE_ARTIFICIAL (type)) + add_AT_flag (mod_type_die, DW_AT_artificial, 1); } /* This probably indicates a bug. */ else if (mod_type_die && mod_type_die->die_tag == DW_TAG_base_type) @@ -18234,6 +18236,8 @@ 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); + if (TYPE_ARTIFICIAL (type)) + add_AT_flag (array_die, DW_AT_artificial, 1); equate_type_number_to_die (type, array_die); if (TREE_CODE (type) == VECTOR_TYPE) @@ -18537,6 +18541,8 @@ gen_enumeration_type_die (tree type, dw_ 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 (TYPE_ARTIFICIAL (type)) + add_AT_flag (type_die, DW_AT_artificial, 1); if (dwarf_version >= 4 || !dwarf_strict) { if (ENUM_IS_SCOPED (type)) @@ -20359,6 +20365,8 @@ gen_struct_or_union_type_die (tree type, { add_name_attribute (type_die, type_tag (type)); add_gnat_descriptive_type_attribute (type_die, type, context_die); + if (TYPE_ARTIFICIAL (type)) + add_AT_flag (type_die, DW_AT_artificial, 1); } } else Index: ada/gcc-interface/utils.c =================================================================== --- ada/gcc-interface/utils.c (revision 172224) +++ ada/gcc-interface/utils.c (working copy) @@ -612,6 +612,7 @@ record_builtin_type (const char *name, t tree type_decl = build_decl (input_location, TYPE_DECL, get_identifier (name), type); DECL_ARTIFICIAL (type_decl) = artificial_p; + TYPE_ARTIFICIAL (type) = artificial_p; gnat_pushdecl (type_decl, Empty); if (debug_hooks->type_decl) @@ -1303,6 +1304,7 @@ create_type_stub_decl (tree type_name, t tree type_decl = build_decl (input_location, TYPE_DECL, type_name, type); DECL_ARTIFICIAL (type_decl) = 1; + TYPE_ARTIFICIAL (type) = 1; return type_decl; } @@ -1335,6 +1337,7 @@ create_type_decl (tree type_name, tree t TYPE_DECL, type_name, type); DECL_ARTIFICIAL (type_decl) = artificial_p; + TYPE_ARTIFICIAL (type) = artificial_p; /* Add this decl to the current binding level. */ gnat_pushdecl (type_decl, gnat_node);