Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Abdul Basit Ijaz <abdul.b.ijaz@intel.com>
To: gdb-patches@sourceware.org
Cc: abdul.b.ijaz@intel.com, JiniSusan.George@amd.com, tom@tromey.com,
	eliz@gnu.org
Subject: [PATCH v11 09/10] gdb, mi: Skip trampoline functions for the -stack-list-arguments command.
Date: Mon,  3 Aug 2026 21:34:48 +0200	[thread overview]
Message-ID: <20260803193449.33375-10-abdul.b.ijaz@intel.com> (raw)
In-Reply-To: <20260803193449.33375-1-abdul.b.ijaz@intel.com>

This change skips trampoline functions for the '-stack-list-arguments'
command when the option 'skip-trampoline-functions' is set to 'on'.  Before
this change, GDB prints the arguments of frames indicated by the
compiler with DIE "DW_AT_trampoline" in the backtrace for the mi command
stack-list-arguments, 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-args
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-arguments' command output looks like:

'''
(gdb)
-stack-list-arguments 0
^done,
stack-args=[
frame={level="0",args=[name="x",name="y"]},
frame={level="1",args=[]},
frame={level="2",args=[name="num1",name="num2"]},
frame={level="3",args=[]},
frame={level="4",args=[]}]
'''

After change:

'''
(gdb)
-stack-list-arguments 0
^done,
stack-args=[
frame={level="0",args=[name="x",name="y"]},
frame={level="1",args=[name="num1",name="num2"]},
frame={level="2",args=[]}]
'''

The test gdb.mi/mi-func-treampoline is updated for testing the change.
---
 gdb/doc/gdb.texinfo                         |  3 +++
 gdb/mi/mi-cmd-stack.c                       |  7 +++++++
 gdb/testsuite/gdb.mi/mi-func-trampoline.exp | 13 ++++++++++---
 3 files changed, 20 insertions(+), 3 deletions(-)

diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
index 684716a869e..99909984241 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -35815,6 +35815,9 @@ variable object is updated, @value{GDBN} makes sure that the
 thread/frame combination the variable object is bound to still exists,
 and re-evaluates the variable object in context of that thread/frame.
 
+If the option @code{skip-trampoline-functions} is set, @value{GDBN} will
+not show trampoline functions in the stack.
+
 The following is the complete set of @sc{gdb/mi} operations defined to
 access this functionality:
 
diff --git a/gdb/mi/mi-cmd-stack.c b/gdb/mi/mi-cmd-stack.c
index 1f66c02f8b4..66c758bd44e 100644
--- a/gdb/mi/mi-cmd-stack.c
+++ b/gdb/mi/mi-cmd-stack.c
@@ -401,6 +401,13 @@ mi_cmd_stack_list_args (const char *command, const char *const *argv, int argc)
 	   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);
+	    }
+
 	  ui_out_emit_tuple tuple_emitter (uiout, "frame");
 	  uiout->field_signed ("level", i);
 	  list_args_or_locals (user_frame_print_options,
diff --git a/gdb/testsuite/gdb.mi/mi-func-trampoline.exp b/gdb/testsuite/gdb.mi/mi-func-trampoline.exp
index f40a9722f91..4e0c3922eb6 100644
--- a/gdb/testsuite/gdb.mi/mi-func-trampoline.exp
+++ b/gdb/testsuite/gdb.mi/mi-func-trampoline.exp
@@ -13,9 +13,9 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/> .
 
-# Test -stack-list-frames command for functions with trampoline
-# calls.  Also checks if trampoline frames are filtered while printing
-# stack.
+# Test -stack-list-frames and -stack-list-arguments command for functions
+# with trampoline calls.  Also checks if trampoline frames are filtered
+# while printing stack.
 
 require allow_fortran_tests
 
@@ -55,6 +55,10 @@ set frame1_regx "\{level=\"0\",addr=\"$hex\",func=\"second\",file=\".*func-tramp
 set frame2_regx "\{level=\"2\",addr=\"$hex\",func=\"first\",.*\}"
 set frame3_regx "\{level=\"4\",addr=\"$hex\",func=\"func_trampoline\",.*\}"
 
+set arg1_regx "\{level=\"0\",args=\\\[name=\"x\",name=\"y\"\\\]\}"
+set arg2_regx "\{level=\"1\",args=\\\[name=\"num1\",name=\"num2\"\\\]\}"
+set arg3_regx "\{level=\"2\",args=\\\[\\\]\}"
+
 # Set breakpoint inside the innermost function 'second'.
 mi_create_breakpoint "-t $srcfile:$inner_loc" \
     "insert breakpoint at line $inner_loc " \
@@ -67,3 +71,6 @@ mi_expect_stop \
 
 mi_gdb_test "100-stack-list-frames" \
     "100\\^done,stack=\\\[frame=${frame1_regx},frame=${frame2_regx},frame=${frame3_regx}\\\]"
+
+mi_gdb_test "200-stack-list-arguments 0" \
+    "200\\^done,stack-args=\\\[frame=${arg1_regx},frame=${arg2_regx},frame=${arg3_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.


  parent reply	other threads:[~2026-08-03 19:37 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-03 19:34 [PATCH v11 00/10] GDB support for DW_AT_trampoline Abdul Basit Ijaz
2026-08-03 19:34 ` [PATCH v11 01/10] gdb, dwarf: add support for DW_AT_trampoline in DWARF reader Abdul Basit Ijaz
2026-08-03 19:34 ` [PATCH v11 02/10] gdb/symtab: add lookup for trampoline functions Abdul Basit Ijaz
2026-08-03 19:34 ` [PATCH v11 03/10] gdb: handle stepping through functions with DW_AT_trampoline Abdul Basit Ijaz
2026-08-03 19:34 ` [PATCH v11 04/10] gdb: Skip trampoline frames for the backtrace command Abdul Basit Ijaz
2026-08-03 19:34 ` [PATCH v11 05/10] gdb: Skip trampoline functions for the finish and reverse-finish commands Abdul Basit Ijaz
2026-08-03 19:34 ` [PATCH v11 06/10] gdb: Skip trampoline functions for the up command Abdul Basit Ijaz
2026-08-03 19:34 ` [PATCH v11 07/10] gdb: Skip trampoline functions for the return command Abdul Basit Ijaz
2026-08-03 19:34 ` [PATCH v11 08/10] gdb, mi: Skip trampoline functions for the -stack-list-frames command Abdul Basit Ijaz
2026-08-03 19:34 ` Abdul Basit Ijaz [this message]
2026-08-03 19:34 ` [PATCH v11 10/10] gdb: Filter trampoline frames in backtrace when using Python frame-filters Abdul Basit Ijaz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260803193449.33375-10-abdul.b.ijaz@intel.com \
    --to=abdul.b.ijaz@intel.com \
    --cc=JiniSusan.George@amd.com \
    --cc=eliz@gnu.org \
    --cc=gdb-patches@sourceware.org \
    --cc=tom@tromey.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox