Skip to content

Commit 261d003

Browse files
committed
[lldb] [llgs] Fix premature server exit if multiprocess+nonstop
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
1 parent b415f8e commit 261d003

File tree

2 files changed

+36
-12
lines changed

2 files changed

+36
-12
lines changed

lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3860,9 +3860,9 @@ GDBRemoteCommunicationServerLLGS::Handle_vStopped(
38603860
m_stop_notification_queue.pop_front();
38613861
if (!m_stop_notification_queue.empty())
38623862
return SendPacketNoLock(m_stop_notification_queue.front());
3863-
// If this was the last notification and the process exited, terminate
3864-
// the server.
3865-
if (m_inferior_prev_state == eStateExited) {
3863+
// If this was the last notification and all the processes exited,
3864+
// terminate the server.
3865+
if (m_debugged_processes.empty()) {
38663866
m_exit_now = true;
38673867
m_mainloop.RequestTermination();
38683868
}

lldb/test/API/tools/lldb-server/TestGdbRemoteFork.py

Lines changed: 33 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -392,17 +392,17 @@ def test_vkill_both(self):
392392
def test_vkill_both_nonstop(self):
393393
self.vkill_test(kill_parent=True, kill_child=True, nonstop=True)
394394

395-
def resume_one_test(self, run_order, use_vCont=False):
395+
def resume_one_test(self, run_order, use_vCont=False, nonstop=False):
396396
parent_pid, parent_tid, child_pid, child_tid = (
397-
self.start_fork_test(["fork", "trap"]))
397+
self.start_fork_test(["fork", "trap"], nonstop=nonstop))
398398

399399
parent_expect = [
400-
"[$]T05thread:p{}.{};.*".format(parent_pid, parent_tid),
401-
"[$]W00;process:{}#.*".format(parent_pid),
400+
"T05thread:p{}.{};.*".format(parent_pid, parent_tid),
401+
"W00;process:{}#.*".format(parent_pid),
402402
]
403403
child_expect = [
404-
"[$]T05thread:p{}.{};.*".format(child_pid, child_tid),
405-
"[$]W00;process:{}#.*".format(child_pid),
404+
"T05thread:p{}.{};.*".format(child_pid, child_tid),
405+
"W00;process:{}#.*".format(child_pid),
406406
]
407407

408408
for x in run_order:
@@ -427,9 +427,17 @@ def resume_one_test(self, run_order, use_vCont=False):
427427
"send packet: $OK#00",
428428
"read packet: $c#00",
429429
], True)
430-
self.test_sequence.add_log_lines([
431-
{"direction": "send", "regex": expect},
432-
], True)
430+
if nonstop:
431+
self.test_sequence.add_log_lines([
432+
"send packet: $OK#00",
433+
{"direction": "send", "regex": "%Stop:" + expect},
434+
"read packet: $vStopped#00",
435+
"send packet: $OK#00",
436+
], True)
437+
else:
438+
self.test_sequence.add_log_lines([
439+
{"direction": "send", "regex": "[$]" + expect},
440+
], True)
433441
# if at least one process remained, check both PIDs
434442
if parent_expect or child_expect:
435443
self.test_sequence.add_log_lines([
@@ -475,6 +483,14 @@ def test_c_child_then_parent(self):
475483
def test_c_interspersed(self):
476484
self.resume_one_test(run_order=["parent", "child", "parent", "child"])
477485

486+
@expectedFailureAll(archs=["arm"]) # TODO
487+
@expectedFailureAll(archs=["aarch64"],
488+
bugnumber="https://github.com/llvm/llvm-project/issues/56268")
489+
@add_test_categories(["fork"])
490+
def test_c_interspersed_nonstop(self):
491+
self.resume_one_test(run_order=["parent", "child", "parent", "child"],
492+
nonstop=True)
493+
478494
@expectedFailureAll(archs=["arm"]) # TODO
479495
@expectedFailureAll(archs=["aarch64"],
480496
bugnumber="https://github.com/llvm/llvm-project/issues/56268")
@@ -513,6 +529,14 @@ def test_vCont_interspersed(self):
513529
self.resume_one_test(run_order=["parent", "child", "parent", "child"],
514530
use_vCont=True)
515531

532+
@expectedFailureAll(archs=["arm"]) # TODO
533+
@expectedFailureAll(archs=["aarch64"],
534+
bugnumber="https://github.com/llvm/llvm-project/issues/56268")
535+
@add_test_categories(["fork"])
536+
def test_vCont_interspersed_nonstop(self):
537+
self.resume_one_test(run_order=["parent", "child", "parent", "child"],
538+
use_vCont=True, nonstop=True)
539+
516540
@add_test_categories(["fork"])
517541
def test_vCont_two_processes(self):
518542
parent_pid, parent_tid, child_pid, child_tid = (

0 commit comments

Comments
 (0)