2 Test that we obey thread conditioned breakpoints and expression
3 conditioned breakpoints simultaneously
9 from lldbsuite.test.decorators import *
10 from lldbsuite.test.lldbtest import *
11 from lldbsuite.test import lldbutil
14 class ThreadSpecificBreakPlusConditionTestCase(TestBase):
16 mydir = TestBase.compute_mydir(__file__)
18 # test frequently times out or hangs
19 @skipIf(oslist=['windows', 'freebsd'])
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."""
29 exe = self.getBuildArtifact("a.out")
31 target = self.dbg.CreateTarget(exe)
32 self.assertTrue(target, VALID_TARGET)
34 main_source_spec = lldb.SBFileSpec("main.cpp")
36 # Set a breakpoint in the thread body, and make it active for only the
38 break_thread_body = target.BreakpointCreateBySourceRegex(
39 "Break here in thread body.", main_source_spec)
41 break_thread_body.IsValid() and break_thread_body.GetNumLocations() > 0,
42 "Failed to set thread body breakpoint.")
44 process = target.LaunchSimple(
45 None, None, self.get_process_working_directory())
47 self.assertTrue(process, PROCESS_IS_VALID)
49 threads = lldbutil.get_threads_stopped_at_breakpoint(
50 process, break_thread_body)
52 victim_thread = threads[0]
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
60 frame = victim_thread.GetFrameAtIndex(0)
61 value = frame.FindVariable("my_value").GetValueAsSigned(0)
63 value > 0 and value < 11,
64 "Got a reasonable value for my_value.")
66 cond_string = "my_value != %d" % (value)
68 break_thread_body.SetThreadID(victim_thread.GetThreadID())
69 break_thread_body.SetCondition(cond_string)
73 next_stop_state = process.GetState()
75 next_stop_state == lldb.eStateExited,
76 "We should have not hit the breakpoint again.")