From: Tom de Vries Date: Wed, 16 Sep 2020 12:53:26 +0000 (+0200) Subject: [gdb/testsuite] Detect gdb prompt after monitor exit X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=337882d477675296a22fd8c1f7412ca30c70d9b0;p=binutils-gdb.git [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 * lib/gdbserver-support.exp (gdbserver_exit): Make sure we get the gdb prompt after issuing "monitor exit". --- diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index 481d18a3217..d368b2dfc1a 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2020-09-16 Tom de Vries + + * lib/gdbserver-support.exp (gdbserver_exit): Make sure we + get the gdb prompt after issuing "monitor exit". + 2020-09-16 Tom de Vries PR testsuite/26624 diff --git a/gdb/testsuite/lib/gdbserver-support.exp b/gdb/testsuite/lib/gdbserver-support.exp index a2cc80f28d7..2734ca6c878 100644 --- a/gdb/testsuite/lib/gdbserver-support.exp +++ b/gdb/testsuite/lib/gdbserver-support.exp @@ -451,13 +451,20 @@ 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 $" { - exp_continue + set have_prompt 1 + if { [info exists server_spawn_id] } { + exp_continue + } } -i "$server_spawn_id" eof { wait -i $expect_out(spawn_id) unset server_spawn_id + if { ! $have_prompt } { + exp_continue + } } timeout { warning "Timed out waiting for EOF in server after $monitor_exit"