From patchwork Thu May 26 20:03:33 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Dodji Seketeli X-Patchwork-Id: 97621 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 A859EB6F8E for ; Fri, 27 May 2011 06:03:56 +1000 (EST) Received: (qmail 21785 invoked by alias); 26 May 2011 20:03:54 -0000 Received: (qmail 21776 invoked by uid 22791); 26 May 2011 20:03:53 -0000 X-SWARE-Spam-Status: No, hits=-1.9 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from seketeli.net (HELO ms.seketeli.net) (91.121.166.71) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 26 May 2011 20:03:35 +0000 Received: from localhost (torimasen.com [82.237.12.13]) by ms.seketeli.net (Postfix) with ESMTP id 7E1FAEA04B; Thu, 26 May 2011 22:02:59 +0200 (CEST) Received: by localhost (Postfix, from userid 500) id 324618E604B; Thu, 26 May 2011 22:03:33 +0200 (CEST) From: Dodji Seketeli To: Jason Merrill Cc: GCC Patches , Tom Tromey Subject: Re: [PATCH] PR debug/49047 (linkage name missing for cdtors) References: <4DDE6F74.1030509@redhat.com> X-URL: http://www.seketeli.net/~dodji Mail-Followup-To: Jason Merrill , GCC Patches , Tom Tromey Date: Thu, 26 May 2011 22:03:33 +0200 In-Reply-To: <4DDE6F74.1030509@redhat.com> (Jason Merrill's message of "Thu, 26 May 2011 11:19:16 -0400") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux) MIME-Version: 1.0 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 Jason Merrill a écrit: > Why not just call add_linkage_name after add_abstract_origin_attribute? That is what I first did and it worked for this case. But then I wasn't sure if there could be cases where a function DIE would have the DW_AT_abstract_origin set, but won't have any actual code? For instance if the function has DECL_EXTERNAL set. That's why I wanted to call add_linkage_name only if the function has DW_AT_{low,high}_pc so that I am sure it contains actual code. If my concern is not justified then I guess the patch below should be enough then. gcc/ * dwarf2out.c (gen_subprogram_die): Emit linkage name attribute for functions containing actual code for public cloned abstract functions. gcc/testsuite/ * g++.dg/debug/dwarf2/cdtor-1.C: New test. --- gcc/dwarf2out.c | 7 +++++++ gcc/testsuite/g++.dg/debug/dwarf2/cdtor-1.C | 17 +++++++++++++++++ 2 files changed, 24 insertions(+), 0 deletions(-) create mode 100644 gcc/testsuite/g++.dg/debug/dwarf2/cdtor-1.C diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c index 55453a3..0cf782f 100644 --- a/gcc/dwarf2out.c +++ b/gcc/dwarf2out.c @@ -19636,6 +19636,13 @@ gen_subprogram_die (tree decl, dw_die_ref context_die) subr_die = new_die (DW_TAG_subprogram, context_die, decl); add_abstract_origin_attribute (subr_die, origin); + if (TREE_PUBLIC (origin)) + /* So this is where the actual code for a publicly accessible + cloned function is. Let's emit linkage name attribute for + it. This helps debuggers to e.g, set breakpoints into + constructors/destructors when the user asks "break + K::K". */ + add_linkage_name (subr_die, decl); } else if (old_die) { diff --git a/gcc/testsuite/g++.dg/debug/dwarf2/cdtor-1.C b/gcc/testsuite/g++.dg/debug/dwarf2/cdtor-1.C new file mode 100644 index 0000000..6d39e54 --- /dev/null +++ b/gcc/testsuite/g++.dg/debug/dwarf2/cdtor-1.C @@ -0,0 +1,17 @@ +// origin PR debug/49047 +// { dg-options "-g -dA" } +// { dg-do compile } + +struct K +{ + K () { } + ~K () { } +}; + +int +main() +{ + K k; +} + +// { dg-final {scan-assembler-times "\[^\n\r\]*DW_AT_MIPS_linkage_name:" 2 } }