126ad9e97ee5d22b727aea2a17656e6b49076cb3
[openbsd] /
1 """
2 Test that we obey thread conditioned breakpoints and expression
3 conditioned breakpoints simultaneously
4 """
5
6
7
8 import lldb
9 from lldbsuite.test.decorators import *
10 from lldbsuite.test.lldbtest import *
11 from lldbsuite.test import lldbutil
12
13
14 class ThreadSpecificBreakPlusConditionTestCase(TestBase):
15
16     mydir = TestBase.compute_mydir(__file__)
17
18     # test frequently times out or hangs
19     @skipIf(oslist=['windows', 'freebsd'])
20     @skipIfDarwin
21     # hits break in another thread in testrun
22     @expectedFailureAll(oslist=['freebsd'], bugnumber='llvm.org/pr18522')
23     @add_test_categories(['pyapi'])
24     @expectedFailureAll(oslist=['ios', 'watchos', 'tvos', 'bridgeos'], archs=['armv7', 'armv7k'], bugnumber='rdar://problem/34563348') # Two threads seem to end up with the same my_value when built for armv7.
25     @expectedFailureNetBSD
26     def test_python(self):
27         """Test that we obey thread conditioned breakpoints."""
28         self.build()
29         exe = self.getBuildArtifact("a.out")
30
31         target = self.dbg.CreateTarget(exe)
32         self.assertTrue(target, VALID_TARGET)
33
34         main_source_spec = lldb.SBFileSpec("main.cpp")
35
36         # Set a breakpoint in the thread body, and make it active for only the
37         # first thread.
38         break_thread_body = target.BreakpointCreateBySourceRegex(
39             "Break here in thread body.", main_source_spec)
40         self.assertTrue(
41             break_thread_body.IsValid() and break_thread_body.GetNumLocations() > 0,
42             "Failed to set thread body breakpoint.")
43
44         process = target.LaunchSimple(
45             None, None, self.get_process_working_directory())
46
47         self.assertTrue(process, PROCESS_IS_VALID)
48
49         threads = lldbutil.get_threads_stopped_at_breakpoint(
50             process, break_thread_body)
51
52         victim_thread = threads[0]
53
54         # Pick one of the threads, and change the breakpoint so it ONLY stops for this thread,
55         # but add a condition that it won't stop for this thread's my_value.  The other threads
56         # pass the condition, so they should stop, but if the thread-specification is working
57         # they should not stop.  So nobody should hit the breakpoint anymore, and we should
58         # just exit cleanly.
59
60         frame = victim_thread.GetFrameAtIndex(0)
61         value = frame.FindVariable("my_value").GetValueAsSigned(0)
62         self.assertTrue(
63             value > 0 and value < 11,
64             "Got a reasonable value for my_value.")
65
66         cond_string = "my_value != %d" % (value)
67
68         break_thread_body.SetThreadID(victim_thread.GetThreadID())
69         break_thread_body.SetCondition(cond_string)
70
71         process.Continue()
72
73         next_stop_state = process.GetState()
74         self.assertTrue(
75             next_stop_state == lldb.eStateExited,
76             "We should have not hit the breakpoint again.")