From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id OTcFGOXtcGo/awMAWB0awg (envelope-from ) for ; Mon, 03 Aug 2026 15:37:09 -0400 Authentication-Results: simark.ca; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=DedW9h2g; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 5CCAE1E09E; Mon, 03 Aug 2026 15:37:09 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-6.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=4.0.1 Received: from vm01.sourceware.org (vm01.sourceware.org [38.145.34.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 9E84D1E099 for ; Mon, 03 Aug 2026 15:37:08 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 89D634BB24D4 for ; Mon, 3 Aug 2026 19:37:07 +0000 (GMT) Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.18]) by sourceware.org (Postfix) with ESMTPS id 3CE5D4BB24DB for ; Mon, 3 Aug 2026 19:36:30 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 3CE5D4BB24DB Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=intel.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 3CE5D4BB24DB Authentication-Results: sourceware.org; arc=none smtp.remote-ip=192.198.163.18 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1785785790; cv=none; b=tWNdkFUqcbj2j6aAx3ps0E2Y9/Pfh6eHFDVMLtP1b6ZcUqtHp0Nr+uZdRrTnZ/9o65K2ssocd/YpxmjYKFQmXb+H45GP+haFD8R2cmCWium06LzkUKGKTgHFijLzxGq5mXaxIT5JKtRSbfBaXjECg/fLygRTUr82WdX2AHeAHGA= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1785785790; c=relaxed/simple; bh=CpeGd7VbW0RUECbdG4SnmMo7G7c4Cn+AHcOd9ucM1s8=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=ANAZXVuYRruRlhYge05F90TwXn2VglyEjW5Sh9gc0v/hsuzphOmFlosFITWowsmvnVEfBQMlWxQF0MRW3KDLH+6g5AOZxJgOIZ1+DS772xdul2An7kzoinYW1K7jYBaIjY1RK4CUycUt6aLmM6oyjvSoawHxK5AWQxQCYP7grT0= ARC-Authentication-Results: i=1; sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1785785790; x=1817321790; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=CpeGd7VbW0RUECbdG4SnmMo7G7c4Cn+AHcOd9ucM1s8=; b=DedW9h2ga4KIbhzC1vurXneUNGTRCdDMMpYMTFBxczAjP7NlcRQ5o2KL UHie/MCfGte/bmoHMto5LY1iuwefnQcvlaf3mtQMezmxIqgxA+28r4t9o RzNfXGOqgED2qougHZC0bs6srLwQ4qXkbRKjMgrm87WdtviFlhT/ckImu nakZWRzwuDxFeVpIE4fmtq3tjB0v7+ylf/KI5cUkBC+9aC8tjWStA3frx rWLDJJelqUoH7sy6pOL5tjzc15rCg1kf1Dbj4/ElGbykXRlJukbjFipYB bqKkySfmCdCT7mZxscqiWAVvKz/SgXIJcn23O676CMa/S5Jbd0niJVQqx A==; X-CSE-ConnectionGUID: 476At66zRIeZD6snT/x3Yw== X-CSE-MsgGUID: 7A9Dt7eQTU2WlwBcUQGHcA== X-IronPort-AV: E=McAfee;i="6800,10657,11864"; a="85462685" X-IronPort-AV: E=Sophos;i="6.25,203,1779174000"; d="scan'208";a="85462685" Received: from orviesa004.jf.intel.com ([10.64.159.144]) by fmvoesa112.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Aug 2026 12:36:04 -0700 X-CSE-ConnectionGUID: Dz96ryExQIKA4AJDEhqKWA== X-CSE-MsgGUID: K7+NFDaFTgi2LK0dQ+EGgA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.25,203,1779174000"; d="scan'208";a="265139796" Received: from fdaddami-mobl1.amr.corp.intel.com (HELO localhost) ([10.245.115.173]) by orviesa004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Aug 2026 12:36:03 -0700 From: Abdul Basit Ijaz To: gdb-patches@sourceware.org Cc: abdul.b.ijaz@intel.com, JiniSusan.George@amd.com, tom@tromey.com, eliz@gnu.org Subject: [PATCH v11 07/10] gdb: Skip trampoline functions for the return command. Date: Mon, 3 Aug 2026 21:34:46 +0200 Message-Id: <20260803193449.33375-8-abdul.b.ijaz@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260803193449.33375-1-abdul.b.ijaz@intel.com> References: <20260803193449.33375-1-abdul.b.ijaz@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~public-inbox=simark.ca@sourceware.org This change skips trampoline functions for the return command when the option 'skip-trampoline-functions' is set to 'on'. Before this change, GDB processes trampoline functions indicated by the compiler with DIE "DW_AT_trampoline" for the return command and stops at the trampoline functions. For better user experience, all such frames can be skipped and hidden from the user. In this example the IFX compiler emits "DW_AT_trampoline" tag for the 'first' and 'second' trampoline functions like following: function second (x, y) result(z) integer, intent(in) :: x, y integer :: z z = x * y ! breakpt-return end function second function first (num1, num2) result(total) integer, intent(in) :: num1, num2 integer :: total total = second (num1 + 4, num2 * 3) ! first-breakpt total = total + 30 end function first Related Dwarf: 0x0000013f: DW_TAG_subprogram DW_AT_low_pc (0x0000000000404350) DW_AT_high_pc (0x000000000040435f) DW_AT_frame_base (DW_OP_reg6 RBP) DW_AT_linkage_name ("second_.t74p.t75p") DW_AT_name ("second_.t74p.t75p") DW_AT_trampoline ("second_") 0x0000015a: DW_TAG_subprogram DW_AT_low_pc (0x00000000004044a0) DW_AT_high_pc (0x00000000004044af) DW_AT_frame_base (DW_OP_reg6 RBP) DW_AT_linkage_name ("first_.t104p.t105p") DW_AT_name ("first_.t104p.t105p") DW_AT_trampoline ("first_") Before this change, the return command output looks like: ''' (gdb) return Make second return now? (y or n) y \#0 0x0000000000405209 in second_.t74p.t75p () at test.f90:12 12 end function first ''' After this change: ''' (gdb) return Make second return now? (y or n) y \#0 0x00000000004051e3 in first (num1=16, num2=3) at test.f90:10 10 total = second (num1 + 4, num2 * 3) ! first-breakpt ''' The test gdb.fortran/func-trampoline.exp is updated for testing this change. --- gdb/doc/gdb.texinfo | 6 +++--- gdb/stack.c | 11 +++++++++++ gdb/testsuite/gdb.fortran/func-trampoline.exp | 10 +++++++++- 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo index ee94ad09fd9..b73cdf8b430 100644 --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo @@ -6772,9 +6772,9 @@ DWARF trampolines marked via DW_AT_trampoline are supported by this. When issuing a @code{backtrace}, if @code{skip-trampoline-functions} is set, @value{GDBN} will skip trampoline frames while printing the stack. -When issuing a @code{finish}, @code{reverse-finish} or @code{up}, if -@code{skip-trampoline-functions} is set, @value{GDBN} will skip trampoline -frames while returning from the target function. +When issuing a @code{finish}, @code{reverse-finish}, @code{up} or +@code{return}, if @code{skip-trampoline-functions} is set, @value{GDBN} will +skip trampoline frames while returning from the target function. Currently, only DWARF trampolines marked via DW_AT_trampoline are supported by this. diff --git a/gdb/stack.c b/gdb/stack.c index 8b1644ddb6e..90d6fef6824 100644 --- a/gdb/stack.c +++ b/gdb/stack.c @@ -2839,6 +2839,17 @@ return_command (const char *retval_exp, int from_tty) if (get_frame_type (get_current_frame ()) == DUMMY_FRAME) frame_pop (get_current_frame ()); + if (skip_trampoline_functions) + { + frame_info_ptr ret_frame = get_current_frame (); + for (int i = 0; (SAFE_TRAMPOLINE_CHAIN (i, ret_frame) + && in_trampoline_frame (ret_frame)); ++i) + { + frame_pop (ret_frame); + ret_frame = get_current_frame (); + } + } + select_frame (get_current_frame ()); /* If interactive, print the frame that is now current. */ if (from_tty) diff --git a/gdb/testsuite/gdb.fortran/func-trampoline.exp b/gdb/testsuite/gdb.fortran/func-trampoline.exp index ce9f14160aa..4f91aa17860 100644 --- a/gdb/testsuite/gdb.fortran/func-trampoline.exp +++ b/gdb/testsuite/gdb.fortran/func-trampoline.exp @@ -13,7 +13,7 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -# Test "backtrace", "backtrace -n", "finish" and "up" commands for +# Test "backtrace", "backtrace -n", "finish", "up" and "return" commands for # functions with trampoline calls. require allow_fortran_tests @@ -105,4 +105,12 @@ foreach_with_prefix opt_level {O0 O2} { "#$decimal.* $middle_desc" \ "${fill}first = second \\(num1 \\+ 4, num2 \\* 3\\).*${fill}"] } + + with_test_prefix "return" { + init_test $opt_level + + gdb_test "return" \ + ".*first = second \\(num1 \\+ 4, num2 \\* 3\\) \\! first-breakpt" \ + "" "Make second return now.*y or n. $" "y" + } } -- 2.34.1 ________________________________________ Intel Deutschland GmbH Registered Address: Dornacher Strasse 1, 85622 Feldkirchen, Germany Tel: +49 (89) 99143-0 www.intel.de Managing Directors: Candice Moore, Jeffrey Schneiderman, Ramachandran Sitaraman Chairperson of the Supervisory Board: Sonja Pierer Registered Seat: Munich Commercial Register B: Amtsgericht Munich HRB 186928 This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). Any review or distribution by others is strictly prohibited. If you are not the intended recipient, please contact the sender and delete all copies.