Differential D61687 Diff 200160 packages/Python/lldbsuite/test/tools/lldb-server/TestGdbRemote_qThreadStopInfo.py
Changeset View
Changeset View
Standalone View
Standalone View
packages/Python/lldbsuite/test/tools/lldb-server/TestGdbRemote_qThreadStopInfo.py
Show First 20 Lines • Show All 49 Lines • ▼ Show 20 Lines | def gather_stop_replies_via_qThreadStopInfo(self, thread_count): | ||||
], | ], | ||||
True) | True) | ||||
context = self.expect_gdbremote_sequence() | context = self.expect_gdbremote_sequence() | ||||
self.assertIsNotNone(context) | self.assertIsNotNone(context) | ||||
# Wait until all threads have started. | # Wait until all threads have started. | ||||
threads = self.wait_for_thread_count(thread_count, timeout_seconds=3) | threads = self.wait_for_thread_count(thread_count, timeout_seconds=3) | ||||
self.assertIsNotNone(threads) | self.assertIsNotNone(threads) | ||||
# On Windows there can be additional 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. | |||||
clayborg: Will this always be "thread_count+1" for window? Or can there be more threads.
This leads to a… | |||||
triple = self.dbg.GetSelectedPlatform().GetTriple() | |||||
if re.match(".*-.*-windows", triple): | |||||
self.assertGreaterEqual(len(threads), thread_count) | |||||
else: | |||||
self.assertEqual(len(threads), thread_count) | self.assertEqual(len(threads), thread_count) | ||||
# Grab stop reply for each thread via qThreadStopInfo{tid:hex}. | # Grab stop reply for each thread via qThreadStopInfo{tid:hex}. | ||||
stop_replies = {} | stop_replies = {} | ||||
thread_dicts = {} | thread_dicts = {} | ||||
for thread in threads: | for thread in threads: | ||||
# Run the qThreadStopInfo command. | # Run the qThreadStopInfo command. | ||||
self.reset_test_sequence() | self.reset_test_sequence() | ||||
self.test_sequence.add_log_lines( | self.test_sequence.add_log_lines( | ||||
Show All 30 Lines | def gather_stop_replies_via_qThreadStopInfo(self, thread_count): | ||||
# Hang on to the key-val dictionary for the thread. | # Hang on to the key-val dictionary for the thread. | ||||
thread_dicts[kv_thread_id] = kv_dict | thread_dicts[kv_thread_id] = kv_dict | ||||
return (stop_replies, thread_dicts) | return (stop_replies, thread_dicts) | ||||
def qThreadStopInfo_works_for_multiple_threads(self, thread_count): | def qThreadStopInfo_works_for_multiple_threads(self, thread_count): | ||||
(stop_replies, _) = self.gather_stop_replies_via_qThreadStopInfo(thread_count) | (stop_replies, _) = self.gather_stop_replies_via_qThreadStopInfo(thread_count) | ||||
triple = self.dbg.GetSelectedPlatform().GetTriple() | |||||
# Consider one more thread created by calling DebugBreakProcess. | |||||
if re.match(".*-.*-windows", triple): | |||||
self.assertGreaterEqual(len(stop_replies), thread_count) | |||||
else: | |||||
self.assertEqual(len(stop_replies), thread_count) | self.assertEqual(len(stop_replies), thread_count) | ||||
@debugserver_test | @debugserver_test | ||||
def test_qThreadStopInfo_works_for_multiple_threads_debugserver(self): | def test_qThreadStopInfo_works_for_multiple_threads_debugserver(self): | ||||
self.init_debugserver_test() | self.init_debugserver_test() | ||||
self.build() | self.build() | ||||
self.set_inferior_startup_launch() | self.set_inferior_startup_launch() | ||||
self.qThreadStopInfo_works_for_multiple_threads(self.THREAD_COUNT) | self.qThreadStopInfo_works_for_multiple_threads(self.THREAD_COUNT) | ||||
Show All 11 Lines | def qThreadStopInfo_only_reports_one_thread_stop_reason_during_interrupt( | ||||
no_stop_reason_count = sum( | no_stop_reason_count = sum( | ||||
1 for stop_reason in list( | 1 for stop_reason in list( | ||||
stop_replies.values()) if stop_reason == 0) | stop_replies.values()) if stop_reason == 0) | ||||
with_stop_reason_count = sum( | with_stop_reason_count = sum( | ||||
1 for stop_reason in list( | 1 for stop_reason in list( | ||||
stop_replies.values()) if stop_reason != 0) | stop_replies.values()) if stop_reason != 0) | ||||
# All but one thread should report no stop reason. | # All but one thread should report no stop reason. | ||||
triple = self.dbg.GetSelectedPlatform().GetTriple() | |||||
# Consider one more thread created by calling DebugBreakProcess. | |||||
if re.match(".*-.*-windows", triple): | |||||
self.assertGreaterEqual(no_stop_reason_count, thread_count - 1) | |||||
else: | |||||
self.assertEqual(no_stop_reason_count, thread_count - 1) | self.assertEqual(no_stop_reason_count, thread_count - 1) | ||||
I think this assertion should just be deleted. If the assertion below (that one thread has a stop reason) is true, then it trivially true that the rest of the threads don't have one. Whether or not a platforms spawns an extra thread does not seem to be relevant for this test. labath: I think this assertion should just be deleted. If the assertion below (that one thread has a… | |||||
Not Done ReplyInline ActionsThis comment doesn't appear to be "done". labath: This comment doesn't appear to be "done". | |||||
# Only one thread should should indicate a stop reason. | # Only one thread should should indicate a stop reason. | ||||
self.assertEqual(with_stop_reason_count, 1) | self.assertEqual(with_stop_reason_count, 1) | ||||
@debugserver_test | @debugserver_test | ||||
def test_qThreadStopInfo_only_reports_one_thread_stop_reason_during_interrupt_debugserver( | def test_qThreadStopInfo_only_reports_one_thread_stop_reason_during_interrupt_debugserver( | ||||
self): | self): | ||||
self.init_debugserver_test() | self.init_debugserver_test() | ||||
self.build() | self.build() | ||||
Show All 24 Lines | class TestGdbRemote_qThreadStopInfo(gdbremote_testcase.GdbRemoteTestCaseBase): | ||||
@debugserver_test | @debugserver_test | ||||
def test_qThreadStopInfo_has_valid_thread_names_debugserver(self): | def test_qThreadStopInfo_has_valid_thread_names_debugserver(self): | ||||
self.init_debugserver_test() | self.init_debugserver_test() | ||||
self.build() | self.build() | ||||
self.set_inferior_startup_launch() | self.set_inferior_startup_launch() | ||||
self.qThreadStopInfo_has_valid_thread_names(self.THREAD_COUNT, "a.out") | self.qThreadStopInfo_has_valid_thread_names(self.THREAD_COUNT, "a.out") | ||||
# test requires OS with set, equal thread names by default. | # test requires OS with set, equal thread names by default. | ||||
@skipUnlessPlatform(["linux"]) | # Windows threads do not have a name property and use the process name by default. | ||||
@skipUnlessPlatform(["linux", "windows"]) | |||||
@llgs_test | @llgs_test | ||||
def test_qThreadStopInfo_has_valid_thread_names_llgs(self): | def test_qThreadStopInfo_has_valid_thread_names_llgs(self): | ||||
self.init_llgs_test() | self.init_llgs_test() | ||||
self.build() | self.build() | ||||
self.set_inferior_startup_launch() | self.set_inferior_startup_launch() | ||||
self.qThreadStopInfo_has_valid_thread_names(self.THREAD_COUNT, "a.out") | self.qThreadStopInfo_has_valid_thread_names(self.THREAD_COUNT, "a.out") |
Will this always be "thread_count+1" for window? Or can there be more threads.
This leads to a higher level question: Does the user ever want to see the "DebugBreakProcess" thread in the IDE? Should we just never report this thread from lldb-server and avoid these mismatch issues? We should be consistent with what other windows debuggers do (show DebugBreakProcess or not).