2 Test number of threads.
8 from lldbsuite.test.decorators import *
9 from lldbsuite.test.lldbtest import *
10 from lldbsuite.test import lldbutil
13 class BreakpointAfterJoinTestCase(TestBase):
15 mydir = TestBase.compute_mydir(__file__)
18 # Call super's setUp().
20 # Find the line number for our breakpoint.
21 self.breakpoint = line_number('main.cpp', '// Set breakpoint here')
25 bugnumber="llvm.org/pr15824 thread states not properly maintained")
27 oslist=lldbplatformutil.getDarwinOSTriples(),
28 bugnumber="llvm.org/pr15824 thread states not properly maintained and <rdar://problem/28557237>")
31 bugnumber="llvm.org/pr18190 thread states not properly maintained")
32 @expectedFailureNetBSD
34 """Test breakpoint handling after a thread join."""
35 self.build(dictionary=self.getBuildFlags())
37 exe = self.getBuildArtifact("a.out")
38 self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
40 # This should create a breakpoint in the main thread.
41 lldbutil.run_break_set_by_file_and_line(
42 self, "main.cpp", self.breakpoint, num_expected_locations=1)
44 # The breakpoint list should show 1 location.
47 "Breakpoint location shown correctly",
49 "1: file = 'main.cpp', line = %d, exact_match = 0, locations = 1" %
53 self.runCmd("run", RUN_SUCCEEDED)
55 # The stop reason of the thread should be breakpoint.
56 self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
58 'stop reason = breakpoint'])
60 # Get the target process
61 target = self.dbg.GetSelectedTarget()
62 process = target.GetProcess()
64 # The exit probably occurred during breakpoint handling, but it isn't
65 # guaranteed. The main thing we're testing here is that the debugger
66 # handles this cleanly is some way.
68 # Get the number of threads
69 num_threads = process.GetNumThreads()
71 # Make sure we see at least six threads
74 'Number of expected threads and actual threads do not match.')
76 # Make sure all threads are stopped
77 for i in range(0, num_threads):
79 process.GetThreadAtIndex(i).IsStopped(),
80 "Thread {0} didn't stop during breakpoint.".format(i))
83 self.runCmd("continue")
85 # If the process hasn't exited, collect some information
86 if process.GetState() != lldb.eStateExited:
87 self.runCmd("thread list")
88 self.runCmd("process status")
90 # At this point, the inferior process should have exited.
92 process.GetState() == lldb.eStateExited,