From: Kevin Buettner <kevinb@redhat.com>
To: gdb-patches@sourceware.org
Cc: Kevin Buettner <kevinb@redhat.com>
Subject: [PATCH] [gdb/testsuite] Fix gdb.base/inline-frame-cycle-unwind.exp for s390x
Date: Sat, 1 Nov 2025 21:46:51 -0700 [thread overview]
Message-ID: <20251102044651.502973-1-kevinb@redhat.com> (raw)
This commit fixes six failures for s390x due to a fundamental
difference in unwinding behavior between s390x and other
architectures:
FAIL: gdb.base/inline-frame-cycle-unwind.exp: bt: cycle at level 5:
backtrace when the unwind is broken at frame 5
FAIL: gdb.base/inline-frame-cycle-unwind.exp: bt: cycle at level 3:
backtrace when the unwind is broken at frame 3
FAIL: gdb.base/inline-frame-cycle-unwind.exp: bt: cycle at level 1:
backtrace when the unwind is broken at frame 1
FAIL: gdb.base/inline-frame-cycle-unwind.exp: bt -no-filters: cycle at level 5:
backtrace when the unwind is broken at frame 5
FAIL: gdb.base/inline-frame-cycle-unwind.exp: bt -no-filters: cycle at level 3:
backtrace when the unwind is broken at frame 3
FAIL: gdb.base/inline-frame-cycle-unwind.exp: bt -no-filters: cycle at level 1:
backtrace when the unwind is broken at frame 1
The core issue is that on s390x, the Canonical Frame Address (CFA) for
a function points *into the caller's stack frame*, whereas on x86_64
or aarch64 the CFA points *within the current function's frame*. This
architectural difference causes cycle detection to occur later on
s390x.
The patch resolves this by:
- Making expected backtrace output architecture-specific.
- For non-s390x targets: expecting the full set of frames up to the
specified level.
- For s390x: expecting fewer frames before detecting the cycle
(e.g., level 5 shows 3 frames instead of 5).
- Skipping the cycle at level 1 test entirely on s390x since it cannot
be detected at that frame.
Tested using recent Fedora releases on s390x, x86_64, and aarch64.
---
.../gdb.base/inline-frame-cycle-unwind.exp | 81 +++++++++++++------
1 file changed, 57 insertions(+), 24 deletions(-)
diff --git a/gdb/testsuite/gdb.base/inline-frame-cycle-unwind.exp b/gdb/testsuite/gdb.base/inline-frame-cycle-unwind.exp
index 7fc47af624f..ccd86eb79ab 100644
--- a/gdb/testsuite/gdb.base/inline-frame-cycle-unwind.exp
+++ b/gdb/testsuite/gdb.base/inline-frame-cycle-unwind.exp
@@ -92,15 +92,31 @@ foreach bt_cmd { "bt" "bt -no-filters" } {
gdb_test_no_output "python stop_at_level=5"
gdb_test "maint flush register-cache" \
"Register cache flushed\\."
+
+ # Frames expected on all targets
+ set exp [list \
+ "#0 \[^\r\n\]* inline_func \\(\\) at \[^\r\n\]*" \
+ "#1 \[^\r\n\]* normal_func \\(\\) at \[^\r\n\]*" \
+ "#2 \[^\r\n\]* inline_func \\(\\) at \[^\r\n\]*" \
+ "#3 \[^\r\n\]* normal_func \\(\\) at \[^\r\n\]*"]
+
+ # Additional frames required on non-s390x targets
+ if {![istarget "s390x*-*-*"]} {
+ lappend exp \
+ "#4 \[^\r\n\]* inline_func \\(\\) at \[^\r\n\]*" \
+ "#5 \[^\r\n\]* normal_func \\(\\) at \[^\r\n\]*"
+ }
+ #
+ # The final line that should appear for every target
+ lappend exp \
+ "Backtrace stopped: previous frame identical to this frame \\(corrupt stack\\?\\)"
+
+ # Convert the list to the single string that gdb_test_lines expects.
+ # (This is equivalent to [multi_line {*}$exp]).
+ set expected [join $exp "\r\n"]
+
gdb_test_lines "$bt_cmd" "backtrace when the unwind is broken at frame 5" \
- [multi_line \
- "#0 \[^\r\n\]* inline_func \\(\\) at \[^\r\n\]+" \
- "#1 \[^\r\n\]* normal_func \\(\\) at \[^\r\n\]+" \
- "#2 \[^\r\n\]* inline_func \\(\\) at \[^\r\n\]+" \
- "#3 \[^\r\n\]* normal_func \\(\\) at \[^\r\n\]+" \
- "#4 \[^\r\n\]* inline_func \\(\\) at \[^\r\n\]+" \
- "#5 \[^\r\n\]* normal_func \\(\\) at \[^\r\n\]+" \
- "Backtrace stopped: previous frame identical to this frame \\(corrupt stack\\?\\)"]
+ $expected
}
with_test_prefix "cycle at level 3" {
@@ -108,25 +124,42 @@ foreach bt_cmd { "bt" "bt -no-filters" } {
gdb_test_no_output "python stop_at_level=3"
gdb_test "maint flush register-cache" \
"Register cache flushed\\."
+ # Frames expected on all targets
+ set exp [list \
+ "#0 \[^\r\n\]* inline_func \\(\\) at \[^\r\n\]*" \
+ "#1 \[^\r\n\]* normal_func \\(\\) at \[^\r\n\]*"]
+
+ # Additional frames required on non-s390x targets
+ if {![istarget "s390x*-*-*"]} {
+ lappend exp \
+ "#2 \[^\r\n\]* inline_func \\(\\) at \[^\r\n\]*" \
+ "#3 \[^\r\n\]* normal_func \\(\\) at \[^\r\n\]*"
+ }
+ #
+ # The final line that should appear for every target
+ lappend exp \
+ "Backtrace stopped: previous frame identical to this frame \\(corrupt stack\\?\\)"
+
+ # Convert the list to the single string that gdb_test_lines expects.
+ # (This is equivalent to [multi_line {*}$exp]).
+ set expected [join $exp "\r\n"]
+
gdb_test_lines "$bt_cmd" "backtrace when the unwind is broken at frame 3" \
- [multi_line \
- "#0 \[^\r\n\]* inline_func \\(\\) at \[^\r\n\]+" \
- "#1 \[^\r\n\]* normal_func \\(\\) at \[^\r\n\]+" \
- "#2 \[^\r\n\]* inline_func \\(\\) at \[^\r\n\]+" \
- "#3 \[^\r\n\]* normal_func \\(\\) at \[^\r\n\]+" \
- "Backtrace stopped: previous frame identical to this frame \\(corrupt stack\\?\\)"]
+ $expected
}
- with_test_prefix "cycle at level 1" {
- # Arrange to introduce a stack cycle at frame 1.
- gdb_test_no_output "python stop_at_level=1"
- gdb_test "maint flush register-cache" \
- "Register cache flushed\\."
- gdb_test_lines "$bt_cmd" "backtrace when the unwind is broken at frame 1" \
- [multi_line \
- "#0 \[^\r\n\]* inline_func \\(\\) at \[^\r\n\]+" \
- "#1 \[^\r\n\]* normal_func \\(\\) at \[^\r\n\]+" \
- "Backtrace stopped: previous frame identical to this frame \\(corrupt stack\\?\\)"]
+ if {![istarget "s390x*-*-*"]} {
+ with_test_prefix "cycle at level 1" {
+ # Arrange to introduce a stack cycle at frame 1.
+ gdb_test_no_output "python stop_at_level=1"
+ gdb_test "maint flush register-cache" \
+ "Register cache flushed\\."
+ gdb_test_lines "$bt_cmd" "backtrace when the unwind is broken at frame 1" \
+ [multi_line \
+ "#0 \[^\r\n\]* inline_func \\(\\) at \[^\r\n\]+" \
+ "#1 \[^\r\n\]* normal_func \\(\\) at \[^\r\n\]+" \
+ "Backtrace stopped: previous frame identical to this frame \\(corrupt stack\\?\\)"]
+ }
}
# Flush the register cache (which also flushes the frame cache) so we
--
2.51.0
next reply other threads:[~2025-11-02 4:48 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-02 4:46 Kevin Buettner [this message]
2025-12-08 19:53 ` Kevin Buettner
2025-12-09 19:53 ` Simon Marchi
2025-12-11 13:50 ` Tom de Vries
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=20251102044651.502973-1-kevinb@redhat.com \
--to=kevinb@redhat.com \
--cc=gdb-patches@sourceware.org \
/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