testsuite: Don't use expect_background to reap gdbserver
I adjusted a test to do 'expect -i $server_spawn_id -re ...', and saw
really strange behavior. Whether that expect would work, depended on
whether GDB would also send output and the same expect matched it too
(on $gdb_spawn_id). I was perplexed until I noticed that
gdbserver_spawn spawns gdbserver and then uses expect_background to
reap gdbserver. That expect_background conflicts/races with any
"expect -i $server_spawn_id" done anywhere else in parallel...
In order to make it possible for tests to read inferior I/O out of
$server_spawn_id, we to get rid of that expect_background. This patch
makes us instead reap gdbserver's spawn id when GDB exits. If GDB is
still around, this gives a chance for gdbserver to exit cleanly. The
current code in gdb_finish uses "kill", but that doesn't work with
extended-remote (gdbserver doesn't exit). We now use "monitor exit"
instead which works in both remote and extended-remote modes.
gdb/testsuite/ChangeLog:
2015-04-07 Pedro Alves <palves@redhat.com>
* lib/gdb.exp (gdb_finish): Delete persistent gdbserver handling.
* lib/gdbserver-support.exp (gdbserver_start): Make
$server_spawn_id global.
(gdbserver_start): Don't wait for gdbserver's spawn id with
expect_background.
(close_gdbserver): New procedure.
(gdb_exit): Rename the default version and reimplement.