From patchwork Mon Aug 3 19:34:45 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Ijaz, Abdul B" X-Patchwork-Id: 140538 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 733B24BB24C6 for ; Mon, 3 Aug 2026 19:37:49 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 733B24BB24C6 Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=D7k6CluI X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.18]) by sourceware.org (Postfix) with ESMTPS id 33BA44BB24D2 for ; Mon, 3 Aug 2026 19:35:55 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 33BA44BB24D2 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 33BA44BB24D2 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=1785785755; cv=none; b=iBjQDHxegSk9WdohRE52LagMmQeXLysACNKMWq6B7hwJ9uJGElAK1NuaTMXpzrzK8Wpyhk1d+lKVymUARqosFABqKHhiaALEGap5AETxvDUeBxfgg79CP6NHrWSzU0EGiWzdjNigTUT5gjP9q5Oz+Nam6qPm86ZN1KDn4WeuMwk= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1785785755; c=relaxed/simple; bh=oJsCtRAGsN02CtnpC5DSegi/dh6DLzI+FP4s4wnQv0g=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=FNIv5Yg7f5XHqU/YvuMkf2751DtVxmSe78FjiqbGCCHiZQh+8qkpJ6QKTpzrcVvTWeFUFe2ZBbD7u/1uyjYhgTgugx2e6swAE0fHDyirXiFH3sg5nYWOnXmlCXRbk32icu6vY62G/AH3tDLnNXL61aABftZQVhxyIDfCFByyyAU= 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=1785785755; x=1817321755; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=oJsCtRAGsN02CtnpC5DSegi/dh6DLzI+FP4s4wnQv0g=; b=D7k6CluIYL2vw8N//M/9yoeOzZ6ROKBLjAHFC6ogxDJhZ+yXVwPKrxWk eYojNJARko7hFj/zNDjWPC4ORS2fSKDakTgAVQ37j4JWKmrslqk9a2skr DUB0zB2XZDAtOdVWUl3mTabpdanr8BbB9iXvtdYNfgsY6ocTLieGASeFz Z6uIfZgkbzD1L2whbjRjS8ilvC/d3XztQqFbw8Em1+vCgMakOyDx3zE6Q qMCiH2rYLjXaJKjvcFQoiLyvOKpWoBvVapqtESNLv7DdJDOHeRFnzODzD nGOyjSHGnvGpzCMDzgsYPwsDNkRWur/KuEhbHAJlTWEy8ivw0uULkDnWZ g==; X-CSE-ConnectionGUID: TZxLW1vIR7GiV2WLozDKYg== X-CSE-MsgGUID: OU+5n1qzRNG+zWWgEmIpGQ== X-IronPort-AV: E=McAfee;i="6800,10657,11864"; a="85462666" X-IronPort-AV: E=Sophos;i="6.25,203,1779174000"; d="scan'208";a="85462666" 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:35:53 -0700 X-CSE-ConnectionGUID: tjCJWUtOQzSuV+4QyvIV2g== X-CSE-MsgGUID: yhCM2DA1SF+JXa5/JiG/eQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.25,203,1779174000"; d="scan'208";a="265139738" 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:35:52 -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 06/10] gdb: Skip trampoline functions for the up command. Date: Mon, 3 Aug 2026 21:34:45 +0200 Message-Id: <20260803193449.33375-7-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 X-Spam-Status: No, score=-11.0 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, SPF_HELO_NONE, TXREP, T_SPF_TEMPERROR shortcircuit=no autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on sourceware.org 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~patchwork=sourceware.org@sourceware.org This change skips trampoline functions when the option 'skip-trampoline-functions' is set to 'on' for the up command. Before this change, GDB processes trampoline functions indicated by the compiler with DIE "DW_AT_trampoline" and stops at the trampoline function for the 'up' command. 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-up 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 'up' command output looks like: ''' (gdb) up \#1 0x0000000000405209 in second_.t74p.t75p () at test.f90:12 12 end function first ''' After this change: ''' (gdb) up \#2 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 | 2 +- gdb/stack.c | 7 +++++++ gdb/testsuite/gdb.fortran/func-trampoline.exp | 12 ++++++++++-- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo index b9dd6c14809..ee94ad09fd9 100644 --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo @@ -6772,7 +6772,7 @@ 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} or @code{reverse-finish}, if +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. diff --git a/gdb/stack.c b/gdb/stack.c index fa217ae9f6f..8b1644ddb6e 100644 --- a/gdb/stack.c +++ b/gdb/stack.c @@ -2636,6 +2636,13 @@ up_silently_base (const char *count_exp) frame = find_relative_frame (get_selected_frame ("No stack."), &count); if (count != 0 && count_exp == NULL) error (_("Initial frame selected; you cannot go up.")); + + if (skip_trampoline_functions) + { + for (int i = 0; (SAFE_TRAMPOLINE_CHAIN (i, frame) + && in_trampoline_frame (frame)); ++i) + frame = get_prev_frame (frame); + } select_frame (frame); } diff --git a/gdb/testsuite/gdb.fortran/func-trampoline.exp b/gdb/testsuite/gdb.fortran/func-trampoline.exp index f330ac54ef2..ce9f14160aa 100644 --- a/gdb/testsuite/gdb.fortran/func-trampoline.exp +++ b/gdb/testsuite/gdb.fortran/func-trampoline.exp @@ -13,8 +13,8 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -# Test "backtrace", "backtrace -n" and "finish" commands for functions with -# trampoline calls. +# Test "backtrace", "backtrace -n", "finish" and "up" commands for +# functions with trampoline calls. require allow_fortran_tests @@ -97,4 +97,12 @@ foreach_with_prefix opt_level {O0 O2} { "${fill}first \\(num1=16, num2=3\\)${fill}" \ "${fill}(\r\nValue returned is $valnum_re = 180)"] } + + with_test_prefix "up" { + init_test $opt_level + + gdb_test "up" [multi_line \ + "#$decimal.* $middle_desc" \ + "${fill}first = second \\(num1 \\+ 4, num2 \\* 3\\).*${fill}"] + } }