[AMDGPU] Add commute for some VOP3 inst (#121326)
[llvm-project.git] / lldb / test / API / macosx / safe-to-func-call / TestSafeFuncCalls.py
blob551cab1269c51facf14f7aa06c34f508d721386b
1 """Test function call thread safety."""
4 import lldb
5 from lldbsuite.test.decorators import *
6 from lldbsuite.test.lldbtest import *
7 from lldbsuite.test import lldbutil
10 class TestSafeFuncCalls(TestBase):
11 @skipUnlessDarwin
12 @add_test_categories(["pyapi"])
13 def test_with_python_api(self):
14 """Test function call thread safety."""
15 self.build()
16 exe = self.getBuildArtifact("a.out")
18 target = self.dbg.CreateTarget(exe)
19 self.assertTrue(target, VALID_TARGET)
20 self.main_source_spec = lldb.SBFileSpec("main.c")
21 break1 = target.BreakpointCreateByName("stopper", "a.out")
22 self.assertTrue(break1, VALID_BREAKPOINT)
23 process = target.LaunchSimple(None, None, self.get_process_working_directory())
24 self.assertTrue(process, PROCESS_IS_VALID)
25 threads = lldbutil.get_threads_stopped_at_breakpoint(process, break1)
26 self.assertEqual(len(threads), 1, "Failed to stop at breakpoint 1.")
28 self.assertEqual(
29 process.GetNumThreads(),
31 "Check that the process has two threads when sitting at the stopper() breakpoint",
34 main_thread = lldb.SBThread()
35 select_thread = lldb.SBThread()
36 for idx in range(0, process.GetNumThreads()):
37 t = process.GetThreadAtIndex(idx)
38 if t.GetName() == "main thread":
39 main_thread = t
40 if t.GetName() == "select thread":
41 select_thread = t
43 self.assertTrue(
44 main_thread.IsValid() and select_thread.IsValid(),
45 "Got both expected threads",
48 self.assertTrue(
49 main_thread.SafeToCallFunctions(),
50 "It is safe to call functions on the main thread",
52 self.assertFalse(
53 select_thread.SafeToCallFunctions(),
54 "It is not safe to call functions on the select thread",