[Lldb-commits] [lldb] 29caa85 - [lldb] Restore original meaning to test_qThreadStopInfo_only_reports_one_thread_stop_reason_during_interrupt

Pavel Labath via lldb-commits lldb-commits at lists.llvm.org
Wed Feb 9 03:35:08 PST 2022


Author: Pavel Labath
Date: 2022-02-09T12:34:55+01:00
New Revision: 29caa8583f60ed5aa668144491ce65be00986947

URL: https://github.com/llvm/llvm-project/commit/29caa8583f60ed5aa668144491ce65be00986947
DIFF: https://github.com/llvm/llvm-project/commit/29caa8583f60ed5aa668144491ce65be00986947.diff

LOG: [lldb] Restore original meaning to test_qThreadStopInfo_only_reports_one_thread_stop_reason_during_interrupt

D119167 changed the meaning of that test by removing the use of the
interrupt packet. I did not notice this because the interrupting
happened in a shared utility function.

This patch restores the original meaning of the test, but (almost)
avoids sleeps by using process stdout to synchronize. Sadly, this means
the test stays disabled on windows, as it does not implement output
forwarding.

Added: 
    

Modified: 
    lldb/test/API/tools/lldb-server/TestGdbRemote_qThreadStopInfo.py

Removed: 
    


################################################################################
diff  --git a/lldb/test/API/tools/lldb-server/TestGdbRemote_qThreadStopInfo.py b/lldb/test/API/tools/lldb-server/TestGdbRemote_qThreadStopInfo.py
index e03756f240d0..8fe3f777205a 100644
--- a/lldb/test/API/tools/lldb-server/TestGdbRemote_qThreadStopInfo.py
+++ b/lldb/test/API/tools/lldb-server/TestGdbRemote_qThreadStopInfo.py
@@ -9,18 +9,7 @@ class TestGdbRemote_qThreadStopInfo(gdbremote_testcase.GdbRemoteTestCaseBase):
     mydir = TestBase.compute_mydir(__file__)
     THREAD_COUNT = 5
 
-    def gather_stop_replies_via_qThreadStopInfo(self, thread_count):
-        context, threads = self.launch_with_threads(thread_count)
-
-        # On Windows, there could be more threads spawned. For example, DebugBreakProcess will
-        # create a new thread from the debugged process to handle an exception event. So here we
-        # assert 'GreaterEqual' condition.
-        triple = self.dbg.GetSelectedPlatform().GetTriple()
-        if re.match(".*-.*-windows", triple):
-            self.assertGreaterEqual(len(threads), thread_count)
-        else:
-            self.assertEqual(len(threads), thread_count)
-
+    def gather_stop_replies_via_qThreadStopInfo(self, threads):
         # Grab stop reply for each thread via qThreadStopInfo{tid:hex}.
         stop_replies = {}
         thread_dicts = {}
@@ -62,13 +51,14 @@ def gather_stop_replies_via_qThreadStopInfo(self, thread_count):
             # Hang on to the key-val dictionary for the thread.
             thread_dicts[kv_thread_id] = kv_dict
 
-        return (stop_replies, thread_dicts)
+        return stop_replies
 
     @skipIfNetBSD
     def test_qThreadStopInfo_works_for_multiple_threads(self):
         self.build()
         self.set_inferior_startup_launch()
-        (stop_replies, _) = self.gather_stop_replies_via_qThreadStopInfo(self.THREAD_COUNT)
+        _, threads = self.launch_with_threads(self.THREAD_COUNT)
+        stop_replies = self.gather_stop_replies_via_qThreadStopInfo(threads)
         triple = self.dbg.GetSelectedPlatform().GetTriple()
         # Consider one more thread created by calling DebugBreakProcess.
         if re.match(".*-.*-windows", triple):
@@ -78,12 +68,25 @@ def test_qThreadStopInfo_works_for_multiple_threads(self):
 
     @expectedFailureAll(oslist=["freebsd"], bugnumber="llvm.org/pr48418")
     @expectedFailureNetBSD
-    @expectedFailureAll(oslist=["windows"])
+    @expectedFailureAll(oslist=["windows"]) # Output forwarding not implemented
     def test_qThreadStopInfo_only_reports_one_thread_stop_reason_during_interrupt(self):
         self.build()
         self.set_inferior_startup_launch()
-
-        (stop_replies, _) = self.gather_stop_replies_via_qThreadStopInfo(self.THREAD_COUNT)
+        procs = self.prep_debug_monitor_and_inferior(
+                inferior_args=["thread:new"]*4 + ["stop-me-now", "sleep:60"])
+
+        self.test_sequence.add_log_lines([
+                "read packet: $c#00",
+                {"type": "output_match",
+                    "regex": self.maybe_strict_output_regex(r"stop-me-now\r\n")},
+                "read packet: \x03",
+                {"direction": "send",
+                    "regex": r"^\$T([0-9a-fA-F]{2})([^#]*)#..$"}], True)
+        self.add_threadinfo_collection_packets()
+        context = self.expect_gdbremote_sequence()
+        threads = self.parse_threadinfo_packets(context)
+
+        stop_replies = self.gather_stop_replies_via_qThreadStopInfo(threads)
         self.assertIsNotNone(stop_replies)
 
         no_stop_reason_count = sum(


        


More information about the lldb-commits mailing list