Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: "Ijaz, Abdul B" <abdul.b.ijaz@intel.com>
To: Tom Tromey <tom@tromey.com>
Cc: "gdb-patches@sourceware.org" <gdb-patches@sourceware.org>,
	"JiniSusan.George@amd.com" <JiniSusan.George@amd.com>,
	"eliz@gnu.org" <eliz@gnu.org>,
	"Ijaz, Abdul B" <abdul.b.ijaz@intel.com>
Subject: RE: [PATCH v11 10/10] gdb: Filter trampoline frames in backtrace when using Python frame-filters.
Date: Thu, 22 Oct 2026 17:04:24 +0000	[thread overview]
Message-ID: <SA1PR11MB684689C62155BCF81A78A7CDCB652@SA1PR11MB6846.namprd11.prod.outlook.com> (raw)
In-Reply-To: <8733tyu5q0.fsf@tromey.com>

Thanks Tom, for the feedback.

Please see the inline reply below:

>> +  if (skip_trampoline_functions)
>> +    {
>> +      for (int i = 0; (SAFE_TRAMPOLINE_CHAIN (i, frame)
>> +		       && in_trampoline_frame (frame)); ++i)
>> +	{
>> +	  frame = get_prev_frame (frame);
>> +	  if (frame ==  nullptr)
>> +	    return nullptr;
>> +	}
>> +    }

Tom> This seems suspicious to me.
Tom> For one thing, suppose you have A -> Trampoline -> B.  Then in Python you fetch the frame B.  What does B.newer() return?
Tom> I think with this code it will just return B again.

Abdul> You are right that newer () returns the same frame again, and it is a real problem, though for the caller: with A calling the trampoline and the trampoline calling B, it is A.newer () that returns A again, while B.newer () is not affected.  Since every gdb.Frame of a trampoline is turned into the next outer frame, the frame object that A.newer () returns for the trampoline behaves as A, so walking newer () never gets back to B.

For example, with ifx and gdb.fortran/func-trampoline.f90, the call stack is:
  func_trampoline -> first_.t95p.t96p -> first -> second_.t74p.t75p -> second

where first_.t95p.t96p and second_.t74p.t75p are the trampolines. Stopped in "second":

  (gdb) python f2 = gdb.selected_frame().older()
  (gdb) python print(f2.level(), f2.name())
  2 first
  (gdb) python print(f2.newer().level(), f2.newer().name())
  2 first

Here f2.newer () should return "second" (level 0), or the trampoline second_.t74p.t75p at level 1, but not "first" again.

Tom> For DAP, and frame filters, I tend to think it would be better for Python to simply see the frames as they are, but then add a new attribute -- on the frame, but also maybe on the symbol -- indicating if it's been marked as a trampoline.
Tom> Then maybe _FrameDecoratorBase.elided could return True if the frame is a non-"live" trampoline frame.

Abdul> Agreed.  For v12 I will drop the change to frame_object_to_frame_info, so that Python sees the frames as they are, and add new attributes:

- gdb.Symbol.is_trampoline, an attribute like Symbol.is_function;
- gdb.Frame.is_trampoline (), a method like the other gdb.Frame  accessors, true if the frame's function is marked as a trampoline;

For the frame filters, elided () returns the frames elided under a frame, so I would do it the other way round: the frame that a trampoline leads to returns the trampoline frames as its elided frames, except for the live frame, which is never elided.  Frame filters and DAP then handle them like other elided frames.  This depends on what we decide for the backtrace command in 04/10, and I will keep the Python side consistent with that.

Thanks & Best Regards,
Abdul Basit

-----Original Message-----
From: Tom Tromey <tom@tromey.com> 
Sent: Wednesday, October 21, 2026 11:03 PM
To: Ijaz, Abdul B <abdul.b.ijaz@intel.com>
Cc: gdb-patches@sourceware.org; JiniSusan.George@amd.com; tom@tromey.com; eliz@gnu.org
Subject: Re: [PATCH v11 10/10] gdb: Filter trampoline frames in backtrace when using Python frame-filters.

