From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id 8WCDFz/ucGo/awMAWB0awg (envelope-from ) for ; Mon, 03 Aug 2026 15:38:39 -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=KeRvTmKE; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 5B2951E09E; Mon, 03 Aug 2026 15:38:39 -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 [IPv6:2620:52:6:3111::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 575591E099 for ; Mon, 03 Aug 2026 15:38:38 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 325AB4BB24CB for ; Mon, 3 Aug 2026 19:38:37 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 325AB4BB24CB 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=KeRvTmKE Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.18]) by sourceware.org (Postfix) with ESMTPS id 3AE754BB24DC for ; Mon, 3 Aug 2026 19:36:33 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 3AE754BB24DC 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 3AE754BB24DC 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=1785785793; cv=none; b=W5/YirVksCfFrmoBDD7zhClYv9/NNlMVPKcbi/7yf8VjsjdmI4iQ6FYZoRYZsQaUiliC3AhS/NFAMD9EpOI2xuF1bXAiTp0UgbZNYw6/zuHLKe8sw8yalR4opvaYg6GQw9nIAeSXNCWJ20uPwKuPiyjsm7fYv6JWcadgFe+b9yE= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1785785793; c=relaxed/simple; bh=QZ/O7jdkTjjlhwKVy1x6TA3vWCedvq5HOKtQkNCHsMs=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=v6JqHyLJl9ejK6enUn1Ldv+1LS5Q4SwJLj4hJo/hNhhff0sWdxsOXTsnHMMYOQaqbrbAjYoSPUggZpHlMO/1SCHj36fbE2sLktb1d+4MuP34S9VOLc08Lwzg/18cjY6wGshmJi3X34KllqzoIczbQySSaUgRVWTksTRkFzTmeDc= 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=1785785793; x=1817321793; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=QZ/O7jdkTjjlhwKVy1x6TA3vWCedvq5HOKtQkNCHsMs=; b=KeRvTmKEGZ/mzSvR0mrNrSxX+K530YWlUarEpMxqQv7LmZZDcNbV327O BDcCE2n7wKfg5utZM79sRxPrsIESGXOSloa+X7vpM90uXk6MwPKeVdvfZ IzkfpSLfr74VDCksukZAywNH9oHxvPWYfmep4bhZJoo2+Xty4V3tsfJiU iTbK/79B2PBFGLxk1qrWvtszCMhdu8KCkBll34YipxOMqQhM0bo675qUK TAvyPNxpnoVaCTqw0lXI9QfkwUEFK8JZMYNCR8e0tAia3sLoRa0xJ2x7s D3XZ4SsKqxtccZ1Hhi34dCiEZwbp0b/kpq9eTf25wTyF+s/xG78H/ToyV Q==; X-CSE-ConnectionGUID: rvaRcpZ4RDWMlfNgoCLU0Q== X-CSE-MsgGUID: rP2dYunkTjawjhMq6EETBw== X-IronPort-AV: E=McAfee;i="6800,10657,11864"; a="85462703" X-IronPort-AV: E=Sophos;i="6.25,203,1779174000"; d="scan'208";a="85462703" 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:14 -0700 X-CSE-ConnectionGUID: vz3qmQFGTiqXJH5g1P5dYQ== X-CSE-MsgGUID: 02lBiUziQfOVWcpEVzrVow== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.25,203,1779174000"; d="scan'208";a="265139811" 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:12 -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 08/10] gdb, mi: Skip trampoline functions for the -stack-list-frames command. Date: Mon, 3 Aug 2026 21:34:47 +0200 Message-Id: <20260803193449.33375-9-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 '-stack-list-frames' command when the option 'skip-trampoline-functions' is set to 'on'. Before this change, GDB prints the frames indicated by the compiler with DIE "DW_AT_trampoline" in the backtrace for mi command stack-list-frames, but for better user experience, all such frames can be 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-backtrace 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 '-stack-list-frames' command output looks like: ''' (gdb) -stack-list-frames -stack-list-frames ^done, stack=[ frame={level="0",addr="0x0000000000405194",func="second", file="test.f90",fullname="/home/test.f90",line="4", arch="i386:x86-64"}, frame={level="1",addr="0x0000000000405209", func="second_.t74p.t75p", file="test.f90",fullname="/home/test.f90",line="12", arch="i386:x86-64"}, frame={level="2",addr="0x00000000004051e3",func="first", file="test.f90",fullname="/home/test.f90",line="10", arch="i386:x86-64"}, frame={level="3",addr="0x0000000000405309", func="first_.t95p.t96p",file="test.f90", fullname="/home/test.f90",line="21",arch="i386:x86-64"}, frame={level="4",addr="0x0000000000405234", func="func_trampoline",file="test.f90", fullname="/home/test.f90",line="17",arch="i386:x86-64"}] ''' After this change: ''' (gdb) -stack-list-frames -stack-list-frames ^done, stack=[frame={level="0",addr="0x0000000000405194",func="second", file="test.f90",fullname="/home/test.f90",line="4", arch="i386:x86-64"}, frame={level="2",addr="0x00000000004051e3",func="first", file="test.f90",fullname="/home/test.f90",line="10", arch="i386:x86-64"}, frame={level="4",addr="0x0000000000405234", func="func_trampoline",file="test.f90",fullname="/home/test.f90", line="17",arch="i386:x86-64"}] ''' New test gdb.mi/mi-func-trampoline.exp is added for testing the change. --- gdb/doc/gdb.texinfo | 4 +- gdb/mi/mi-cmd-stack.c | 7 +++ gdb/testsuite/gdb.mi/mi-func-trampoline.exp | 69 +++++++++++++++++++++ 3 files changed, 79 insertions(+), 1 deletion(-) create mode 100644 gdb/testsuite/gdb.mi/mi-func-trampoline.exp diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo index b73cdf8b430..684716a869e 100644 --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo @@ -35476,7 +35476,9 @@ an error if @var{low-frame} is larger than the actual number of frames. On the other hand, @var{high-frame} may be larger than the actual number of frames, in which case only existing frames will be returned. If the option @code{--no-frame-filters} is supplied, then -Python frame filters will not be executed. +Python frame filters will not be executed. If the option +@code{skip-trampoline-functions} is set, @value{GDBN} will skip the trampoline +frames while printing a backtrace. @subsubheading @value{GDBN} Command diff --git a/gdb/mi/mi-cmd-stack.c b/gdb/mi/mi-cmd-stack.c index 37a470701af..1f66c02f8b4 100644 --- a/gdb/mi/mi-cmd-stack.c +++ b/gdb/mi/mi-cmd-stack.c @@ -174,6 +174,13 @@ mi_cmd_stack_list_frames (const char *command, const char *const *argv, i++, fi = get_prev_frame (fi)) { QUIT; + if (skip_trampoline_functions) + { + for (int j = 0; (SAFE_TRAMPOLINE_CHAIN (j, fi) + && in_trampoline_frame (fi)); ++j) + fi = get_prev_frame (fi); + } + /* Print the location and the address always, even for level 0. If args is 0, don't print the arguments. */ print_frame_info (user_frame_print_options, diff --git a/gdb/testsuite/gdb.mi/mi-func-trampoline.exp b/gdb/testsuite/gdb.mi/mi-func-trampoline.exp new file mode 100644 index 00000000000..f40a9722f91 --- /dev/null +++ b/gdb/testsuite/gdb.mi/mi-func-trampoline.exp @@ -0,0 +1,69 @@ +# Copyright 2026 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# Test -stack-list-frames command for functions with trampoline +# calls. Also checks if trampoline frames are filtered while printing +# stack. + +require allow_fortran_tests + +if {![test_compiler_info {ifx-*} f90]} { + untested "This test is only applicable for IFX, which emits the\ + trampoline DIE in Dwarf." + return +} + +load_lib fortran.exp +load_lib mi-support.exp + +set MIFLAGS "-i=mi" + +if {[mi_clean_restart]} { + return +} + +set testfile mi-func-trampoline +set srcfile "${srcdir}/gdb.fortran/func-trampoline.f90" +set binfile [standard_output_file $testfile] + +if { [gdb_compile "${srcfile}" "${binfile}" executable \ + {debug f90} ] != "" } { + untested "failed to compile" + return +} + +mi_delete_breakpoints +mi_gdb_reinitialize_dir $srcdir/$subdir +mi_gdb_load ${binfile} + +set inner_loc [gdb_get_line_number "second-breakpt"] +set fill "\[^\r\n\]*" + +set frame1_regx "\{level=\"0\",addr=\"$hex\",func=\"second\",file=\".*func-trampoline.f90\",fullname=\"${fullname_syntax}func-trampoline.f90\",line=\"$inner_loc\",arch=\".*\"\}" +set frame2_regx "\{level=\"2\",addr=\"$hex\",func=\"first\",.*\}" +set frame3_regx "\{level=\"4\",addr=\"$hex\",func=\"func_trampoline\",.*\}" + +# Set breakpoint inside the innermost function 'second'. +mi_create_breakpoint "-t $srcfile:$inner_loc" \ + "insert breakpoint at line $inner_loc " \ + -number 1 -disp del -func second -file ".*trampoline.f90" \ + -line $inner_loc -addr $hex +mi_run_cmd +mi_expect_stop \ + "breakpoint-hit" "second" ".*" ".*trampoline.f90" "\[0-9\]+" { "" "disp=\"del\"" } \ + "run to breakpoint at line $inner_loc" + +mi_gdb_test "100-stack-list-frames" \ + "100\\^done,stack=\\\[frame=${frame1_regx},frame=${frame2_regx},frame=${frame3_regx}\\\]" -- 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.