public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Ulrich Weigand <Ulrich.Weigand@de.ibm.com>
To: "gdb-patches@sourceware.org" <gdb-patches@sourceware.org>,
	Andrew Burgess <aburgess@redhat.com>,
	"cel@linux.ibm.com" <cel@linux.ibm.com>,
	Keith Seitz <keiths@redhat.com>
Subject: RE: [PATCH 1/2, ver2]  PowerPC, Fix-test-gdb.base-store.exp
Date: Wed, 25 Oct 2023 13:24:09 +0000	[thread overview]
Message-ID: <51fbddb2f868c778660c592a91c39677a3763197.camel@de.ibm.com> (raw)
In-Reply-To: <87sf602wqt.fsf@redhat.com>

Andrew Burgess <aburgess@redhat.com> wrote:

>Sorry for being such a pain w.r.t. this patch.  Honestly, it's mostly
>because you touched infrun.c that I'm so interested here.
[...]
>And I'd like to see clearer details about which tests the infrun.c
>changes will fix.

Hi Andrew, as I suggested that particular infrun.c change
to Carl, let me add some background to what Carl replied.

This one-line change in infrun.c fixes a (potential) common-code
bug in existing code.  However, this bug is likely dormant on
all current platforms:

First of all, the bug only shows up on platforms where the
kernel uses a trampoline to dispatch *calls to* the signal
handler (not just *returns from* the signal handler).  Many
platforms use a trampoline for signal return, and that is
working fine, but the only platform I'm aware of that uses
a trampoline for signal handler calls is (recent kernels for)
PowerPC.  I believe the rationale for using a trampoline here
is to improve performance by avoiding unbalancing of the
branch predictor's call/return stack.

However, on PowerPC the bug is dormant as well as it is hidden
by *another* bug that prevents correct unwinding out of the
signal trampoline.  This is because the custom CFI for the
trampoline uses a register number (VSCR) that is not ever used
by compiler-generated CFI, and that particular register is
mapped to an invalid number by the current PowerPC DWARF
mapper.

Now, as Carl fixed the PowerPC DWARF mapper to fix some test
case regressions that showed up on POWER10, he added correct
mappings for all registers including VSCR.  This then caused
unwinding out of the signal trampoline to start working
correctly, which in turn exposed the pre-existing infrun.c bug
in handling signal call trampolines.

Now, that particular bug is that if the kernel uses a signal
call trampoline, infrun.c will see that the current PC is
in a frame that is an immediate child of the step frame (as
the trampoline frame unwinds to the step frame) - and then
incorrectly thinks that a *subroutine call* must have happened.
But we don't want to treat a signal handler invocation like
a subroutine call, in particular we want "nexti" to step
into it.  That's fixed by the one-line change.


Bye,
Ulrich


  reply	other threads:[~2023-10-25 13:24 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-12 14:51 Carl Love
2023-10-12 14:58 ` [Patch 1/2] " Carl Love
2023-10-13 20:34   ` Keith Seitz
2023-10-13 21:00     ` Carl Love
2023-10-16 11:12       ` Ulrich Weigand
2023-10-16 14:31   ` Andrew Burgess
2023-10-16 15:51     ` Carl Love
2023-10-19 15:54       ` Carl Love
2023-10-24  8:50       ` Andrew Burgess
2023-10-24 16:05         ` Carl Love
2023-10-20 18:08     ` [PATCH 1/2, ver2] " Carl Love
2023-10-24  9:30       ` Andrew Burgess
2023-10-25 13:24         ` Ulrich Weigand [this message]
2023-10-30  9:45           ` Andrew Burgess
2023-10-30 16:44             ` Ulrich Weigand
2023-10-30 17:16               ` Carl Love
2023-10-30 17:25               ` [PATCH 1/2, ver3] " Carl Love
2023-11-06 18:24                 ` Carl Love
2023-11-08 10:54                 ` Andrew Burgess
2023-10-12 15:00 ` [PATCH 2/2] " Carl Love
2023-10-13 20:35   ` Keith Seitz
2023-10-13 21:00     ` Carl Love
2023-10-16 11:13       ` Ulrich Weigand
2023-10-16 14:36   ` Andrew Burgess
2023-10-16 15:51     ` Carl Love
2023-10-20 18:08     ` Carl Love
2023-10-24  8:53       ` Andrew Burgess

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=51fbddb2f868c778660c592a91c39677a3763197.camel@de.ibm.com \
    --to=ulrich.weigand@de.ibm.com \
    --cc=aburgess@redhat.com \
    --cc=cel@linux.ibm.com \
    --cc=gdb-patches@sourceware.org \
    --cc=keiths@redhat.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).