2 Test number of threads.
5 from __future__ import print_function
11 from lldbsuite.test.decorators import *
12 from lldbsuite.test.lldbtest import *
13 from lldbsuite.test import lldbutil
16 class MultipleBreakpointTestCase(TestBase):
18 mydir = TestBase.compute_mydir(__file__)
21 # Call super's setUp().
23 # Find the line number for our breakpoint.
24 self.breakpoint = line_number('main.cpp', '// Set breakpoint here')
28 bugnumber="llvm.org/pr15824 thread states not properly maintained")
30 oslist=lldbplatformutil.getDarwinOSTriples(),
31 bugnumber="llvm.org/pr15824 thread states not properly maintained and <rdar://problem/28557237>")
34 bugnumber="llvm.org/pr18190 thread states not properly maintained")
37 bugnumber="llvm.org/pr24668: Breakpoints not resolved correctly")
39 """Test simultaneous breakpoints in multiple threads."""
40 self.build(dictionary=self.getBuildFlags())
41 exe = os.path.join(os.getcwd(), "a.out")
42 self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
44 # This should create a breakpoint in the main thread.
45 lldbutil.run_break_set_by_file_and_line(
46 self, "main.cpp", self.breakpoint, num_expected_locations=1)
49 self.runCmd("run", RUN_SUCCEEDED)
51 # The stop reason of the thread should be breakpoint.
52 # The breakpoint may be hit in either thread 2 or thread 3.
53 self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
55 'stop reason = breakpoint'])
57 # Get the target process
58 target = self.dbg.GetSelectedTarget()
59 process = target.GetProcess()
61 # Get the number of threads
62 num_threads = process.GetNumThreads()
64 # Make sure we see all three threads
67 'Number of expected threads and actual threads do not match.')
69 # Get the thread objects
70 thread1 = process.GetThreadAtIndex(0)
71 thread2 = process.GetThreadAtIndex(1)
72 thread3 = process.GetThreadAtIndex(2)
74 # Make sure both threads are stopped
77 "Primary thread didn't stop during breakpoint")
80 "Secondary thread didn't stop during breakpoint")
83 "Tertiary thread didn't stop during breakpoint")
85 # Delete the first breakpoint then continue
86 self.runCmd("breakpoint delete 1")
89 self.runCmd("continue")
91 # At this point, the inferior process should have exited.
93 process.GetState() == lldb.eStateExited,