>>>>> Abdul Basit Ijaz <abdul.b.ijaz@intel.com> writes:

> In case of the Python frame-filters, this change filters trampoline 
> functions when the option 'skip-trampoline-functions' is set to 'on'.  
> GDB recently added the option to hide frames that are marked by the 
> compiler with "DW_AT_trampoline", see commit 'Skip trampoline frames 
> for the backtrace command'.  This implements the same functionality 
> when python frame filters are in use.

> diff --git a/gdb/python/py-frame.c b/gdb/python/py-frame.c index 
> afa89f0d112..098b37230e1 100644
> --- a/gdb/python/py-frame.c
> +++ b/gdb/python/py-frame.c
> @@ -59,6 +59,17 @@ frame_object_to_frame_info (PyObject *obj)
>    if (frame == NULL)
>      return NULL;
 
> +  if (skip_trampoline_functions)
> +    {
> +      for (int i = 0; (SAFE_TRAMPOLINE_CHAIN (i, frame)
> +		       && in_trampoline_frame (frame)); ++i)
> +	{
> +	  frame = get_prev_frame (frame);
> +	  if (frame ==  nullptr)
> +	    return nullptr;
> +	}
> +    }

This seems suspicious to me.

For one thing, suppose you have A -> Trampoline -> B.  Then in Python you fetch the frame B.  What does B.newer() return?

I think with this code it will just return B again.

For DAP, and frame filters, I tend to think it would be better for Python to simply see the frames as they are, but then add a new attribute -- on the frame, but also maybe on the symbol -- indicating if it's been marked as a trampoline.

Then maybe _FrameDecoratorBase.elided could return True if the frame is a non-"live" trampoline frame.

Tom
________________________________________
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.

  reply	other threads:[~2026-10-22 17:05 UTC|newest]

Thread overview: 32+ 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-10-21 20:33   ` Tom Tromey
2026-10-22 11:02     ` Ijaz, Abdul B
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-10-21 20:39   ` Tom Tromey
2026-10-22 11:15     ` Ijaz, Abdul B
2026-10-21 20:43   ` Tom Tromey
2026-10-22 11:37     ` Ijaz, Abdul B
2026-08-03 19:34 ` [PATCH v11 04/10] gdb: Skip trampoline frames for the backtrace command Abdul Basit Ijaz
2026-10-21 20:50   ` Tom Tromey
2026-10-22 12:11     ` Ijaz, Abdul B
2026-08-03 19:34 ` [PATCH v11 05/10] gdb: Skip trampoline functions for the finish and reverse-finish commands Abdul Basit Ijaz
2026-10-21 20:52   ` Tom Tromey
2026-10-22 12:31     ` Ijaz, Abdul B
2026-08-03 19:34 ` [PATCH v11 06/10] gdb: Skip trampoline functions for the up command Abdul Basit Ijaz
2026-10-21 20:53   ` Tom Tromey
2026-10-22 13:01     ` Tom Tromey
2026-10-22 14:02       ` Ijaz, Abdul B
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-10-21 20:58   ` Tom Tromey
2026-10-22 14:18     ` Ijaz, Abdul B
2026-08-03 19:34 ` [PATCH v11 09/10] gdb, mi: Skip trampoline functions for the -stack-list-arguments command Abdul Basit Ijaz
2026-08-03 19:34 ` [PATCH v11 10/10] gdb: Filter trampoline frames in backtrace when using Python frame-filters Abdul Basit Ijaz
2026-10-21 21:03   ` Tom Tromey
2026-10-22 17:04     ` Ijaz, Abdul B [this message]
2026-09-09  7:40 ` [PING][PATCH v11 00/10] GDB support for DW_AT_trampoline Ijaz, Abdul B
2026-09-18  9:33   ` Ijaz, Abdul B
2026-10-01  7:49     ` Ijaz, Abdul B
2026-10-12 13:52       ` Ijaz, Abdul B

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=SA1PR11MB684689C62155BCF81A78A7CDCB652@SA1PR11MB6846.namprd11.prod.outlook.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