public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] [gdb/testsuite] Fix FAIL in gdb.threads/killed-outside.exp
@ 2021-10-29 10:04 Tom de Vries
  2021-10-29 10:05 ` [PATCH] [gdb] " Tom de Vries
  0 siblings, 1 reply; 2+ messages in thread
From: Tom de Vries @ 2021-10-29 10:04 UTC (permalink / raw)
  To: gdb-patches

On openSUSE Leap 15.2 I run into:
...
(gdb) PASS: gdb.threads/killed-outside.exp: get pid of inferior
Executing on target: kill -9 24753    (timeout = 300)
builtin_spawn -ignore SIGHUP kill -9 24753^M
continue^M
Continuing.^M
Couldn't get registers: No such process.^M
(gdb) [Thread 0x7ffff74c4700 (LWP 24757) exited]^M
^M
Program terminated with signal SIGKILL, Killed.^M
The program no longer exists.^M
FAIL: gdb.threads/killed-outside.exp: prompt after first continue (timeout)
...

The test-case expects the messages:
- "Program terminated with signal SIGKILL, Killed."
- "The program no longer exists."
before the prompt.

When debugging the "Couldn't get registers: No such process" message using
this command-line reproduction:
...
$ gdb -q outputs/gdb.threads/killed-outside/killed-outside \
    -ex "tb all_started" \
    -ex "run" \
    -ex 'shell kill -9 $(pidof killed-outside)' \
    -ex continue
...
I noticed that the first time this error is thrown, it's caught by
regcache_read_pc_protected.

The second time the error is thrown, it's from a regular regcache_read_pc in
resume_1, and we see the error show up.

Fix this by using regcache_read_pc_protected in resume_1 as well.

Tested on x86_64-linux.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=26664
---
 gdb/infrun.c                                 |  2 +-
 gdb/testsuite/gdb.threads/killed-outside.exp | 15 +++------------
 2 files changed, 4 insertions(+), 13 deletions(-)

diff --git a/gdb/infrun.c b/gdb/infrun.c
index 4698fe20cc1..26d11c57574 100644
--- a/gdb/infrun.c
+++ b/gdb/infrun.c
@@ -2268,7 +2268,7 @@ resume_1 (enum gdb_signal sig)
       step = false;
     }
 
-  CORE_ADDR pc = regcache_read_pc (regcache);
+  CORE_ADDR pc = regcache_read_pc_protected (regcache);
 
   infrun_debug_printf ("step=%d, signal=%s, trap_expected=%d, "
 		       "current thread [%s] at %s",
diff --git a/gdb/testsuite/gdb.threads/killed-outside.exp b/gdb/testsuite/gdb.threads/killed-outside.exp
index 7050a4b84ba..f37d896d80d 100644
--- a/gdb/testsuite/gdb.threads/killed-outside.exp
+++ b/gdb/testsuite/gdb.threads/killed-outside.exp
@@ -40,19 +40,10 @@ sleep 2
 set no_such_process_msg "Couldn't get registers: No such process\."
 set killed_msg "Program terminated with signal SIGKILL, Killed\."
 set no_longer_exists_msg "The program no longer exists\."
-set not_being_run_msg "The program is not being run\."
 
-gdb_test_multiple "continue" "prompt after first continue" {
-    -re "Continuing\.\r\n$no_such_process_msg\r\n$no_such_process_msg\r\n$gdb_prompt " {
-	pass $gdb_test_name
-	# Two times $no_such_process_msg.  The bug condition was triggered, go
-	# check for it.
-	gdb_test_multiple "" "messages" {
-	    -re ".*$killed_msg.*$no_longer_exists_msg\r\n" {
-		pass $gdb_test_name
-		gdb_test "continue" $not_being_run_msg "second continue"
-	    }
-	}
+gdb_test_multiple "continue" "" {
+    -re "$no_such_process_msg.*$gdb_prompt " {
+	fail $gdb_test_name
     }
     -re -wrap ".*$killed_msg.*$no_longer_exists_msg" {
 	pass $gdb_test_name

base-commit: 208eb58158c2f23a7fbaff32a4912dbbb8d0ee5c
-- 
2.26.2


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

* [PATCH] [gdb] Fix FAIL in gdb.threads/killed-outside.exp
  2021-10-29 10:04 [PATCH] [gdb/testsuite] Fix FAIL in gdb.threads/killed-outside.exp Tom de Vries
@ 2021-10-29 10:05 ` Tom de Vries
  0 siblings, 0 replies; 2+ messages in thread
