2 Test that expr will time out and allow other threads to run if it blocks.
5 from __future__ import print_function
12 from lldbsuite.test.decorators import *
13 from lldbsuite.test.lldbtest import *
14 from lldbsuite.test import lldbutil
17 class ExprDoesntDeadlockTestCase(TestBase):
19 def getCategories(self):
20 return ['basic_process']
22 mydir = TestBase.compute_mydir(__file__)
24 @expectedFailureAll(oslist=['freebsd'], bugnumber='llvm.org/pr17946')
27 bugnumber="Windows doesn't have pthreads, test needs to be ported")
28 def test_with_run_command(self):
29 """Test that expr will time out and allow other threads to run if it blocks."""
31 exe = os.path.join(os.getcwd(), "a.out")
33 # Create a target by the debugger.
34 target = self.dbg.CreateTarget(exe)
35 self.assertTrue(target, VALID_TARGET)
37 # Now create a breakpoint at source line before call_me_to_get_lock
40 main_file_spec = lldb.SBFileSpec("locking.c")
41 breakpoint = target.BreakpointCreateBySourceRegex(
42 'Break here', main_file_spec)
44 print("breakpoint:", breakpoint)
45 self.assertTrue(breakpoint and
46 breakpoint.GetNumLocations() == 1,
49 # Now launch the process, and do not stop at entry point.
50 process = target.LaunchSimple(
51 None, None, self.get_process_working_directory())
52 self.assertTrue(process, PROCESS_IS_VALID)
54 # Frame #0 should be on self.line1 and the break condition should hold.
55 from lldbsuite.test.lldbutil import get_stopped_thread
56 thread = get_stopped_thread(process, lldb.eStopReasonBreakpoint)
59 "There should be a thread stopped due to breakpoint condition")
61 frame0 = thread.GetFrameAtIndex(0)
63 var = frame0.EvaluateExpression("call_me_to_get_lock()")
64 self.assertTrue(var.IsValid())
65 self.assertTrue(var.GetValueAsSigned(0) == 567)