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