Index: lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp =================================================================== --- lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp +++ lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp @@ -3871,9 +3871,9 @@ m_stop_notification_queue.pop_front(); if (!m_stop_notification_queue.empty()) return SendPacketNoLock(m_stop_notification_queue.front()); - // If this was the last notification and the process exited, terminate - // the server. - if (m_inferior_prev_state == eStateExited) { + // If this was the last notification and all the processes exited, + // terminate the server. + if (m_debugged_processes.empty()) { m_exit_now = true; m_mainloop.RequestTermination(); } Index: lldb/test/API/tools/lldb-server/TestGdbRemoteFork.py =================================================================== --- lldb/test/API/tools/lldb-server/TestGdbRemoteFork.py +++ lldb/test/API/tools/lldb-server/TestGdbRemoteFork.py @@ -392,17 +392,17 @@ def test_vkill_both_nonstop(self): self.vkill_test(kill_parent=True, kill_child=True, nonstop=True) - def resume_one_test(self, run_order, use_vCont=False): + def resume_one_test(self, run_order, use_vCont=False, nonstop=False): parent_pid, parent_tid, child_pid, child_tid = ( - self.start_fork_test(["fork", "trap"])) + self.start_fork_test(["fork", "trap"], nonstop=nonstop)) parent_expect = [ - "[$]T05thread:p{}.{};.*".format(parent_pid, parent_tid), - "[$]W00;process:{}#.*".format(parent_pid), + "T05thread:p{}.{};.*".format(parent_pid, parent_tid), + "W00;process:{}#.*".format(parent_pid), ] child_expect = [ - "[$]T05thread:p{}.{};.*".format(child_pid, child_tid), - "[$]W00;process:{}#.*".format(child_pid), + "T05thread:p{}.{};.*".format(child_pid, child_tid), + "W00;process:{}#.*".format(child_pid), ] for x in run_order: @@ -427,9 +427,17 @@ "send packet: $OK#00", "read packet: $c#00", ], True) - self.test_sequence.add_log_lines([ - {"direction": "send", "regex": expect}, - ], True) + if nonstop: + self.test_sequence.add_log_lines([ + "send packet: $OK#00", + {"direction": "send", "regex": "%Stop:" + expect}, + "read packet: $vStopped#00", + "send packet: $OK#00", + ], True) + else: + self.test_sequence.add_log_lines([ + {"direction": "send", "regex": "[$]" + expect}, + ], True) # if at least one process remained, check both PIDs if parent_expect or child_expect: self.test_sequence.add_log_lines([ @@ -460,6 +468,11 @@ def test_c_interspersed(self): self.resume_one_test(run_order=["parent", "child", "parent", "child"]) + @add_test_categories(["fork"]) + def test_c_interspersed_nonstop(self): + self.resume_one_test(run_order=["parent", "child", "parent", "child"], + nonstop=True) + @add_test_categories(["fork"]) def test_vCont_parent(self): self.resume_one_test(run_order=["parent", "parent"], use_vCont=True) @@ -483,6 +496,11 @@ self.resume_one_test(run_order=["parent", "child", "parent", "child"], use_vCont=True) + @add_test_categories(["fork"]) + def test_vCont_interspersed_nonstop(self): + self.resume_one_test(run_order=["parent", "child", "parent", "child"], + use_vCont=True, nonstop=True) + @add_test_categories(["fork"]) def test_vCont_two_processes(self): parent_pid, parent_tid, child_pid, child_tid = (