public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: "Ijaz, Abdul B" <abdul.b.ijaz@intel.com>
To: Tom Tromey <tom@tromey.com>,
	Abdul Basit Ijaz via Gdb-patches <gdb-patches@sourceware.org>
Cc: "JiniSusan.George@amd.com" <JiniSusan.George@amd.com>,
	"eliz@gnu.org" <eliz@gnu.org>,
	"blarsen@redhat.com" <blarsen@redhat.com>
Subject: RE: [PATCH v4 4/4] gdb: Skip trampoline frames in the stack for printing or finish command.
Date: Mon, 7 Aug 2023 13:28:55 +0000	[thread overview]
Message-ID: <SA1PR11MB68460B1DF316B8C13BE7A5E9CB0CA@SA1PR11MB6846.namprd11.prod.outlook.com> (raw)
In-Reply-To: <87h6phch31.fsf@tromey.com>

Hi Tom,

Thanks for the feedback. Added replies below:

Tom> If I am stopped in a frame and go "up", will I be in the trampoline frame anyway?  And will "bt" then not print the selected frame?  But "frame" will?

Yes in current implementation bt will not print those trampoline frames and user may see from the frame number in bt since in output  frame numbers will be missing/elided for those trampoline calls. So "up" command will still take it to trampoline call. Do we need to handle "up" call ? . One sample run from program where first function call the second function and DW_at_trampoline exist for both of them.

22        second = x * y ! second-breakpt
(gdb) bt
#0  second (x=20, y=9) at db.fortran/func-trampoline.f90:22
#2  0x0000000000405203 in first (num1=16, num2=3) at gdb.fortran/func-trampoline.f90:29
#4  0x0000000000405254 in func_trampoline () at gdb.fortran/func-trampoline.f90:35
(gdb) up
#1  0x0000000000405229 in second_.t74p.t75p () at gdb.fortran/func-trampoline.f90:30
(gdb) frame 1
#1  0x0000000000405229 in second_.t74p.t75p () at gdb.fortran/func-trampoline.f90:30
30      end function

Tom > Also this approach ignores frame filters -- if one is in use, then I think trampoline frames will show up again.  You can try this by writing a dummy frame filter that just returns all frames as-is.

Yes in case of frame filter these trampolines frames are shown up.  Do we need to cover it in this change since I think we need to handle in such case in frame filter script or something need to be handled here for this ?

Thanks & Best Regards
Abdul Basit

-----Original Message-----
From: Tom Tromey <tom@tromey.com> 
Sent: Wednesday, August 2, 2023 10:42 PM
To: Abdul Basit Ijaz via Gdb-patches <gdb-patches@sourceware.org>
Cc: Ijaz, Abdul B <abdul.b.ijaz@intel.com>; JiniSusan.George@amd.com; tom@tromey.com; eliz@gnu.org; blarsen@redhat.com
Subject: Re: [PATCH v4 4/4] gdb: Skip trampoline frames in the stack for printing or finish command.

>>>>> "Abdul" == Abdul Basit Ijaz via Gdb-patches <gdb-patches@sourceware.org> writes:

Abdul> Before the change, GDB prints the frames indicated by the 
Abdul> compiler with DIE "DW_AT_trampoline" in the backtrace and finish 
Abdul> command, but for better user experience, all such frames can be 
Abdul> hidden from the user.  So, after this change, now such frames are 
Abdul> not printed any more in the backtrace command and also the 'finish' command skips the trampoline calls.

Abdul> So far, this DIE is added to DWARF only by the IFX compiler, so 
Abdul> gdb.fortran/mixed-lang-stack test used to fail for this compiler 
Abdul> because of these extra trampoline frames in the backtrace.  After 
Abdul> the commit, those trampoline frames are filtered so test is 
Abdul> updated accordingly to handle the frame level of the filtered frames.

Thanks for the patch.

I'm not totally sure how I feel about the stack trace part of this one.

On the one hand, normally I think it makes sense to elide these frames.
They aren't very interesting.

