public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
* [binutils-gdb] PowerPC: bp-permanent.exp, kill-after-signal fix
@ 2022-05-06 17:46 Carl Love
0 siblings, 0 replies; 2+ messages in thread
From: Carl Love @ 2022-05-06 17:46 UTC (permalink / raw)
To: gdb-cvs
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=dd9cd55e990bcc9f8448cac38d242d53974b3604
commit dd9cd55e990bcc9f8448cac38d242d53974b3604
Author: Carl Love <cel@us.ibm.com>
Date: Fri May 6 17:45:58 2022 +0000
PowerPC: bp-permanent.exp, kill-after-signal fix
The break point after the stepi on Intel is the entry point of the user
signal handler function test_signal_handler. The code at the break point
looks like:
0x<hex address> <test_signal_handler>: endbr64
On PowerPC with a Linux 5.9 kernel or latter, the address where gdb stops
after the stepi is in the vdso code inserted by the kernel. The code at the
breakpoint looks like:
0x<hex address> <__kernel_start_sigtramp_rt64>: bctrl
This is different from other architectures. As discussed below, recent
kernel changes involving the vdso for PowerPC have been made changes to the
signal handler code flow. PowerPC is now stopping in function
__kernel_start_sigtramp_rt64. PowerPC now requires an additional stepi to
reach the user signal handler unlike other architectures.
The bp-permanent.exp and kill-after-signal tests run fine on PowerPC with an
kernel that is older than Linux 5.9.
The PowerPC 64 signal handler was updated by the Linux kernel 5.9-rc1:
commit id: 0138ba5783ae0dcc799ad401a1e8ac8333790df9
powerpc/64/signal: Balance return predictor stack in signal trampoline
An additional change to the PowerPC 64 signal handler was made in Linux
kernel version 5.11-rc7 :
commit id: 24321ac668e452a4942598533d267805f291fdc9
powerpc/64/signal: Fix regression in __kernel_sigtramp_rt64() semantics
The first kernel change, puts code into the user space signal handler (in
the vdso) as a performance optimization to prevent the call/return stack
from getting out of balance. The patch ensures that the entire
user/kernel/vdso cycle is balanced with the addition of the "brctl"
instruction.
The second patch, fixes the semantics of __kernel_sigtramp_rt64(). A new
symbol is introduced to serve as the jump target from the kernel to the
trampoline which now consists of two parts.
The above changes for PowerPC signal handler, causes gdb to stop in the
kernel code not the user signal handler as expected. The kernel dispatches
to the vdso code which in turn calls into the signal handler. PowerPC is
special in that the kernel is using a vdso instruction (bctrl) to enter the
signal handler.
I do not have access to a system with the first patch but not the second. I did
test on Power 9 with the Linux 5.15.0-27-generic kernel. Both tests fail on
this Power 9 system. The two tests also fail on Power 10 with the Linux
5.14.0-70.9.1.el9_0.ppc64le kernel.
The following patch fixes the issue by checking if gdb stopped at "signal
handler called". If gdb stopped there, the tests verifies gdb is in the kernel
function __kernel_start_sigtramp_rt64 then does an additional stepi to reach the
user signal handler. With the patch below, the tests run without errors on both
the Power 9 and Power 10 systems with out any failures.
Diff:
---
gdb/testsuite/gdb.base/bp-permanent.exp | 25 +++++++++++++++++++++
gdb/testsuite/gdb.base/kill-after-signal.exp | 33 +++++++++++++++++++++++++++-
2 files changed, 57 insertions(+), 1 deletion(-)
diff --git a/gdb/testsuite/gdb.base/bp-permanent.exp b/gdb/testsuite/gdb.base/bp-permanent.exp
index 8be46e96238..21b0bc7bb2d 100644
--- a/gdb/testsuite/gdb.base/bp-permanent.exp
+++ b/gdb/testsuite/gdb.base/bp-permanent.exp
@@ -260,6 +260,31 @@ proc test {always_inserted sw_watchpoint} {
-re "Program received signal SIGTRAP.*$gdb_prompt $" {
fail $test
}
+ -re ".*signal handler called.*$gdb_prompt $" {
+ # PowerPC Linux kernel patchs:
+ # commit: 0138ba5783ae0dcc799ad401a1e8ac8333790df9
+ # powerpc/64/signal: Balance return predictor
+ # stack in signal trampoline.
+ #
+ # The kernel places an additional brctl instruction
+ # in the vdso to call the user hadler.
+ #
+ # commit 24321ac668e452a4942598533d267805f291fdc9
+ # powerpc/64/signal: Fix regression in
+ # __kernel_sigtramp_rt64() semantics
+ #
+ # Updates the semantics of __kernel_sigtramp_rt64().
+ # It adds a new symbol to serve as a jump target from
+ # the kernel to the trampoline.
+ #
+ # The net result of these changes is that gdb stops
+ # at __kernel_start_sigtramp_rt64. Need to do one
+ # more stepi to reach the expected location in the user
+ # signal handler.
+ gdb_test "p \$pc" ".*__kernel_start_sigtramp_rt64.*" \
+ "in kernel code"
+ gdb_test "stepi" "handler .*" $test
+ }
-re "handler .*$gdb_prompt $" {
pass $test
}
diff --git a/gdb/testsuite/gdb.base/kill-after-signal.exp b/gdb/testsuite/gdb.base/kill-after-signal.exp
index 09f5cbc39a6..fcbec9a1c2e 100644
--- a/gdb/testsuite/gdb.base/kill-after-signal.exp
+++ b/gdb/testsuite/gdb.base/kill-after-signal.exp
@@ -36,7 +36,38 @@ if ![runto_main] {
}
gdb_test "continue" "Program received signal SIGUSR1, .*"
-gdb_test "stepi" "\r\nhandler .*"
+
+set test "handler"
+gdb_test_multiple "stepi" $test {
+ -re "\r\nhandler .*" {
+ pass $test
+ }
+ -re ".*signal handler called.*$gdb_prompt $" {
+ # PowerPC Linux kernel patchs:
+ # commit: 0138ba5783ae0dcc799ad401a1e8ac8333790df9
+ # powerpc/64/signal: Balance return predictor
+ # stack in signal trampoline.
+ #
+ # The kernel places an additional brctl instruction
+ # in the vdso to call the user hadler.
+ #
+ # commit 24321ac668e452a4942598533d267805f291fdc9
+ # powerpc/64/signal: Fix regression in
+ # __kernel_sigtramp_rt64() semantics
+ #
+ # Updates the semantics of __kernel_sigtramp_rt64().
+ # It adds a new symbol to serve as a jump target from
+ # the kernel to the trampoline.
+ #
+ # The net result of these changes is that gdb stops
+ # at __kernel_start_sigtramp_rt64. Need to do one
+ # more stepi to reach the expected location in the user
+ # signal handler.
+ gdb_test "p \$pc" ".*__kernel_start_sigtramp_rt64.*" "in kernel code"
+ gdb_test "stepi" "\r\nhandler .*" $test
+ }
+}
+
gdb_test_multiple "kill" "kill" {
-re "Kill the program being debugged\\? \\(y or n\\) $" {
gdb_test "y" "\\\[Inferior $decimal \\(.*\\) killed\\\]" "kill"
^ permalink raw reply [flat|nested] 2+ messages in thread
* [binutils-gdb] PowerPC: bp-permanent.exp, kill-after-signal fix
@ 2022-05-18 15:12 Carl Love
0 siblings, 0 replies; 2+ messages in thread
From: Carl Love @ 2022-05-18 15:12 UTC (permalink / raw)
To: gdb-cvs
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=301fe55e9c44d03ebdfbd2b34c9b8570cc2f9f18
commit 301fe55e9c44d03ebdfbd2b34c9b8570cc2f9f18
Author: Carl Love <cel@us.ibm.com>
Date: Fri May 6 21:49:22 2022 +0000
PowerPC: bp-permanent.exp, kill-after-signal fix
Fix changes that didn't make it into commit:
dd9cd55e990bcc9f8448cac38d242d53974b3604.
Fix missing -wrap on gdb_test_multiple in gdb.base/kill-after-signal.exp
that is causing regression test on x86_64-linux with taskset -c 0.
Diff:
---
gdb/testsuite/gdb.base/bp-permanent.exp | 15 +++++++++------
gdb/testsuite/gdb.base/kill-after-signal.exp | 15 +++++++++------
2 files changed, 18 insertions(+), 12 deletions(-)
diff --git a/gdb/testsuite/gdb.base/bp-permanent.exp b/gdb/testsuite/gdb.base/bp-permanent.exp
index 21b0bc7bb2d..1ad9a698db8 100644
--- a/gdb/testsuite/gdb.base/bp-permanent.exp
+++ b/gdb/testsuite/gdb.base/bp-permanent.exp
@@ -260,28 +260,31 @@ proc test {always_inserted sw_watchpoint} {
-re "Program received signal SIGTRAP.*$gdb_prompt $" {
fail $test
}
- -re ".*signal handler called.*$gdb_prompt $" {
- # PowerPC Linux kernel patchs:
+ -re "signal handler called.*$gdb_prompt $" {
+ # After PowerPC Linux kernel commit:
+ #
# commit: 0138ba5783ae0dcc799ad401a1e8ac8333790df9
# powerpc/64/signal: Balance return predictor
# stack in signal trampoline.
#
# The kernel places an additional brctl instruction
- # in the vdso to call the user hadler.
+ # in the vdso to call the user handler.
+ #
+ # And then this commit:
#
# commit 24321ac668e452a4942598533d267805f291fdc9
# powerpc/64/signal: Fix regression in
# __kernel_sigtramp_rt64() semantics
#
- # Updates the semantics of __kernel_sigtramp_rt64().
- # It adds a new symbol to serve as a jump target from
+ # updates the semantics of __kernel_sigtramp_rt64().
+ # It added a new symbol to serve as a jump target from
# the kernel to the trampoline.
#
# The net result of these changes is that gdb stops
# at __kernel_start_sigtramp_rt64. Need to do one
# more stepi to reach the expected location in the user
# signal handler.
- gdb_test "p \$pc" ".*__kernel_start_sigtramp_rt64.*" \
+ gdb_test "p \$pc" "__kernel_start_sigtramp_rt64.*" \
"in kernel code"
gdb_test "stepi" "handler .*" $test
}
diff --git a/gdb/testsuite/gdb.base/kill-after-signal.exp b/gdb/testsuite/gdb.base/kill-after-signal.exp
index 7450b2ae4b9..bdb2a159bfa 100644
--- a/gdb/testsuite/gdb.base/kill-after-signal.exp
+++ b/gdb/testsuite/gdb.base/kill-after-signal.exp
@@ -39,24 +39,27 @@ gdb_test "continue" "Program received signal SIGUSR1, .*"
set test "handler"
gdb_test_multiple "stepi" $test {
- -re "\r\nhandler .*" {
+ -re -wrap "\r\nhandler .*" {
pass $test
}
- -re ".*signal handler called.*$gdb_prompt $" {
- # PowerPC Linux kernel patchs:
+ -re "signal handler called.*$gdb_prompt $" {
+ # After PowerPC Linux kernel commit:
+ #
# commit: 0138ba5783ae0dcc799ad401a1e8ac8333790df9
# powerpc/64/signal: Balance return predictor
# stack in signal trampoline.
#
# The kernel places an additional brctl instruction
- # in the vdso to call the user hadler.
+ # in the vdso to call the user handler.
+ #
+ # And then this commit:
#
# commit 24321ac668e452a4942598533d267805f291fdc9
# powerpc/64/signal: Fix regression in
# __kernel_sigtramp_rt64() semantics
#
- # Updates the semantics of __kernel_sigtramp_rt64().
- # It adds a new symbol to serve as a jump target from
+ # updates the semantics of __kernel_sigtramp_rt64().
+ # It added a new symbol to serve as a jump target from
# the kernel to the trampoline.
#
# The net result of these changes is that gdb stops
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-05-18 15:12 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-06 17:46 [binutils-gdb] PowerPC: bp-permanent.exp, kill-after-signal fix Carl Love
2022-05-18 15:12 Carl Love
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).