[gdb/testsuite] Fix silent timeout in gdb.multi/multi-target.exp
While running test-case gdb.multi/multi-target.exp, I observed a silent
timeout related to "monitor exit".
By making the timeout explicit in an expect clause in gdbserver_gdb_exit:
...
+ timeout {
+ warning "Timed out waiting for EOF in server after $monitor_exit"
+ }
...
we get in the log:
...
monitor exit^M
"monitor" command not supported by this target.^M
(gdb) WARNING: Timed out waiting for EOF in server after monitor exit
...
What happens is the following:
- the inferior 5 is selected
- a breakpoint is set in inferior 1
- the breakpoint triggers and we switch to inferior 1
- setup is called by test_continue, which calls clean_restart, which calls
gdbserver_gdb_exit (due to load_lib gdbserver-support.exp)
- gdbserver_gdb_exit issues "monitor exit"
- gdb responds with "not supported by this target" because inferior 1 is
native
Fix this by keeping a list of server_spawn_id, and cleaning those up before
calling gdbserver_gdb_exit.
This reduces testing time from 1m22s to 32s.
gdb/testsuite/ChangeLog:
2020-04-02 Tom de Vries <tdevries@suse.de>
* lib/gdbserver-support.exp (gdbserver_exit): Factor out of ...
(gdbserver_gdb_exit): ... here. Add timeout warning.
* gdb.multi/multi-target.exp (server_spawn_ids): New global var.
(connect_target_extended_remote): Append new server_spawn_id to
server_spawn_ids.
(cleanup): New proc.
(setup, <toplevel>): Call cleanup.