]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - packages/Python/lldbsuite/test/functionalities/thread/thread_specific_break_plus_condition/TestThreadSpecificBpPlusCondition.py
Vendor import of lldb trunk r338150:
[FreeBSD/FreeBSD.git] / packages / Python / lldbsuite / test / functionalities / thread / thread_specific_break_plus_condition / TestThreadSpecificBpPlusCondition.py
1 """
2 Test that we obey thread conditioned breakpoints and expression
3 conditioned breakpoints simultaneously
4 """
5
6 from __future__ import print_function
7
8
9 import os
10 import time
11 import re
12 import lldb
13 from lldbsuite.test.decorators import *
14 from lldbsuite.test.lldbtest import *
15 from lldbsuite.test import lldbutil
16
17
18 class ThreadSpecificBreakPlusConditionTestCase(TestBase):
19
20     mydir = TestBase.compute_mydir(__file__)
21
22     # test frequently times out or hangs
23     @skipIf(oslist=['windows', 'freebsd'])
24     @skipIfDarwin
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."""
31         self.build()
32         exe = self.getBuildArtifact("a.out")
33
34         target = self.dbg.CreateTarget(exe)
35         self.assertTrue(target, VALID_TARGET)
36
37         main_source_spec = lldb.SBFileSpec("main.cpp")
38
39         # Set a breakpoint in the thread body, and make it active for only the
40         # first thread.
41         break_thread_body = target.BreakpointCreateBySourceRegex(
42             "Break here in thread body.", main_source_spec)
43         self.assertTrue(
44             break_thread_body.IsValid() and break_thread_body.GetNumLocations() > 0,
45             "Failed to set thread body breakpoint.")
46
47         process = target.LaunchSimple(
48             None, None, self.get_process_working_directory())
49
50         self.assertTrue(process, PROCESS_IS_VALID)
51
52         threads = lldbutil.get_threads_stopped_at_breakpoint(
53             process, break_thread_body)
54
55         victim_thread = threads[0]
56
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
61         # just exit cleanly.
62
63         frame = victim_thread.GetFrameAtIndex(0)
64         value = frame.FindVariable("my_value").GetValueAsSigned(0)
65         self.assertTrue(
66             value > 0 and value < 11,
67             "Got a reasonable value for my_value.")
68
69         cond_string = "my_value != %d" % (value)
70
71         break_thread_body.SetThreadID(victim_thread.GetThreadID())
72         break_thread_body.SetCondition(cond_string)
73
74         process.Continue()
75
76         next_stop_state = process.GetState()
77         self.assertTrue(
78             next_stop_state == lldb.eStateExited,
79             "We should have not hit the breakpoint again.")