]> git.ipfire.org Git - thirdparty/valgrind.git/commit
ensure error output of vgdb relay mode is shown to the GDB user
authorPhilippe Waroquiers <philippe.waroquiers@skynet.be>
Sun, 14 Apr 2024 19:15:24 +0000 (21:15 +0200)
committerPhilippe Waroquiers <philippe.waroquiers@skynet.be>
Sun, 14 Apr 2024 19:40:24 +0000 (21:40 +0200)
commitba5088d2270ac55cfcbb9bc046b3c3aa0b0d4990
tree0d6a8f99f361eee6af1f83f0d239ca183952d15f
parent219998aeb64e28391861006e9eb1ea4b96d69083
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.
coregrind/vgdb.c