[1/2,gdb/testsuite] Fix gdb.threads/leader-exit-attach.exp with check-read1

Message ID 20240717072410.3085-1-tdevries@suse.de
State Committed
Headers
Series [1/2,gdb/testsuite] Fix gdb.threads/leader-exit-attach.exp with check-read1 |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_gdb_build--master-arm success Build passed
linaro-tcwg-bot/tcwg_gdb_check--master-arm success Test passed
linaro-tcwg-bot/tcwg_gdb_build--master-aarch64 success Build passed
linaro-tcwg-bot/tcwg_gdb_check--master-aarch64 success Test passed

Commit Message

Tom de Vries July 17, 2024, 7:24 a.m. UTC
  With test-case gdb.threads/leader-exit-attach.exp and check-read1, I run into:
...
(gdb) attach 18591^M
Attaching to program: leader-exit-attach, process 18591^M
warning: process 18591 is a zombie - the process has already terminatedKFAIL: $exp: attach (PRMS: gdb/31555)
^M
ptrace: Operation not permitted.^M
(gdb) FAIL: $exp: get valueof "$_inferior_thread_count"
...

The problem is that the gdb_test_multiple in the test-case doesn't consume the
prompt in all clauses:
...
gdb_test_multiple "attach $testpid" "attach" {
    -re "Attaching to process $testpid failed.*" {
	# GNU/Linux gdbserver.  Linux ptrace does not let you attach
	# to zombie threads.
	setup_kfail "gdb/31555" *-*-linux*
	fail $gdb_test_name
    }
    -re "warning: process $testpid is a zombie - the process has already terminated.*" {
	# Native GNU/Linux.  Linux ptrace does not let you attach to
	# zombie threads.
	setup_kfail "gdb/31555" *-*-linux*
	fail $gdb_test_name
    }
    -re "Attaching to program: $escapedbinfile, process $testpid.*$gdb_prompt $" {
	pass $gdb_test_name
	set attached 1
    }
}
...

Fix this by using -wrap in the first two clauses.

While we're at it, also use -wrap in the third clause.

Tested on x86_64-linux.
---
 gdb/testsuite/gdb.threads/leader-exit-attach.exp | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)


base-commit: b6a5604da00b0438a0fb9b93e8713b14f323b6e4
  

Comments

Tom de Vries July 29, 2024, 12:06 p.m. UTC | #1
On 7/17/24 09:24, Tom de Vries wrote:
> With test-case gdb.threads/leader-exit-attach.exp and check-read1, I run into:
> ...
> (gdb) attach 18591^M
> Attaching to program: leader-exit-attach, process 18591^M
> warning: process 18591 is a zombie - the process has already terminatedKFAIL: $exp: attach (PRMS: gdb/31555)
> ^M
> ptrace: Operation not permitted.^M
> (gdb) FAIL: $exp: get valueof "$_inferior_thread_count"
> ...
> 
> The problem is that the gdb_test_multiple in the test-case doesn't consume the
> prompt in all clauses:
> ...
> gdb_test_multiple "attach $testpid" "attach" {
>      -re "Attaching to process $testpid failed.*" {
> 	# GNU/Linux gdbserver.  Linux ptrace does not let you attach
> 	# to zombie threads.
> 	setup_kfail "gdb/31555" *-*-linux*
> 	fail $gdb_test_name
>      }
>      -re "warning: process $testpid is a zombie - the process has already terminated.*" {
> 	# Native GNU/Linux.  Linux ptrace does not let you attach to
> 	# zombie threads.
> 	setup_kfail "gdb/31555" *-*-linux*
> 	fail $gdb_test_name
>      }
>      -re "Attaching to program: $escapedbinfile, process $testpid.*$gdb_prompt $" {
> 	pass $gdb_test_name
> 	set attached 1
>      }
> }
> ...
> 
> Fix this by using -wrap in the first two clauses.
> 
> While we're at it, also use -wrap in the third clause.
> 

I've pushed this series.

Thanks,
- Tom

> Tested on x86_64-linux.
> ---
>   gdb/testsuite/gdb.threads/leader-exit-attach.exp | 6 +++---
>   1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/gdb/testsuite/gdb.threads/leader-exit-attach.exp b/gdb/testsuite/gdb.threads/leader-exit-attach.exp
> index c1ed1baaa67..a1bc2d470d5 100644
> --- a/gdb/testsuite/gdb.threads/leader-exit-attach.exp
> +++ b/gdb/testsuite/gdb.threads/leader-exit-attach.exp
> @@ -41,19 +41,19 @@ set is_gdbserver [target_is_gdbserver]
>   set attached 0
>   
>   gdb_test_multiple "attach $testpid" "attach" {
> -    -re "Attaching to process $testpid failed.*" {
> +    -re -wrap "Attaching to process $testpid failed.*" {
>   	# GNU/Linux gdbserver.  Linux ptrace does not let you attach
>   	# to zombie threads.
>   	setup_kfail "gdb/31555" *-*-linux*
>   	fail $gdb_test_name
>       }
> -    -re "warning: process $testpid is a zombie - the process has already terminated.*" {
> +    -re -wrap "warning: process $testpid is a zombie - the process has already terminated.*" {
>   	# Native GNU/Linux.  Linux ptrace does not let you attach to
>   	# zombie threads.
>   	setup_kfail "gdb/31555" *-*-linux*
>   	fail $gdb_test_name
>       }
> -    -re "Attaching to program: $escapedbinfile, process $testpid.*$gdb_prompt $" {
> +    -re -wrap "Attaching to program: $escapedbinfile, process $testpid.*" {
>   	pass $gdb_test_name
>   	set attached 1
>       }
> 
> base-commit: b6a5604da00b0438a0fb9b93e8713b14f323b6e4
  

Patch

diff --git a/gdb/testsuite/gdb.threads/leader-exit-attach.exp b/gdb/testsuite/gdb.threads/leader-exit-attach.exp
index c1ed1baaa67..a1bc2d470d5 100644
--- a/gdb/testsuite/gdb.threads/leader-exit-attach.exp
+++ b/gdb/testsuite/gdb.threads/leader-exit-attach.exp
@@ -41,19 +41,19 @@  set is_gdbserver [target_is_gdbserver]
 set attached 0
 
 gdb_test_multiple "attach $testpid" "attach" {
-    -re "Attaching to process $testpid failed.*" {
+    -re -wrap "Attaching to process $testpid failed.*" {
 	# GNU/Linux gdbserver.  Linux ptrace does not let you attach
 	# to zombie threads.
 	setup_kfail "gdb/31555" *-*-linux*
 	fail $gdb_test_name
     }
-    -re "warning: process $testpid is a zombie - the process has already terminated.*" {
+    -re -wrap "warning: process $testpid is a zombie - the process has already terminated.*" {
 	# Native GNU/Linux.  Linux ptrace does not let you attach to
 	# zombie threads.
 	setup_kfail "gdb/31555" *-*-linux*
 	fail $gdb_test_name
     }
-    -re "Attaching to program: $escapedbinfile, process $testpid.*$gdb_prompt $" {
+    -re -wrap "Attaching to program: $escapedbinfile, process $testpid.*" {
 	pass $gdb_test_name
 	set attached 1
     }