From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by sourceware.org (Postfix) with ESMTP id B4C3F386103C for ; Mon, 4 Jan 2021 21:46:03 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org B4C3F386103C Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-572-pKIiBDS0MrCtzM8LPIhmTg-1; Mon, 04 Jan 2021 16:46:01 -0500 X-MC-Unique: pKIiBDS0MrCtzM8LPIhmTg-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 620701005504; Mon, 4 Jan 2021 21:46:00 +0000 (UTC) Received: from localhost.localdomain (ovpn-114-95.phx2.redhat.com [10.3.114.95]) by smtp.corp.redhat.com (Postfix) with ESMTP id D2DFA60BE5; Mon, 4 Jan 2021 21:45:59 +0000 (UTC) Subject: Re: [PATCH] Add line debug info for virtual thunks (PR ipa/97937) To: Bernd Edlinger , "gcc-patches@gcc.gnu.org" , Richard Biener , Jakub Jelinek , Alexandre Oliva References: From: Jeff Law Message-ID: <6fe16e71-1a72-2c9d-11f2-642f9da8539b@redhat.com> Date: Mon, 4 Jan 2021 14:45:59 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.6.0 MIME-Version: 1.0 In-Reply-To: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=WINDOWS-1252 Content-Transfer-Encoding: 8bit Content-Language: en-US X-Spam-Status: No, score=-11.8 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, NICE_REPLY_A, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 04 Jan 2021 21:46:05 -0000 On 1/4/21 1:06 PM, Bernd Edlinger wrote: > Hi, > > > currently there is a problem when debugging a virtual thunk. That is > a decl with DECL_IGNORED_P. Currently the line information displayed > in gdb is completely bogus, thus the last line of whatever function > is immediately before the PC of the thunk. > > This patch improves the debug experience at least a bit by emitting > at the line number information where the thunk has been defined. > I do not dare to touch anything but dwarf2 debug info, therefore > the patch is a bit awkward. > > > Bootstrapped and reg-tested on x86_64-pc-linux-gnu. > Is it OK for trunk? > > > Thanks > Bernd. > > 0001-Add-line-debug-info-for-virtual-thunks.patch > > From 0a44bb870e90623689cae484f8a8899706480876 Mon Sep 17 00:00:00 2001 > From: Bernd Edlinger > Date: Sun, 3 Jan 2021 11:18:39 +0100 > Subject: [PATCH] Add line debug info for virtual thunks > > There is no full debug info since the DECL_IGNORED_P > flag is set on virtual thunks. > But instead of no line info at all, emit at least > the location of the function decl. > > 2021-01-03 Bernd Edlinger > > PR ipa/97937 > * final.c (final_start_function_1): Always emit function start line > information for dwarf2 debug. > (final_end_function): Always call end_function for dwarf2 debug. > * varasm.c (assemble_start_function): Always call begin_function > for dwarf2 debug. > --- > gcc/final.c | 9 +++++++-- > gcc/varasm.c | 2 +- > 2 files changed, 8 insertions(+), 3 deletions(-) > > diff --git a/gcc/final.c b/gcc/final.c > index fc9a05e..5a274c1 100644 > --- a/gcc/final.c > +++ b/gcc/final.c > @@ -1735,7 +1735,12 @@ final_start_function_1 (rtx_insn **firstp, FILE *file, int *seen, > last_filename); > > if (!dwarf2_debug_info_emitted_p (current_function_decl)) > - dwarf2out_begin_prologue (0, 0, NULL); > + { > + if (write_symbols == DWARF2_DEBUG) > + dwarf2out_begin_prologue (last_linenum, last_columnnum, last_filename); > + else > + dwarf2out_begin_prologue (0, 0, NULL); > + } The only way you're getting into this code is for DEBUG_DWARF2 and VMS_AND_DWARF2_DEBUG and in the latter case we want to make the same fix.  So drop the newly added conditional and just make the code something like this: if (!dwarf2_debug_info_emitted_p (current_function_decl))   dwarf2out_begin_prologue (last_linenum, last_columnnum, last_filename) > > #ifdef LEAF_REG_REMAP > if (crtl->uses_only_leaf_regs) > @@ -1879,7 +1884,7 @@ final_end_function (void) > { > app_disable (); > > - if (!DECL_IGNORED_P (current_function_decl)) > + if (!DECL_IGNORED_P (current_function_decl) || write_symbols == DWARF2_DEBUG) > debug_hooks->end_function (high_function_linenum); > > /* Finally, output the function epilogue: > diff --git a/gcc/varasm.c b/gcc/varasm.c > index ce5d449..513922d 100644 > --- a/gcc/varasm.c > +++ b/gcc/varasm.c > @@ -1930,7 +1930,7 @@ assemble_start_function (tree decl, const char *fnname) > ASM_OUTPUT_FUNCTION_PREFIX (asm_out_file, fnname); > #endif > > - if (!DECL_IGNORED_P (decl)) > + if (!DECL_IGNORED_P (decl) || write_symbols == DWARF2_DEBUG) > (*debug_hooks->begin_function) (decl); I'd drop the DWARF2_DEBUG conditionals in these two hunks as well.  There's no reason why we wouldn't want to emit suitable debug information for other formats.  Jeff