]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - packages/Python/lldbsuite/test/functionalities/expr-doesnt-deadlock/TestExprDoesntBlock.py
Vendor import of lldb trunk r290819:
[FreeBSD/FreeBSD.git] / packages / Python / lldbsuite / test / functionalities / expr-doesnt-deadlock / TestExprDoesntBlock.py
1 """
2 Test that expr will time out and allow other threads to run if it blocks.
3 """
4
5 from __future__ import print_function
6
7
8 import os
9 import time
10 import re
11 import lldb
12 from lldbsuite.test.decorators import *
13 from lldbsuite.test.lldbtest import *
14 from lldbsuite.test import lldbutil
15
16
17 class ExprDoesntDeadlockTestCase(TestBase):
18
19     def getCategories(self):
20         return ['basic_process']
21
22     mydir = TestBase.compute_mydir(__file__)
23
24     @expectedFailureAll(oslist=['freebsd'], bugnumber='llvm.org/pr17946')
25     @expectedFailureAll(
26         oslist=["windows"],
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."""
30         self.build()
31         exe = os.path.join(os.getcwd(), "a.out")
32
33         # Create a target by the debugger.
34         target = self.dbg.CreateTarget(exe)
35         self.assertTrue(target, VALID_TARGET)
36
37         # Now create a breakpoint at source line before call_me_to_get_lock
38         # gets called.
39
40         main_file_spec = lldb.SBFileSpec("locking.c")
41         breakpoint = target.BreakpointCreateBySourceRegex(
42             'Break here', main_file_spec)
43         if self.TraceOn():
44             print("breakpoint:", breakpoint)
45         self.assertTrue(breakpoint and
46                         breakpoint.GetNumLocations() == 1,
47                         VALID_BREAKPOINT)
48
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)
53
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)
57         self.assertTrue(
58             thread.IsValid(),
59             "There should be a thread stopped due to breakpoint condition")
60
61         frame0 = thread.GetFrameAtIndex(0)
62
63         var = frame0.EvaluateExpression("call_me_to_get_lock()")
64         self.assertTrue(var.IsValid())
65         self.assertTrue(var.GetValueAsSigned(0) == 567)