public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Tom Tromey <tom@tromey.com>
To: Abdul Basit Ijaz via Gdb-patches <gdb-patches@sourceware.org>
Cc: Abdul Basit Ijaz <abdul.b.ijaz@intel.com>,
	 JiniSusan.George@amd.com, tom@tromey.com,  eliz@gnu.org,
	 blarsen@redhat.com,
	 Nils-Christian Kempke <nils-christian.kempke@intel.com>
Subject: Re: [PATCH v4 3/4] gdb/infrun: handle stepping through functions with DW_AT_trampoline
Date: Wed, 02 Aug 2023 14:33:46 -0600	[thread overview]
Message-ID: <87leetchg5.fsf@tromey.com> (raw)
In-Reply-To: <20230801224744.24433-4-abdul.b.ijaz@intel.com> (Abdul Basit Ijaz via Gdb-patches's message of "Wed, 2 Aug 2023 00:47:43 +0200")

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

Abdul> From: Nils-Christian Kempke <nils-christian.kempke@intel.com>
Abdul> This patch makes infrun continue stepping into and through trampoline
Abdul> functions marked via the DW_AT_trampoline in DWARF.  The attribute can
Abdul> be emitted by the compiler for certain subroutines/inlined subroutines
Abdul> that are compiler generated and should be hidden from a user.

Thanks for the patch.

infrun isn't really my area but I do have some nits.

Abdul> +      bool in_trampoline = skip_trampoline_functions
Abdul> +			   && in_trampoline_function (stop_pc);
Abdul> +
Abdul> +      if (in_trampoline)

The assignment is not formatted correctly, but it seems to me that
there's no need for this variable at all, and the expression can be
inlined into the 'if' -- which will also fix the formatting.

Abdul> +	  real_stop_pc = find_function_trampoline_target (stop_pc);
Abdul> +
Abdul> +	  for (int i = 0; i < MAX_TRAMPOLINE_CHAIN_SIZE
Abdul> +			  && in_trampoline_function (real_stop_pc); ++i)

Normally we'd split at the ';':

    for (int i = 0;
         i < MAX_TRAMPOLINE_CHAIN_SIZE
         && in_trampoline_function (real_stop_pc);
         ++i)

... with the middle expression being all on one line if it fits.

Abdul> +	    {
Abdul> +		real_stop_pc = find_function_trampoline_target (real_stop_pc);
Abdul> +		/* Exit if find_function_trampoline_target failed to find the
Abdul> +		   trampoline target.  Do not try to resolve the trampolines
Abdul> +		   in this case.  */
Abdul> +		if (real_stop_pc == 0x0)

Just '0', not '0x0'.

Abdul> +	  /* If we failed to find a target we will just single step in the
Abdul> +	     hope of leaving the trampoline again soon.  */
Abdul> +	  if (real_stop_pc == 0x0)

Ditto.

Abdul> +      if (real_stop_pc == 0)
Abdul> +	real_stop_pc = skip_language_trampoline (frame, stop_pc);
Abdul>        if (real_stop_pc == 0)
Abdul>  	real_stop_pc = gdbarch_skip_trampoline_code (gdbarch, frame, stop_pc);

This is pre-existing code, but I wonder how all these different pieces
interact, or are supposed to interact.

I guess the language stuff is there to work around a GCC deficiency, in
that it does not emit DW_AT_trampoline.

The gdbarch stuff... I don't know but I see a lot of arches implement
this (though mostly deferring to the solib code).

Anyway, is it possible to have a gdbarch or c++ trampoline then call a
DW_AT_trampoline function?  If so then wouldn't we end up with an
erroneous stop?

I'm just wondering if these ought to be unified in some way, like say
look for any sort of trampoline target in the loop.

Also LOL at the gnu-v3-abi.c code:

  if (thunk_name == NULL || strstr (thunk_name, " thunk to ") == NULL)
    return 0;

It also seems a bit weird that skip_trampoline_functions only affects
this one subset of trampoline functions.

Tom

  parent reply	other threads:[~2023-08-02 20:33 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 [this message]
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
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=87leetchg5.fsf@tromey.com \
    --to=tom@tromey.com \
    --cc=JiniSusan.George@amd.com \
    --cc=abdul.b.ijaz@intel.com \
    --cc=blarsen@redhat.com \
    --cc=eliz@gnu.org \
    --cc=gdb-patches@sourceware.org \
    --cc=nils-christian.kempke@intel.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).