[Lldb-commits] [PATCH] D128639: [lldb] [llgs] Fix premature server exit if multiprocess+nonstop

Michał Górny via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Tue Jun 28 12:49:36 PDT 2022


This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG261d0033500e: [lldb] [llgs] Fix premature server exit if multiprocess+nonstop (authored by mgorny).
Herald added a project: LLDB.

Changed prior to commit:
  https://reviews.llvm.org/D128639?vs=440187&id=440733#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D128639/new/

https://reviews.llvm.org/D128639

Files:
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
  lldb/test/API/tools/lldb-server/TestGdbRemoteFork.py


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([
@@ -475,6 +483,14 @@
     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")
@@ -513,6 +529,14 @@
         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 = (
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
@@ -3860,9 +3860,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();
   }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D128639.440733.patch
Type: text/x-patch
Size: 4416 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20220628/c74e80e8/attachment-0001.bin>


More information about the lldb-commits mailing list