From: Eli Zaretskii <eliz@gnu.org>
To: Abdul Basit Ijaz <abdul.b.ijaz@intel.com>
Cc: gdb-patches@sourceware.org, JiniSusan.George@amd.com,
tom@tromey.com, nils-christian.kempke@intel.com
Subject: Re: [PATCH v3 3/4] gdb/infrun: handle stepping through functions with DW_AT_trampoline
Date: Tue, 11 Jul 2023 14:21:28 +0300 [thread overview]
Message-ID: <837cr68zif.fsf@gnu.org> (raw)
In-Reply-To: <20230710225643.32280-4-abdul.b.ijaz@intel.com> (message from Abdul Basit Ijaz on Tue, 11 Jul 2023 00:56:42 +0200)
> From: Abdul Basit Ijaz <abdul.b.ijaz@intel.com>
> Cc: abdul.b.ijaz@intel.com,
> JiniSusan.George@amd.com,
> tom@tromey.com,
> eliz@gnu.org,
> Nils-Christian Kempke <nils-christian.kempke@intel.com>
> Date: Tue, 11 Jul 2023 00:56:42 +0200
>
> From: Nils-Christian Kempke <nils-christian.kempke@intel.com>
>
> This patch makes infrun continue stepping into and through trampoline
> functions marked via the DW_AT_trampoline in DWARF. The attribute can
> be emitted by the compiler for certain subroutines/inlined subroutines
> that are compiler generated and should be hidden from a user.
>
> Mainly, infrun is modified in 3 ways.
>
> First, GDB will now attempt to step through trampoline functions.
> Whenever we issued a step command that would make GDB step into a
> function that is marked trampoline, GDB will try to step directly towards
> the trampoline's 'target' instead and, e.g., not stop at the first
> instruction of the trampoline.
> The target can be specified by the compiler by the value of
> DW_AT_trampoline if its form is either an address, a name, or a DIE
> reference. DW_AT_trampoline is also allowed to be specified as a flag
> (containing true or false), in which case the target is assumed to be
> unknown. If GDB successfully finds a target, so if the value of
> DW_AT_trampoline was not a flag and could be resolved successfully, GDB
> steps directly towards the target and through the trampoline, hiding
> the trampoline from the user. If GDB cannot, however deduce a target,
> most likely because the DW_AT_trampoline was given as a flag or because
> of broken debug info, it will instead continue inside execution in the
> trampoline function until it reaches an instruction that is not
> associated with a trampoline function, which is usually the target
> function. It will then stop and give control back to the user.
> It should be noted, that there might be the cases, where trampolines
> call functions other than the target before the actual target call. If,
> in such a situation, GDB fails to resolve the target, it would resume
> execution until stepping into this other function call, and hand back
> control to the user, without actually having reached the target. A
> second step would have to be issued by the user to arrive a the target
> (by resuming in the trampoline and then until leaving it a second time).
> As this is a rather pathological case and no real instance of this is
> known, I think the current behavior here is good enough and seems to be
> the best GDB can do in such a situation.
>
> Secondly, as trampoline functions normally do not have any real source
> code correlation, it is likely that they mostly appear without line
> info.
> Normally, GDB would skip completely over a function call to a function
> that has no source line information, so we would never get to the
> aforementioned stepping through a trampoline and target resolution. To
> remedy this, for debug info trampolines, GDB now attempts to step through
> them regardless of them having source line information or not. So
> issuing a step at a function call wrapped by a trampoline without source
> line information will no longer skip the whole function call, but now
> step through the trampoline and attempt to resolve the trampoline target
> as described above (so usually, a single step at the call site will step
> through the trampoline and towards the target, even if the trampoline had
> not source line info).
>
> Last, in all other cases when GDB is about to stop at a location that is
> included in a trampoline region (e.g. after a step from the target back
> into the trampoline) GDB will instead continue until the trampoline
> region is left again and only then give control back to the user. This
> change serves the purpose of allowing stepping back from a target call
> through the trampoline without the user noticing the artificial function
> call inbetween call site and target.
>
> Together, these changes attempt to hide the trampoline function from the
> user while stepping. Additionally, the skip-trampoline-functions option
> has been introduced in infrun. It is set by default, and, when turned
> off, GDB will return to its 'normal' stepping behavior and ignore any
> possible DW_AT_trampoline.
>
> As currently only ifx emits the DW_AT_trampoline tag, a test has been
> added to gdb.dwarf2 that artificially creates a set of trampoline
> functions.
>
> 2023-07-10 Nils-Christian Kempke <nils-christian.kempke@intel.com>
> ---
> gdb/NEWS | 15 ++
> gdb/doc/gdb.texinfo | 36 +++
> gdb/infrun.c | 81 +++++-
> gdb/infrun.h | 4 +
> .../gdb.dwarf2/dw2-function-trampolines.c | 80 ++++++
> .../gdb.dwarf2/dw2-function-trampolines.exp | 245 ++++++++++++++++++
> 6 files changed, 457 insertions(+), 4 deletions(-)
> create mode 100644 gdb/testsuite/gdb.dwarf2/dw2-function-trampolines.c
> create mode 100644 gdb/testsuite/gdb.dwarf2/dw2-function-trampolines.exp
Thanks, the documentation parts are okay.
Reviewed-By: Eli Zaretskii <eliz@gnu.org>
next prev parent reply other threads:[~2023-07-11 11:22 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-10 22:56 [PATCH v3 0/4] GDB support for DW_AT_trampoline Abdul Basit Ijaz
2023-07-10 22:56 ` [PATCH v3 1/4] gdb, dwarf: add support for DW_AT_trampoline in DWARF reader Abdul Basit Ijaz
2023-07-27 9:09 ` Bruno Larsen
2023-07-29 11:36 ` Ijaz, Abdul B
2023-07-31 7:16 ` Bruno Larsen
2023-07-10 22:56 ` [PATCH v3 2/4] gdb/symtab: add lookup for trampoline functions Abdul Basit Ijaz
2023-07-10 22:56 ` [PATCH v3 3/4] gdb/infrun: handle stepping through functions with DW_AT_trampoline Abdul Basit Ijaz
2023-07-11 11:21 ` Eli Zaretskii [this message]
2023-07-27 11:46 ` Bruno Larsen
2023-07-29 11:03 ` Ijaz, Abdul B
2023-07-10 22:56 ` [PATCH v3 4/4] gdb: Skip trampoline frames in the stack for printing or finish command Abdul Basit Ijaz
2023-07-11 11:23 ` Eli Zaretskii
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=837cr68zif.fsf@gnu.org \
--to=eliz@gnu.org \
--cc=JiniSusan.George@amd.com \
--cc=abdul.b.ijaz@intel.com \
--cc=gdb-patches@sourceware.org \
--cc=nils-christian.kempke@intel.com \
--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).