1""" 2Test that expr will time out and allow other threads to run if it blocks. 3""" 4 5import lldb 6from lldbsuite.test.decorators import * 7from lldbsuite.test.lldbtest import * 8from lldbsuite.test import lldbutil 9 10 11class ExprDoesntDeadlockTestCase(TestBase): 12 @add_test_categories(["basic_process"]) 13 def test_with_run_command(self): 14 """Test that expr will time out and allow other threads to run if it blocks.""" 15 self.build() 16 target = self.createTestTarget() 17 18 # Now create a breakpoint at source line before call_me_to_get_lock 19 # gets called. 20 21 main_file_spec = lldb.SBFileSpec("locking.cpp") 22 breakpoint = target.BreakpointCreateBySourceRegex("Break here", main_file_spec) 23 if self.TraceOn(): 24 print("breakpoint:", breakpoint) 25 self.assertTrue( 26 breakpoint and breakpoint.GetNumLocations() == 1, VALID_BREAKPOINT 27 ) 28 29 # Now launch the process, and do not stop at entry point. 30 process = target.LaunchSimple(None, None, self.get_process_working_directory()) 31 self.assertTrue(process, PROCESS_IS_VALID) 32 33 # Frame #0 should be on self.line1 and the break condition should hold. 34 from lldbsuite.test.lldbutil import get_stopped_thread 35 36 thread = get_stopped_thread(process, lldb.eStopReasonBreakpoint) 37 self.assertTrue( 38 thread.IsValid(), 39 "There should be a thread stopped due to breakpoint condition", 40 ) 41 42 frame0 = thread.GetFrameAtIndex(0) 43 44 var = frame0.EvaluateExpression("call_me_to_get_lock(get_int())") 45 self.assertTrue(var.IsValid()) 46 self.assertEqual(var.GetValueAsSigned(0), 567) 47