From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from eggs.gnu.org (eggs.gnu.org [IPv6:2001:470:142:3::10]) by sourceware.org (Postfix) with ESMTPS id 99C313851ABA for ; Mon, 5 Jun 2023 12:07:15 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 99C313851ABA Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gnu.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gnu.org Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q68zP-0006nn-OD; Mon, 05 Jun 2023 08:07:13 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=G4zlCWFUlPtfvNQocamd/OoPYRiXOtY3FYiw8/v74qg=; b=jip9MXKWxcwh /Kdbq5m2m0ZGosrXLDcTJQVZBeR4QifUhFNwiS+ldMDlIFazDagq/rhG4X+dma/RmfbZn4B4r8m8+ z2nM7mvKpDyIknfjz3lrTLVjnDszz87AXRUy+D1dY0E5sDCqwnKXCLzURwbZvu61EF09NMPgR4TPT gdplDE9IgU2R5ReEEyTQafBInhM3SDYUNFgM2UvGIbaSjMU+jDgonDAuXv2M1KyuPJ4YFtYPXvkae vSUmguh8c2H6VY3SuthI9sZ/ZBGXLpEmU2r9zxt1wisMDRPjwB7thrENhkc1R0KBTZ30PVbAEJsjL DPnJnUp00C1HT/5z7ouHTQ==; Received: from [87.69.77.57] (helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q68zN-000829-1p; Mon, 05 Jun 2023 08:07:11 -0400 Date: Mon, 05 Jun 2023 15:07:07 +0300 Message-Id: <83jzwi3yfo.fsf@gnu.org> From: Eli Zaretskii To: Abdul Basit Ijaz Cc: gdb-patches@sourceware.org, JiniSusan.George@amd.com, tom@tromey.com, nils-christian.kempke@intel.com In-Reply-To: <20230605110410.3078-4-abdul.b.ijaz@intel.com> (message from Abdul Basit Ijaz via Gdb-patches on Mon, 5 Jun 2023 13:04:09 +0200) Subject: Re: [PATCH v2 3/4] gdb/infrun: handle stepping through functions with DW_AT_trampoline References: <20230605110410.3078-1-abdul.b.ijaz@intel.com> <20230605110410.3078-4-abdul.b.ijaz@intel.com> X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_BARRACUDACENTRAL,SPF_HELO_PASS,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: > Cc: abdul.b.ijaz@intel.com, JiniSusan.George@amd.com, tom@tromey.com, > Nils-Christian Kempke > Date: Mon, 5 Jun 2023 13:04:09 +0200 > From: Abdul Basit Ijaz via Gdb-patches > > gdb/NEWS | 14 + > gdb/doc/gdb.texinfo | 36 +++ > gdb/infrun.c | 81 +++++- > gdb/infrun.h | 4 + > .../gdb.dwarf2/dw2-function-trampolines.c | 80 ++++++ > .../gdb.dwarf2/dw2-function-trampolines.exp | 245 ++++++++++++++++++ > 6 files changed, 456 insertions(+), 4 deletions(-) > create mode 100644 gdb/testsuite/gdb.dwarf2/dw2-function-trampolines.c > create mode 100644 gdb/testsuite/gdb.dwarf2/dw2-function-trampolines.exp Thanks. > diff --git a/gdb/NEWS b/gdb/NEWS > index c0aac212e30..d349791de62 100644 > --- a/gdb/NEWS > +++ b/gdb/NEWS > @@ -342,6 +342,20 @@ GDB now supports floating-point on LoongArch GNU/Linux. > > * New commands > > +set skip-trampoline-functions on|off > +show skip-trampoline-functions > + This controls whether GDB's stepping behavior will recognize function calls > + that have been marked as trampolines in the debug info. It improves > + stepping behavior in that it steps through trampoline code and hides it from > + the user. GDB can now step through trampolines that are correctly marked as > + such in the compiler's debug info. If the target of a trampoline is unknown, > + GDB will continue until the trampoline section is left again and only then > + hand control back to the user. GDB does this even if the trampoline has no > + associated line info. If this is turned off, GDB will step into trampolines > + if there is line table information for them or step over the trampoline calls > + if there is no line table information. Currently, only DWARF trampolines > + are supported. This part is OK, but I'd suggest to say what is the default (I'm guessing ON). > --- a/gdb/doc/gdb.texinfo > +++ b/gdb/doc/gdb.texinfo > @@ -6366,6 +6366,42 @@ debug information. This is the default. > Show whether @value{GDBN} will stop in or step over functions without > source line debug information. > > +@kindex set skip-trampoline-functions > +@item set skip-trampoline-functions > +@cindex trampoline functions > +@cindex stepping through trampoline functions > +@itemx set skip-trampoline-functions on Please move all the index entries before all the @item/@itemx. This is so index-search in an Info reader will place the reader before the text, not in its middle. > +When calling a function in any language, some compilers might generate > +so-called trampoline functions, which wrap the actual function call (the "trampoline functions" should be in @dfn, since you are introducing new terminology. > +target of the trampoline). The compiler might mark such a trampoline in its > +debug information. Often, such trampolines do not have any source line > +information associated with them which will lead the @code{step} command to > +behave like a @code{next} and skip the function call completely. > + > +The @code{set skip-trampoline-functions on} command will cause the @code{step} > +command to treat these trampolines differently. When issuing a @code{step} at > +the call site of a trampoline function if @code{skip-trampoline-functions} is > +set @value{GDBN} will attempt to determine the target of the trampoline and > +then step through the trampoline stopping at the target. If the target could > +not be found or was not given in the debug info, @value{GDBN} will simply > +continue execution until it leaves the trampoline code again, even if the > +trampoline has no line info associated with it. When returning from a target > +function call and stepping back into the trampoline, @value{GDBN} will again > +step through the trampoline towards the call site. > +Additionally, even if stopped in a trampoline function with source line > +information, issuing a @code{step} will prompt @value{GDBN} to resume execution > +until leaving the trampoline region again. The @code{stepi} command is not > +affected by the setting which is enabled by default. Currently, only > +DWARF trampolines marked via DW_AT_trampoline are supported by this. Again, this should say what is the default of this setting. Reviewed-By: Eli Zaretskii