ensure error output of vgdb relay mode is shown to the GDB user
With GDB14.1, when there is more than one valgrind process, 'target remote | vgdb' shows:
(gdb) tar rem | vgdb
Remote debugging using | vgdb
no --pid= arg given and multiple valgrind pids found:
use --pid=913621 for ./Inst/bin/valgrind --vgdb-stop-at=startup ./gdbserver_tests/sleepers
use --pid=913622 for ./Inst/bin/valgrind --vgdb-stop-at=startup ./gdbserver_tests/sleepers
Remote communication error. Target disconnected: Connection reset by peer.
(gdb)
With GDB 15.0.50.
20240414-git, we obtain:
(gdb) tar rem | vgdb
Remote debugging using | vgdb
Remote communication error. Target disconnected: error while reading: Connection reset by peer.
(gdb)
This looks like a race condition:
When vgdb exits due to several pid or due to any other error (e.g. an argument
error), GDB gets a SIGPIPE and closes the pipe to/from vgdb. To avoid losing
the error messages In such cases, have vgdb wait for the first packet from GDB
before exiting.
With this change, the early errors of vgdb are shown to the user.
Tested on debian, with GDB 12, 13, 15 and 15.0.50.
20240414-git.