[gdb/testsuite] Detect gdb prompt after monitor exit

With this gdbserver-support.exp patch:
...
@@ -451,8 +451,10 @@ proc gdbserver_exit { is_mi } {
 	    # We use expect rather than gdb_expect because
 	    # we want to suppress printing exception messages, otherwise,
 	    # remote_expect, invoked by gdb_expect, prints the exceptions.
+	    set have_prompt 0
 	    expect {
 		-i "$gdb_spawn_id" -re "$gdb_prompt $" {
+		    set have_prompt 1
 		    exp_continue
 		}
 		-i "$server_spawn_id" eof {
@@ -463,6 +465,7 @@ proc gdbserver_exit { is_mi } {
                    warning "Timed out waiting for EOF in server after $monitor_exit"
                }
 	    }
+	    gdb_assert {$have_prompt}
 	}
     }
     close_gdbserver
...
and with this in parallel:
...
$ stress -c 5
...
we run into this and similar FAILs:
...
FAIL: gdb.multi/multi-target.exp: continue: non-stop=on: $have_prompt
...

In more detail:
...
(gdb) PASS: gdb.multi/multi-target.exp: continue: non-stop=on: inferior 5
Remote debugging from host ::1, port 40712^M
Process build/gdb/testsuite/outputs/gdb.multi/multi-target/multi-target \
  created; pid = 11098^M
monitor exit^M
Killing process(es): 11098^M
FAIL: gdb.multi/multi-target.exp: continue: non-stop=on: $have_prompt
spawn build/gdb/testsuite/../../gdb/gdb -nw -nx -data-directory \
  build/gdb/testsuite/../data-directory^M
...

After issuing a "monitor exit" command, we should always get a prompt back, so
check for that.

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2020-09-16  Tom de Vries  <tdevries@suse.de>

	* lib/gdbserver-support.exp (gdbserver_exit): Make sure we
	get the gdb prompt after issuing "monitor exit".
This commit is contained in:
Tom de Vries
2020-09-16 14:53:26 +02:00
parent 0690f59128
commit 337882d477
2 changed files with 13 additions and 1 deletions

View File

@ -1,3 +1,8 @@
2020-09-16 Tom de Vries <tdevries@suse.de>
* lib/gdbserver-support.exp (gdbserver_exit): Make sure we
get the gdb prompt after issuing "monitor exit".
2020-09-16 Tom de Vries <tdevries@suse.de> 2020-09-16 Tom de Vries <tdevries@suse.de>
PR testsuite/26624 PR testsuite/26624

View File

@ -451,13 +451,20 @@ proc gdbserver_exit { is_mi } {
# We use expect rather than gdb_expect because # We use expect rather than gdb_expect because
# we want to suppress printing exception messages, otherwise, # we want to suppress printing exception messages, otherwise,
# remote_expect, invoked by gdb_expect, prints the exceptions. # remote_expect, invoked by gdb_expect, prints the exceptions.
set have_prompt 0
expect { expect {
-i "$gdb_spawn_id" -re "$gdb_prompt $" { -i "$gdb_spawn_id" -re "$gdb_prompt $" {
exp_continue set have_prompt 1
if { [info exists server_spawn_id] } {
exp_continue
}
} }
-i "$server_spawn_id" eof { -i "$server_spawn_id" eof {
wait -i $expect_out(spawn_id) wait -i $expect_out(spawn_id)
unset server_spawn_id unset server_spawn_id
if { ! $have_prompt } {
exp_continue
}
} }
timeout { timeout {
warning "Timed out waiting for EOF in server after $monitor_exit" warning "Timed out waiting for EOF in server after $monitor_exit"