On the other hand, we have frame filters for frame elision, but then this works in a totally different way.

If I am stopped in a frame and go "up", will I be in the trampoline frame anyway?  And will "bt" then not print the selected frame?  But "frame" will?

Abdul> +  if (skip_trampoline_functions)
Abdul> +    {
Abdul> +      for (int i = 0; i < MAX_TRAMPOLINE_CHAIN_SIZE
Abdul> +		      && (frame != nullptr)
Abdul> +		      && in_trampoline_frame (frame); ++i)
Abdul> +	frame = get_prev_frame (frame);

Formatting looks weird here.

Abdul> +++ b/gdb/stack.c
Abdul> @@ -2054,6 +2054,14 @@ backtrace_command_1 (const frame_print_options &fp_opts,
Abdul>  	{
Abdul>  	  QUIT;
 
Abdul> +	  if (in_trampoline_frame (fi))
Abdul> +	    {
Abdul> +	      /* Trampoline frames are not printed so they are not counted in
Abdul> +		 the backtrace limit.  */
Abdul> +	      count++;
Abdul> +	      continue;

I guess the frame numbers will skip as well, because the frame level is a property of the frame, not of the loop displaying frames.

Also this approach ignores frame filters -- if one is in use, then I think trampoline frames will show up again.  You can try this by writing a dummy frame filter that just returns all frames as-is.

Tom
Intel Deutschland GmbH
Registered Address: Am Campeon 10, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, www.intel.de <http://www.intel.de>
Managing Directors: Christin Eisenschmid, Sharon Heck, Tiffany Doon Silva  
Chairperson of the Supervisory Board: Nicole Lau
Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928

  reply	other threads:[~2023-08-07 13:29 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-01 22:47 [PATCH v4 0/4] GDB support for DW_AT_trampoline Abdul Basit Ijaz
2023-08-01 22:47 ` [PATCH v4 1/4] gdb, dwarf: add support for DW_AT_trampoline in DWARF reader Abdul Basit Ijaz
2023-08-02 20:07   ` Tom Tromey
2023-08-07 14:43     ` Ijaz, Abdul B
2023-08-10 16:20       ` Tom Tromey
2023-08-02 20:13   ` Tom Tromey
2023-08-07 13:36     ` Ijaz, Abdul B
2023-08-10 16:18       ` Tom Tromey
2023-08-14 21:53         ` Ijaz, Abdul B
2023-08-01 22:47 ` [PATCH v4 2/4] gdb/symtab: add lookup for trampoline functions Abdul Basit Ijaz
2023-08-02 20:18   ` Tom Tromey
2023-08-07  7:40     ` Ijaz, Abdul B
2023-08-01 22:47 ` [PATCH v4 3/4] gdb/infrun: handle stepping through functions with DW_AT_trampoline Abdul Basit Ijaz
2023-08-02 11:52   ` Eli Zaretskii
2023-08-02 11:54     ` Ijaz, Abdul B
2023-08-02 20:33   ` Tom Tromey
2023-08-07  8:08     ` Ijaz, Abdul B
2023-08-10 16:56       ` Tom Tromey
2023-08-16 14:18         ` Ijaz, Abdul B
2023-08-01 22:47 ` [PATCH v4 4/4] gdb: Skip trampoline frames in the stack for printing or finish command Abdul Basit Ijaz
2023-08-02 11:52   ` Eli Zaretskii
2023-08-02 11:54     ` Ijaz, Abdul B
2023-08-02 20:41   ` Tom Tromey
2023-08-07 13:28     ` Ijaz, Abdul B [this message]
2023-08-10 17:45       ` Tom Tromey
2023-08-02 20:42   ` Tom Tromey
2023-08-07  7:19     ` 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=SA1PR11MB68460B1DF316B8C13BE7A5E9CB0CA@SA1PR11MB6846.namprd11.prod.outlook.com \
    --to=abdul.b.ijaz@intel.com \
    --cc=JiniSusan.George@amd.com \
    --cc=blarsen@redhat.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).