From: Tom de Vries @ 2021-10-29 10:05 UTC (permalink / raw)
  To: gdb-patches

[ correcting gdb/testsuite -> gdb ]

On 10/29/21 12:04 PM, Tom de Vries via Gdb-patches wrote:
> On openSUSE Leap 15.2 I run into:
> ...
> (gdb) PASS: gdb.threads/killed-outside.exp: get pid of inferior
> Executing on target: kill -9 24753    (timeout = 300)
> builtin_spawn -ignore SIGHUP kill -9 24753^M
> continue^M
> Continuing.^M
> Couldn't get registers: No such process.^M
> (gdb) [Thread 0x7ffff74c4700 (LWP 24757) exited]^M
> ^M
> Program terminated with signal SIGKILL, Killed.^M
> The program no longer exists.^M
> FAIL: gdb.threads/killed-outside.exp: prompt after first continue (timeout)
> ...
> 
> The test-case expects the messages:
> - "Program terminated with signal SIGKILL, Killed."
> - "The program no longer exists."
> before the prompt.
> 
> When debugging the "Couldn't get registers: No such process" message using
> this command-line reproduction:
> ...
> $ gdb -q outputs/gdb.threads/killed-outside/killed-outside \
>     -ex "tb all_started" \
>     -ex "run" \
>     -ex 'shell kill -9 $(pidof killed-outside)' \
>     -ex continue
> ...
> I noticed that the first time this error is thrown, it's caught by
> regcache_read_pc_protected.
> 
> The second time the error is thrown, it's from a regular regcache_read_pc in
> resume_1, and we see the error show up.
> 
> Fix this by using regcache_read_pc_protected in resume_1 as well.
> 
> Tested on x86_64-linux.
> 
> Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=26664
> ---
>  gdb/infrun.c                                 |  2 +-
>  gdb/testsuite/gdb.threads/killed-outside.exp | 15 +++------------
>  2 files changed, 4 insertions(+), 13 deletions(-)
> 
> diff --git a/gdb/infrun.c b/gdb/infrun.c
> index 4698fe20cc1..26d11c57574 100644
> --- a/gdb/infrun.c
> +++ b/gdb/infrun.c
> @@ -2268,7 +2268,7 @@ resume_1 (enum gdb_signal sig)
>        step = false;
>      }
>  
> -  CORE_ADDR pc = regcache_read_pc (regcache);
> +  CORE_ADDR pc = regcache_read_pc_protected (regcache);
>  
>    infrun_debug_printf ("step=%d, signal=%s, trap_expected=%d, "
>  		       "current thread [%s] at %s",
> diff --git a/gdb/testsuite/gdb.threads/killed-outside.exp b/gdb/testsuite/gdb.threads/killed-outside.exp
> index 7050a4b84ba..f37d896d80d 100644
> --- a/gdb/testsuite/gdb.threads/killed-outside.exp
> +++ b/gdb/testsuite/gdb.threads/killed-outside.exp
> @@ -40,19 +40,10 @@ sleep 2
>  set no_such_process_msg "Couldn't get registers: No such process\."
>  set killed_msg "Program terminated with signal SIGKILL, Killed\."
>  set no_longer_exists_msg "The program no longer exists\."
> -set not_being_run_msg "The program is not being run\."
>  
> -gdb_test_multiple "continue" "prompt after first continue" {
> -    -re "Continuing\.\r\n$no_such_process_msg\r\n$no_such_process_msg\r\n$gdb_prompt " {
> -	pass $gdb_test_name
> -	# Two times $no_such_process_msg.  The bug condition was triggered, go
> -	# check for it.
> -	gdb_test_multiple "" "messages" {
> -	    -re ".*$killed_msg.*$no_longer_exists_msg\r\n" {
> -		pass $gdb_test_name
> -		gdb_test "continue" $not_being_run_msg "second continue"
> -	    }
> -	}
> +gdb_test_multiple "continue" "" {
> +    -re "$no_such_process_msg.*$gdb_prompt " {
> +	fail $gdb_test_name
>      }
>      -re -wrap ".*$killed_msg.*$no_longer_exists_msg" {
>  	pass $gdb_test_name
> 
> base-commit: 208eb58158c2f23a7fbaff32a4912dbbb8d0ee5c
> 

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

end of thread, other threads:[~2021-10-29 10:05 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-29 10:04 [PATCH] [gdb/testsuite] Fix FAIL in gdb.threads/killed-outside.exp Tom de Vries
2021-10-29 10:05 ` [PATCH] [gdb] " 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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).