From patchwork Fri Jun 25 20:16:25 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 56984 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 88D5DB6EF7 for ; Sat, 26 Jun 2010 06:16:28 +1000 (EST) Received: (qmail 27168 invoked by alias); 25 Jun 2010 20:16:00 -0000 Received: (qmail 27082 invoked by uid 22791); 25 Jun 2010 20:15:50 -0000 X-SWARE-Spam-Status: No, hits=-6.0 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_HI, SPF_HELO_PASS, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 25 Jun 2010 20:15:45 +0000 Received: from int-mx04.intmail.prod.int.phx2.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.17]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o5PKFhow006100 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 25 Jun 2010 16:15:43 -0400 Received: from tyan-ft48-01.lab.bos.redhat.com (tyan-ft48-01.lab.bos.redhat.com [10.16.42.4]) by int-mx04.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o5PKFgIW003086 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 25 Jun 2010 16:15:43 -0400 Received: from tyan-ft48-01.lab.bos.redhat.com (tyan-ft48-01.lab.bos.redhat.com [127.0.0.1]) by tyan-ft48-01.lab.bos.redhat.com (8.14.4/8.14.4) with ESMTP id o5PKGPxp009897; Fri, 25 Jun 2010 22:16:25 +0200 Received: (from jakub@localhost) by tyan-ft48-01.lab.bos.redhat.com (8.14.4/8.14.4/Submit) id o5PKGPoD009895; Fri, 25 Jun 2010 22:16:25 +0200 Date: Fri, 25 Jun 2010 22:16:25 +0200 From: Jakub Jelinek To: Jason Merrill Cc: gcc-patches@gcc.gnu.org Subject: [PATCH] Add DW_AT_accessibility for DW_TAG_{typedef, structure_type, class_type, enumeration_type} (PR debug/44668) Message-ID: <20100625201625.GC25077@tyan-ft48-01.lab.bos.redhat.com> Reply-To: Jakub Jelinek MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-12-10) X-IsSubscribed: yes 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! We weren't emitting DW_AT_accessibility for private or protected typedefs etc. inside of classes/structures. The following patch fixes that, bootstrapped/regtested on x86_64-linux and i686-linux. Ok for trunk? 2010-06-25 Jakub Jelinek PR debug/44668 * dwarf2out.c (add_accessibility_attribute): New function. (gen_subprogram_die, gen_variable_die, gen_field_die): Use it instead of adding DW_AT_accessibility manually. (gen_enumeration_type_die, gen_struct_or_union_type_die, gen_typedef_die): Use it. * g++.dg/debug/dwarf2/accessibility1.C: New test. Jakub --- gcc/dwarf2out.c.jj 2010-06-21 19:26:39.000000000 +0200 +++ gcc/dwarf2out.c 2010-06-25 20:02:01.000000000 +0200 @@ -15746,6 +15746,17 @@ add_AT_location_description (dw_die_ref add_AT_loc_list (die, attr_kind, descr); } +/* Add DW_AT_accessibility attribute to DIE if needed. */ + +static void +add_accessibility_attribute (dw_die_ref die, tree decl) +{ + if (TREE_PROTECTED (decl)) + add_AT_unsigned (die, DW_AT_accessibility, DW_ACCESS_protected); + else if (TREE_PRIVATE (decl)) + add_AT_unsigned (die, DW_AT_accessibility, DW_ACCESS_private); +} + /* Attach the specialized form of location attribute used for data members of struct and union types. In the special case of a FIELD_DECL node which represents a bit-field, the "offset" part of this special location @@ -18017,7 +18028,10 @@ gen_enumeration_type_die (tree type, dw_ TREE_ASM_WRITTEN (type) = 1; add_byte_size_attribute (type_die, type); if (TYPE_STUB_DECL (type) != NULL_TREE) - add_src_coords_attributes (type_die, TYPE_STUB_DECL (type)); + { + add_src_coords_attributes (type_die, TYPE_STUB_DECL (type)); + add_accessibility_attribute (type_die, TYPE_STUB_DECL (type)); + } /* If the first reference to this type was as the return type of an inline function, then it may not have a parent. Fix this now. */ @@ -18524,10 +18538,7 @@ gen_subprogram_die (tree decl, dw_die_re if (DECL_ARTIFICIAL (decl)) add_AT_flag (subr_die, DW_AT_artificial, 1); - if (TREE_PROTECTED (decl)) - add_AT_unsigned (subr_die, DW_AT_accessibility, DW_ACCESS_protected); - else if (TREE_PRIVATE (decl)) - add_AT_unsigned (subr_die, DW_AT_accessibility, DW_ACCESS_private); + add_accessibility_attribute (subr_die, decl); } if (declaration) @@ -19025,10 +19036,7 @@ gen_variable_die (tree decl, tree origin if (DECL_ARTIFICIAL (decl)) add_AT_flag (var_die, DW_AT_artificial, 1); - if (TREE_PROTECTED (decl)) - add_AT_unsigned (var_die, DW_AT_accessibility, DW_ACCESS_protected); - else if (TREE_PRIVATE (decl)) - add_AT_unsigned (var_die, DW_AT_accessibility, DW_ACCESS_private); + add_accessibility_attribute (var_die, decl); } if (declaration) @@ -19257,10 +19265,7 @@ gen_field_die (tree decl, dw_die_ref con if (DECL_ARTIFICIAL (decl)) add_AT_flag (decl_die, DW_AT_artificial, 1); - if (TREE_PROTECTED (decl)) - add_AT_unsigned (decl_die, DW_AT_accessibility, DW_ACCESS_protected); - else if (TREE_PRIVATE (decl)) - add_AT_unsigned (decl_die, DW_AT_accessibility, DW_ACCESS_private); + add_accessibility_attribute (decl_die, decl); /* Equate decl number to die, so that we can look up this decl later on. */ equate_decl_number_to_die (decl, decl_die); @@ -19534,13 +19539,16 @@ gen_struct_or_union_type_die (tree type, TREE_ASM_WRITTEN (type) = 1; add_byte_size_attribute (type_die, type); if (TYPE_STUB_DECL (type) != NULL_TREE) - add_src_coords_attributes (type_die, TYPE_STUB_DECL (type)); + { + add_src_coords_attributes (type_die, TYPE_STUB_DECL (type)); + add_accessibility_attribute (type_die, TYPE_STUB_DECL (type)); + } /* If the first reference to this type was as the return type of an inline function, then it may not have a parent. Fix this now. */ if (type_die->die_parent == NULL) add_child_die (scope_die, type_die); push_decl_scope (type); gen_member_die (type, type_die); pop_decl_scope (); @@ -19647,6 +19656,8 @@ gen_typedef_die (tree decl, dw_die_ref c TYPE in argument yield the DW_TAG_typedef we have just created. */ equate_type_number_to_die (type, type_die); + + add_accessibility_attribute (type_die, decl); } if (DECL_ABSTRACT (decl)) --- gcc/testsuite/g++.dg/debug/dwarf2/accessibility1.C.jj 2010-06-25 20:17:09.000000000 +0200 +++ gcc/testsuite/g++.dg/debug/dwarf2/accessibility1.C 2010-06-25 20:18:26.000000000 +0200 @@ -0,0 +1,24 @@ +// PR debug/44668 +// { dg-do compile } +// { dg-options "-g -dA" } + +struct C +{ +private: + typedef int a; + a b; + enum g { g1, g2 } h; + struct D { int i; } i; +protected: + typedef int c; + c d; +public: + typedef int e; + e f; +} c; + +// 3 private DW_TAG_member dies, 1 private DW_TAG_typedef, +// 1 private DW_TAG_enumeration_type and 1 private DW_TAG_structure_type +// { dg-final { scan-assembler-times "3\[^\\r\\n\]* DW_AT_accessibility" 6 } } +// 1 private DW_TAG_member die, 1 private DW_TAG_typedef +// { dg-final { scan-assembler-times "2\[^\\r\\n\]* DW_AT_accessibility" 2 } }