From patchwork Thu Jul 29 13:09:32 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 60266 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 60331B70BD for ; Thu, 29 Jul 2010 23:07:14 +1000 (EST) Received: (qmail 30167 invoked by alias); 29 Jul 2010 13:07:12 -0000 Received: (qmail 30147 invoked by uid 22791); 29 Jul 2010 13:07:09 -0000 X-SWARE-Spam-Status: No, hits=-6.1 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; Thu, 29 Jul 2010 13:07:04 +0000 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o6TD72YK029509 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 29 Jul 2010 09:07:03 -0400 Received: from tyan-ft48-01.lab.bos.redhat.com (tyan-ft48-01.lab.bos.redhat.com [10.16.42.4]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o6TD72BC020898 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 29 Jul 2010 09:07:02 -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 o6TD9W2D014254; Thu, 29 Jul 2010 15:09:32 +0200 Received: (from jakub@localhost) by tyan-ft48-01.lab.bos.redhat.com (8.14.4/8.14.4/Submit) id o6TD9Wst014252; Thu, 29 Jul 2010 15:09:32 +0200 Date: Thu, 29 Jul 2010 15:09:32 +0200 From: Jakub Jelinek To: Jason Merrill Cc: gcc-patches@gcc.gnu.org, Tom Tromey , Roland McGrath Subject: [PATCH] Fix up DW_AT_accessibility (PR debug/45124) Message-ID: <20100729130932.GF18378@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! GCC (and GDB too) currently assume that DW_AT_acessibility default is DW_ACCESS_private in DW_TAG_inheritance and DW_ACCESS_public otherwise. But that's not what the standard says, it says (at least for DW_TAG_inheritance/DW_TAG_member/DW_TAG_subprogram) that accessibility default is private in classes and public in structs/unions/interfaces. I've raised the issue on dwarf-discuss whether the same applies to other DIEs and whether its meaning is how I read it (namely, in immediate children of DW_TAG_class_type default is DW_ACCESS_private, in immediate children of DW_TAG_{structure,union,interface}_type default is DW_ACCESS_public and in children of other DIEs it makes no sense. For compatibility with GDB, I believe all we can do is add more DW_AT_accessibility attributes and keep emitting where we were (uselessly) emitting before. Here is a patch that implements that. 2010-07-29 Jakub Jelinek PR debug/45124 * dwarf2out.c (add_accessibility_attribute): Add DW_AT_accessibility DW_ACCESS_public for public children of DW_TAG_class_type. (gen_inheritance_die): Add DW_AT_accessibility DW_ACCESS_private for private children of DIEs other than DW_TAG_class_type. Jakub --- gcc/dwarf2out.c.jj 2010-07-29 10:21:15.000000000 +0200 +++ gcc/dwarf2out.c 2010-07-29 10:53:49.000000000 +0200 @@ -15834,10 +15834,16 @@ add_AT_location_description (dw_die_ref static void add_accessibility_attribute (dw_die_ref die, tree decl) { + /* In DW_TAG_class_type children DW_ACCESS_private is the default + instead of DW_ACCESS_public. Emit DW_ACCESS_private anyway + for compatibility. */ 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); + else if (die->die_parent + && die->die_parent->die_tag == DW_TAG_class_type) + add_AT_unsigned (die, DW_AT_accessibility, DW_ACCESS_public); } /* Attach the specialized form of location attribute used for data members of @@ -19567,10 +19573,15 @@ gen_inheritance_die (tree binfo, tree ac if (BINFO_VIRTUAL_P (binfo)) add_AT_unsigned (die, DW_AT_virtuality, DW_VIRTUALITY_virtual); + /* DW_ACCESS_private is the default accessibility only in DW_TAG_class_type + children, but for compatibility emit DW_ACCESS_public here even + when it is the default. */ if (access == access_public_node) add_AT_unsigned (die, DW_AT_accessibility, DW_ACCESS_public); else if (access == access_protected_node) add_AT_unsigned (die, DW_AT_accessibility, DW_ACCESS_protected); + else if (context_die->die_tag != DW_TAG_class_type) + add_AT_unsigned (die, DW_AT_accessibility, DW_ACCESS_private); } /* Generate a DIE for a class member. */