[1/2] gdb/testsuite: fix gdb.threads/threadcrash.exp on 32-bit arm targets

Message ID 20240201155812.1189388-3-blarsen@redhat.com
State New
Headers
Series Fixes to gdb.threads/threadcrash.exp |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_gdb_build--master-aarch64 fail Patch failed to apply
linaro-tcwg-bot/tcwg_gdb_build--master-arm fail Patch failed to apply

Commit Message

Guinevere Larsen Feb. 1, 2024, 3:58 p.m. UTC
  There are 2 issues with the test gdb.threads/threadcrash.exp on arm
targets, both relating to issues in how the targets handles gcores. The
first is that the test fails to cout the number of threads in the
inferior and the second is that GDB can't properly backtrace from a
gcore.

The first error is fixed on this commit by getting the convenience
variable _inferior_thread_count as opposed to calculating it based on
the output of "info threads"

For the second, this test just emits a single xfail referring back to PR
corefiles/31294, which tracks the issues with gcores in 32-bit arm
targets.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31294
---
 gdb/testsuite/gdb.threads/threadcrash.exp | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)
  

Comments

Tom de Vries Feb. 2, 2024, 12:04 p.m. UTC | #1
On 2/1/24 16:58, Guinevere Larsen wrote:
> There are 2 issues with the test gdb.threads/threadcrash.exp on arm
> targets, both relating to issues in how the targets handles gcores. The
> first is that the test fails to cout the number of threads in the
> inferior and the second is that GDB can't properly backtrace from a
> gcore.
> 
> The first error is fixed on this commit by getting the convenience
> variable _inferior_thread_count as opposed to calculating it based on
> the output of "info threads"
> 
> For the second, this test just emits a single xfail referring back to PR
> corefiles/31294, which tracks the issues with gcores in 32-bit arm
> targets.
> 

Hi Guinevere,

the fact that the PR has the corefiles component suggests that there's a 
problem with gdb, which means a kfail should be used. An xfail is used 
to indicate problems in the environment (meaning external to gdb), like 
a known problem in the linux kernel, or incorrect debug info generated 
by the compiler, etc.

Thanks,
- Tom

> Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31294
> ---
>   gdb/testsuite/gdb.threads/threadcrash.exp | 15 ++++++++-------
>   1 file changed, 8 insertions(+), 7 deletions(-)
> 
> diff --git a/gdb/testsuite/gdb.threads/threadcrash.exp b/gdb/testsuite/gdb.threads/threadcrash.exp
> index d3e3494cbea..362c4c5879d 100644
> --- a/gdb/testsuite/gdb.threads/threadcrash.exp
> +++ b/gdb/testsuite/gdb.threads/threadcrash.exp
> @@ -27,12 +27,9 @@
>   proc test_thread_count {} {
>       set thread_count 0
>   
> -    gdb_test_multiple "info threads" "getting thread count" -lbl {
> -	-re "\(Thread\|LWP\)" {
> -	    incr thread_count
> -	    exp_continue
> -	}
> -	-re "$::gdb_prompt " {
> +    gdb_test_multiple "print \$_inferior_thread_count" "getting thread count" {
> +	-re ".* = (\[0-9]+).*" {
> +	    set thread_count $expect_out(1,string)
>   	    gdb_assert {$thread_count == 7}
>   	}
>       }
> @@ -230,4 +227,8 @@ test_live_inferior
>   
>   test_corefile
>   
> -test_gcore
> +if { [is_aarch32_target] } {
> +    xfail "gcore tests fail on 32-bit arm, see PR corefiles/31294"
> +} else {
> +    test_gcore
> +}
  

Patch

diff --git a/gdb/testsuite/gdb.threads/threadcrash.exp b/gdb/testsuite/gdb.threads/threadcrash.exp
index d3e3494cbea..362c4c5879d 100644
--- a/gdb/testsuite/gdb.threads/threadcrash.exp
+++ b/gdb/testsuite/gdb.threads/threadcrash.exp
@@ -27,12 +27,9 @@ 
 proc test_thread_count {} {
     set thread_count 0
 
-    gdb_test_multiple "info threads" "getting thread count" -lbl {
-	-re "\(Thread\|LWP\)" {
-	    incr thread_count
-	    exp_continue
-	}
-	-re "$::gdb_prompt " {
+    gdb_test_multiple "print \$_inferior_thread_count" "getting thread count" {
+	-re ".* = (\[0-9]+).*" {
+	    set thread_count $expect_out(1,string)
 	    gdb_assert {$thread_count == 7}
 	}
     }
@@ -230,4 +227,8 @@  test_live_inferior
 
 test_corefile
 
-test_gcore
+if { [is_aarch32_target] } {
+    xfail "gcore tests fail on 32-bit arm, see PR corefiles/31294"
+} else {
+    test_gcore
+}