2 Test number of threads.
5 from __future__ import print_function
11 from lldbsuite.test.lldbtest import *
12 import lldbsuite.test.lldbutil as lldbutil
14 class BreakpointAfterJoinTestCase(TestBase):
16 mydir = TestBase.compute_mydir(__file__)
19 # Call super's setUp().
21 # Find the line number for our breakpoint.
22 self.breakpoint = line_number('main.cpp', '// Set breakpoint here')
24 @expectedFailureDarwin("llvm.org/pr15824") # thread states not properly maintained
25 @expectedFailureFreeBSD("llvm.org/pr18190") # thread states not properly maintained
26 @expectedFailureLinux("llvm.org/pr15824") # thread states not properly maintained
28 """Test breakpoint handling after a thread join."""
29 self.build(dictionary=self.getBuildFlags())
31 exe = os.path.join(os.getcwd(), "a.out")
32 self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
34 # This should create a breakpoint in the main thread.
35 lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.breakpoint, num_expected_locations=1)
37 # The breakpoint list should show 1 location.
38 self.expect("breakpoint list -f", "Breakpoint location shown correctly",
39 substrs = ["1: file = 'main.cpp', line = %d, exact_match = 0, locations = 1" % self.breakpoint])
42 self.runCmd("run", RUN_SUCCEEDED)
44 # The stop reason of the thread should be breakpoint.
45 self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
47 'stop reason = breakpoint'])
49 # Get the target process
50 target = self.dbg.GetSelectedTarget()
51 process = target.GetProcess()
53 # The exit probably occurred during breakpoint handling, but it isn't
54 # guaranteed. The main thing we're testing here is that the debugger
55 # handles this cleanly is some way.
57 # Get the number of threads
58 num_threads = process.GetNumThreads()
60 # Make sure we see at least six threads
61 self.assertTrue(num_threads >= 6, 'Number of expected threads and actual threads do not match.')
63 # Make sure all threads are stopped
64 for i in range(0, num_threads):
65 self.assertTrue(process.GetThreadAtIndex(i).IsStopped(),
66 "Thread {0} didn't stop during breakpoint.".format(i))
69 self.runCmd("continue")
71 # If the process hasn't exited, collect some information
72 if process.GetState() != lldb.eStateExited:
73 self.runCmd("thread list")
74 self.runCmd("process status")
76 # At this point, the inferior process should have exited.
77 self.assertTrue(process.GetState() == lldb.eStateExited, PROCESS_EXITED)