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