2 Test that we obey thread conditioned breakpoints and expression
3 conditioned breakpoints simultaneously
6 from __future__ import print_function
13 from lldbsuite.test.decorators import *
14 from lldbsuite.test.lldbtest import *
15 from lldbsuite.test import lldbutil
18 class ThreadSpecificBreakPlusConditionTestCase(TestBase):
20 mydir = TestBase.compute_mydir(__file__)
22 # test frequently times out or hangs
23 @skipIf(oslist=['windows', 'freebsd'])
25 # hits break in another thread in testrun
26 @expectedFailureAll(oslist=['freebsd'], bugnumber='llvm.org/pr18522')
27 @add_test_categories(['pyapi'])
28 @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.
29 def test_python(self):
30 """Test that we obey thread conditioned breakpoints."""
32 exe = self.getBuildArtifact("a.out")
34 target = self.dbg.CreateTarget(exe)
35 self.assertTrue(target, VALID_TARGET)
37 main_source_spec = lldb.SBFileSpec("main.cpp")
39 # Set a breakpoint in the thread body, and make it active for only the
41 break_thread_body = target.BreakpointCreateBySourceRegex(
42 "Break here in thread body.", main_source_spec)
44 break_thread_body.IsValid() and break_thread_body.GetNumLocations() > 0,
45 "Failed to set thread body breakpoint.")
47 process = target.LaunchSimple(
48 None, None, self.get_process_working_directory())
50 self.assertTrue(process, PROCESS_IS_VALID)
52 threads = lldbutil.get_threads_stopped_at_breakpoint(
53 process, break_thread_body)
55 victim_thread = threads[0]
57 # Pick one of the threads, and change the breakpoint so it ONLY stops for this thread,
58 # but add a condition that it won't stop for this thread's my_value. The other threads
59 # pass the condition, so they should stop, but if the thread-specification is working
60 # they should not stop. So nobody should hit the breakpoint anymore, and we should
63 frame = victim_thread.GetFrameAtIndex(0)
64 value = frame.FindVariable("my_value").GetValueAsSigned(0)
66 value > 0 and value < 11,
67 "Got a reasonable value for my_value.")
69 cond_string = "my_value != %d" % (value)
71 break_thread_body.SetThreadID(victim_thread.GetThreadID())
72 break_thread_body.SetCondition(cond_string)
76 next_stop_state = process.GetState()
78 next_stop_state == lldb.eStateExited,
79 "We should have not hit the breakpoint again.")