Skip to content

Commit

Permalink
[lldb] [llgs] Fix premature server exit if multiprocess+nonstop
Browse files Browse the repository at this point in the history
Fix lldb-server in the non-stop + multiprocess mode to exit on vStopped
only if all processes have exited, rather than when the first one exits.

Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.llvm.org/D128639
  • Loading branch information
mgorny committed Jun 28, 2022
1 parent b415f8e commit 261d003
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3860,9 +3860,9 @@ GDBRemoteCommunicationServerLLGS::Handle_vStopped(
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();
}
Expand Down
42 changes: 33 additions & 9 deletions lldb/test/API/tools/lldb-server/TestGdbRemoteFork.py
Original file line number Diff line number Diff line change
Expand Up @@ -392,17 +392,17 @@ def test_vkill_both(self):
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:
Expand All @@ -427,9 +427,17 @@ def resume_one_test(self, run_order, use_vCont=False):
"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([
Expand Down Expand Up @@ -475,6 +483,14 @@ def test_c_child_then_parent(self):
def test_c_interspersed(self):
self.resume_one_test(run_order=["parent", "child", "parent", "child"])

@expectedFailureAll(archs=["arm"]) # TODO
@expectedFailureAll(archs=["aarch64"],
bugnumber="https://github.com/llvm/llvm-project/issues/56268")
@add_test_categories(["fork"])
def test_c_interspersed_nonstop(self):
self.resume_one_test(run_order=["parent", "child", "parent", "child"],
nonstop=True)

@expectedFailureAll(archs=["arm"]) # TODO
@expectedFailureAll(archs=["aarch64"],
bugnumber="https://github.com/llvm/llvm-project/issues/56268")
Expand Down Expand Up @@ -513,6 +529,14 @@ def test_vCont_interspersed(self):
self.resume_one_test(run_order=["parent", "child", "parent", "child"],
use_vCont=True)

@expectedFailureAll(archs=["arm"]) # TODO
@expectedFailureAll(archs=["aarch64"],
bugnumber="https://github.com/llvm/llvm-project/issues/56268")
@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 = (
Expand Down

0 comments on commit 261d003

Please sign in to comment.