Skip to content

Commit 29caa85

Browse files
committed
[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.
1 parent 4883145 commit 29caa85

File tree

1 file changed

+20
-17
lines changed

1 file changed

+20
-17
lines changed

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

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,7 @@ class TestGdbRemote_qThreadStopInfo(gdbremote_testcase.GdbRemoteTestCaseBase):
99
mydir = TestBase.compute_mydir(__file__)
1010
THREAD_COUNT = 5
1111

12-
def gather_stop_replies_via_qThreadStopInfo(self, thread_count):
13-
context, threads = self.launch_with_threads(thread_count)
14-
15-
# On Windows, there could be more threads spawned. For example, DebugBreakProcess will
16-
# create a new thread from the debugged process to handle an exception event. So here we
17-
# assert 'GreaterEqual' condition.
18-
triple = self.dbg.GetSelectedPlatform().GetTriple()
19-
if re.match(".*-.*-windows", triple):
20-
self.assertGreaterEqual(len(threads), thread_count)
21-
else:
22-
self.assertEqual(len(threads), thread_count)
23-
12+
def gather_stop_replies_via_qThreadStopInfo(self, threads):
2413
# Grab stop reply for each thread via qThreadStopInfo{tid:hex}.
2514
stop_replies = {}
2615
thread_dicts = {}
@@ -62,13 +51,14 @@ def gather_stop_replies_via_qThreadStopInfo(self, thread_count):
6251
# Hang on to the key-val dictionary for the thread.
6352
thread_dicts[kv_thread_id] = kv_dict
6453

65-
return (stop_replies, thread_dicts)
54+
return stop_replies
6655

6756
@skipIfNetBSD
6857
def test_qThreadStopInfo_works_for_multiple_threads(self):
6958
self.build()
7059
self.set_inferior_startup_launch()
71-
(stop_replies, _) = self.gather_stop_replies_via_qThreadStopInfo(self.THREAD_COUNT)
60+
_, threads = self.launch_with_threads(self.THREAD_COUNT)
61+
stop_replies = self.gather_stop_replies_via_qThreadStopInfo(threads)
7262
triple = self.dbg.GetSelectedPlatform().GetTriple()
7363
# Consider one more thread created by calling DebugBreakProcess.
7464
if re.match(".*-.*-windows", triple):
@@ -78,12 +68,25 @@ def test_qThreadStopInfo_works_for_multiple_threads(self):
7868

7969
@expectedFailureAll(oslist=["freebsd"], bugnumber="llvm.org/pr48418")
8070
@expectedFailureNetBSD
81-
@expectedFailureAll(oslist=["windows"])
71+
@expectedFailureAll(oslist=["windows"]) # Output forwarding not implemented
8272
def test_qThreadStopInfo_only_reports_one_thread_stop_reason_during_interrupt(self):
8373
self.build()
8474
self.set_inferior_startup_launch()
85-
86-
(stop_replies, _) = self.gather_stop_replies_via_qThreadStopInfo(self.THREAD_COUNT)
75+
procs = self.prep_debug_monitor_and_inferior(
76+
inferior_args=["thread:new"]*4 + ["stop-me-now", "sleep:60"])
77+
78+
self.test_sequence.add_log_lines([
79+
"read packet: $c#00",
80+
{"type": "output_match",
81+
"regex": self.maybe_strict_output_regex(r"stop-me-now\r\n")},
82+
"read packet: \x03",
83+
{"direction": "send",
84+
"regex": r"^\$T([0-9a-fA-F]{2})([^#]*)#..$"}], True)
85+
self.add_threadinfo_collection_packets()
86+
context = self.expect_gdbremote_sequence()
87+
threads = self.parse_threadinfo_packets(context)
88+
89+
stop_replies = self.gather_stop_replies_via_qThreadStopInfo(threads)
8790
self.assertIsNotNone(stop_replies)
8891

8992
no_stop_reason_count = sum(

0 commit comments

Comments
 (0)