Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [PATCH] [gdb/testsuite] Fix gdb.base/inline-frame-cycle-unwind.exp for s390x
@ 2025-11-02  4:46 Kevin Buettner
  2025-12-08 19:53 ` Kevin Buettner
  0 siblings, 1 reply; 4+ messages in thread
From: Kevin Buettner @ 2025-11-02  4:46 UTC (permalink / raw)
  To: gdb-patches; +Cc: Kevin Buettner

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


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] [gdb/testsuite] Fix gdb.base/inline-frame-cycle-unwind.exp for s390x
  2025-11-02  4:46 [PATCH] [gdb/testsuite] Fix gdb.base/inline-frame-cycle-unwind.exp for s390x Kevin Buettner
@ 2025-12-08 19:53 ` Kevin Buettner
  2025-12-09 19:53   ` Simon Marchi
  0 siblings, 1 reply; 4+ messages in thread
From: Kevin Buettner @ 2025-12-08 19:53 UTC (permalink / raw)
  To: gdb-patches

Ping.

On Sat,  1 Nov 2025 21:46:51 -0700
Kevin Buettner <kevinb@redhat.com> wrote:

> 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
> 


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] [gdb/testsuite] Fix gdb.base/inline-frame-cycle-unwind.exp for s390x
  2025-12-08 19:53 ` Kevin Buettner
@ 2025-12-09 19:53   ` Simon Marchi
  2025-12-11 13:50     ` Tom de Vries
  0 siblings, 1 reply; 4+ messages in thread
From: Simon Marchi @ 2025-12-09 19:53 UTC (permalink / raw)
  To: Kevin Buettner, gdb-patches

On 12/8/25 2:53 PM, Kevin Buettner wrote:
> Ping.
> 
> On Sat,  1 Nov 2025 21:46:51 -0700
> Kevin Buettner <kevinb@redhat.com> wrote:
> 
>> 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.

I can't comment on the s390x-specific details, but code-wise the patch
LGTM.  Tom de Vries might have an opinion, he was doing some s390x fixes
recently.

Some nits below.

>> ---
>>  .../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

Unexpected `#` by itself above.

>> @@ -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

Likewise.

Simon

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] [gdb/testsuite] Fix gdb.base/inline-frame-cycle-unwind.exp for s390x
  2025-12-09 19:53   ` Simon Marchi
@ 2025-12-11 13:50     ` Tom de Vries
  0 siblings, 0 replies; 4+ messages in thread
From: Tom de Vries @ 2025-12-11 13:50 UTC (permalink / raw)
  To: Simon Marchi, Kevin Buettner, gdb-patches

On 12/9/25 8:53 PM, Simon Marchi wrote:
> On 12/8/25 2:53 PM, Kevin Buettner wrote:
>> Ping.
>>
>> On Sat,  1 Nov 2025 21:46:51 -0700
>> Kevin Buettner <kevinb@redhat.com> wrote:
>>
>>> 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.
> 
> I can't comment on the s390x-specific details, but code-wise the patch
> LGTM.  Tom de Vries might have an opinion, he was doing some s390x fixes
> recently.
> 

After playing around with printf debugging the test-case on s390x-linux 
and x86_64-linux side by side, my understanding is that the test-case 
fails because it doesn't manage to correctly calculate frame-ids for 
s390x, which can easily be fixed by using "maint print frame-id".

I've got a proposal for an alternative patch ( 
https://sourceware.org/pipermail/gdb-patches/2025-December/223355.html ).

Thanks,
- Tom

> Some nits below.
> 
>>> ---
>>>   .../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
> 
> Unexpected `#` by itself above.
> 
>>> @@ -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
> 
> Likewise.
> 
> Simon


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2025-12-11 13:51 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-11-02  4:46 [PATCH] [gdb/testsuite] Fix gdb.base/inline-frame-cycle-unwind.exp for s390x Kevin Buettner
2025-12-08 19:53 ` Kevin Buettner
2025-12-09 19:53   ` Simon Marchi
2025-12-11 13:50     ` Tom de Vries

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox