From patchwork Thu May 26 14:45:06 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dodji Seketeli X-Patchwork-Id: 97585 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 EA7F5B6F90 for ; Fri, 27 May 2011 00:45:35 +1000 (EST) Received: (qmail 14625 invoked by alias); 26 May 2011 14:45:34 -0000 Received: (qmail 14612 invoked by uid 22791); 26 May 2011 14:45:31 -0000 X-SWARE-Spam-Status: No, hits=-5.8 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, 26 May 2011 14:45:09 +0000 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p4QEj9dQ032341 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 26 May 2011 10:45:09 -0400 Received: from localhost (ovpn-113-91.phx2.redhat.com [10.3.113.91]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id p4QEj7JV030628 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 26 May 2011 10:45:08 -0400 Received: by localhost (Postfix, from userid 500) id 681318E604B; Thu, 26 May 2011 16:45:06 +0200 (CEST) From: Dodji Seketeli To: GCC Patches Cc: Jason Merrill , Tom Tromey Subject: [PATCH] PR debug/49047 (linkage name missing for cdtors) X-URL: http://www.redhat.com Mail-Followup-To: GCC Patches , Jason Merrill , Tom Tromey Date: Thu, 26 May 2011 16:45:06 +0200 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux) MIME-Version: 1.0 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 Hello, The constructors (resp. destructors) of a given class K are cloned. For each constructor (resp. destructor) There is thus an abstract version of the function and (at least) a concrete version that actually contains the code of the abstract version. The debug info generated for a constructor (resp. destructor) lacks linkage name (DWARF attribute DW_AT_MIPS_linkage_name), making the job of GDB slow and difficult when it tries to get the actual concrete function that contains the constructor's code to, e.g, set a breakpoint. The patch below emits that linkage name for those concrete versions of cloned public functions. Tested on x86-64-unknown-linux-gnu against trunk. 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 | 11 +++++++++++ gcc/testsuite/g++.dg/debug/dwarf2/cdtor-1.C | 17 +++++++++++++++++ 2 files changed, 28 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..85c01b1 100644 --- a/gcc/dwarf2out.c +++ b/gcc/dwarf2out.c @@ -19601,6 +19601,7 @@ gen_subprogram_die (tree decl, dw_die_ref context_die) dw_die_ref old_die = lookup_decl_die (decl); int declaration = (current_function_decl != decl || class_or_namespace_scope_p (context_die)); + bool fn_has_code_addr_p = false; premark_used_types (); @@ -19769,6 +19770,7 @@ gen_subprogram_die (tree decl, dw_die_ref context_die) /* We have already generated the labels. */ add_AT_lbl_id (subr_die, DW_AT_low_pc, fde->dw_fde_begin); add_AT_lbl_id (subr_die, DW_AT_high_pc, fde->dw_fde_end); + fn_has_code_addr_p = true; } else { @@ -19780,6 +19782,7 @@ gen_subprogram_die (tree decl, dw_die_ref context_die) ASM_GENERATE_INTERNAL_LABEL (label_id, FUNC_END_LABEL, current_function_funcdef_no); add_AT_lbl_id (subr_die, DW_AT_high_pc, label_id); + fn_has_code_addr_p = true; } #if VMS_DEBUGGING_INFO @@ -19929,6 +19932,14 @@ gen_subprogram_die (tree decl, dw_die_ref context_die) if (cfun->static_chain_decl) add_AT_location_description (subr_die, DW_AT_static_link, loc_list_from_tree (cfun->static_chain_decl, 2)); + + if (fn_has_code_addr_p && origin && 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); } /* Generate child dies for template paramaters. */ 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 } }