diff --git a/gdb/remote.c b/gdb/remote.c index ff75204ee8..d036dcf9cf 100644 --- a/gdb/remote.c +++ b/gdb/remote.c @@ -7919,8 +7919,16 @@ remote_target::wait_as (ptid_t ptid, target_waitstatus *status, int options) event_ptid = first_remote_resumed_thread (this); } else - /* A process exit. Invalidate our notion of current thread. */ - record_currthread (rs, minus_one_ptid); + { + /* A process exit. Invalidate our notion of current thread. */ + record_currthread (rs, minus_one_ptid); + /* It's possible that the packet did not include a pid. */ + if (event_ptid == null_ptid) + event_ptid = first_remote_resumed_thread (this); + /* EVENT_PTID could still be NULL_PTID. Double-check. */ + if (event_ptid == null_ptid) + event_ptid = magic_null_ptid; + } return event_ptid; } diff --git a/gdb/testsuite/gdb.server/connect-without-multi-process.exp b/gdb/testsuite/gdb.server/connect-without-multi-process.exp index fba20a6a0b..36b42207e2 100644 --- a/gdb/testsuite/gdb.server/connect-without-multi-process.exp +++ b/gdb/testsuite/gdb.server/connect-without-multi-process.exp @@ -14,7 +14,7 @@ # along with this program. If not, see . */ # Check that we can connect to GDBserver with the multiprocess -# extensions disabled, and run to main. +# extensions disabled, run to main, and finish the process. load_lib gdbserver-support.exp @@ -52,6 +52,9 @@ proc do_test {multiprocess} { "target $gdbserver_protocol" gdb_test "continue" "main .*" "continue to main" + + # Also test the termination because the 'W' packet differs + gdb_test "continue" ".* exited normally.*" "continue to termination" } foreach multiprocess { "off" "auto" } {