2011-12-13 04:04:44 +00:00
|
|
|
"""
|
|
|
|
Test that expr will time out and allow other threads to run if it blocks.
|
|
|
|
"""
|
|
|
|
|
2015-10-23 17:04:29 +00:00
|
|
|
from __future__ import print_function
|
|
|
|
|
2015-11-03 19:20:39 +00:00
|
|
|
|
2016-09-06 20:57:50 +00:00
|
|
|
import os
|
|
|
|
import time
|
2011-12-13 04:04:44 +00:00
|
|
|
import re
|
2015-11-03 02:06:18 +00:00
|
|
|
import lldb
|
2016-02-04 23:04:17 +00:00
|
|
|
from lldbsuite.test.decorators import *
|
2015-11-03 02:06:18 +00:00
|
|
|
from lldbsuite.test.lldbtest import *
|
2016-02-04 23:04:17 +00:00
|
|
|
from lldbsuite.test import lldbutil
|
2011-12-13 04:04:44 +00:00
|
|
|
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2011-12-13 04:04:44 +00:00
|
|
|
class ExprDoesntDeadlockTestCase(TestBase):
|
|
|
|
|
2013-02-26 22:51:48 +00:00
|
|
|
def getCategories(self):
|
|
|
|
return ['basic_process']
|
|
|
|
|
2013-12-10 23:19:29 +00:00
|
|
|
mydir = TestBase.compute_mydir(__file__)
|
2011-12-13 04:04:44 +00:00
|
|
|
|
2016-02-19 19:25:03 +00:00
|
|
|
@expectedFailureAll(oslist=['freebsd'], bugnumber='llvm.org/pr17946')
|
2016-09-06 20:57:50 +00:00
|
|
|
@expectedFailureAll(
|
|
|
|
oslist=["windows"],
|
|
|
|
bugnumber="Windows doesn't have pthreads, test needs to be ported")
|
2015-09-30 10:12:40 +00:00
|
|
|
def test_with_run_command(self):
|
2011-12-13 04:04:44 +00:00
|
|
|
"""Test that expr will time out and allow other threads to run if it blocks."""
|
2015-09-30 10:12:40 +00:00
|
|
|
self.build()
|
2011-12-13 04:04:44 +00:00
|
|
|
exe = os.path.join(os.getcwd(), "a.out")
|
|
|
|
|
|
|
|
# Create a target by the debugger.
|
|
|
|
target = self.dbg.CreateTarget(exe)
|
|
|
|
self.assertTrue(target, VALID_TARGET)
|
|
|
|
|
2016-09-06 20:57:50 +00:00
|
|
|
# Now create a breakpoint at source line before call_me_to_get_lock
|
|
|
|
# gets called.
|
2011-12-13 04:04:44 +00:00
|
|
|
|
2016-09-06 20:57:50 +00:00
|
|
|
main_file_spec = lldb.SBFileSpec("locking.c")
|
|
|
|
breakpoint = target.BreakpointCreateBySourceRegex(
|
|
|
|
'Break here', main_file_spec)
|
2011-12-14 01:36:04 +00:00
|
|
|
if self.TraceOn():
|
2015-10-23 17:04:29 +00:00
|
|
|
print("breakpoint:", breakpoint)
|
2011-12-13 04:04:44 +00:00
|
|
|
self.assertTrue(breakpoint and
|
|
|
|
breakpoint.GetNumLocations() == 1,
|
|
|
|
VALID_BREAKPOINT)
|
|
|
|
|
|
|
|
# Now launch the process, and do not stop at entry point.
|
2016-09-06 20:57:50 +00:00
|
|
|
process = target.LaunchSimple(
|
|
|
|
None, None, self.get_process_working_directory())
|
2011-12-13 04:04:44 +00:00
|
|
|
self.assertTrue(process, PROCESS_IS_VALID)
|
|
|
|
|
|
|
|
# Frame #0 should be on self.line1 and the break condition should hold.
|
2015-11-03 02:06:18 +00:00
|
|
|
from lldbsuite.test.lldbutil import get_stopped_thread
|
2011-12-13 04:04:44 +00:00
|
|
|
thread = get_stopped_thread(process, lldb.eStopReasonBreakpoint)
|
2016-09-06 20:57:50 +00:00
|
|
|
self.assertTrue(
|
|
|
|
thread.IsValid(),
|
|
|
|
"There should be a thread stopped due to breakpoint condition")
|
2011-12-13 04:04:44 +00:00
|
|
|
|
|
|
|
frame0 = thread.GetFrameAtIndex(0)
|
|
|
|
|
2016-09-06 20:57:50 +00:00
|
|
|
var = frame0.EvaluateExpression("call_me_to_get_lock()")
|
|
|
|
self.assertTrue(var.IsValid())
|
|
|
|
self.assertTrue(var.GetValueAsSigned(0) == 567)
|