[gdb/testsuite] Detect gdb prompt after monitor exit
authorTom de Vries <tdevries@suse.de>
Wed, 16 Sep 2020 12:53:26 +0000 (14:53 +0200)
committerTom de Vries <tdevries@suse.de>
Wed, 16 Sep 2020 12:53:26 +0000 (14:53 +0200)
commit337882d477675296a22fd8c1f7412ca30c70d9b0
tree0c10194ecef9ad496caed05c7e62c406f2327128
parent0690f591284b7de9fe0a423b148a5617062ccc1f
[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".
gdb/testsuite/ChangeLog
gdb/testsuite/lib/gdbserver-support.exp
This page took 0.024782 seconds and 4 git commands to generate.