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 CreateDuringStepTestCase(TestBase):
15 mydir = TestBase.compute_mydir(__file__)
19 bugnumber="llvm.org/pr15824 thread states not properly maintained")
21 oslist=lldbplatformutil.getDarwinOSTriples(),
22 bugnumber="llvm.org/pr15824 thread states not properly maintained, <rdar://problem/28557237>")
25 bugnumber="llvm.org/pr18190 thread states not properly maintained")
28 bugnumber="llvm.org/pr24668: Breakpoints not resolved correctly")
29 @expectedFailureNetBSD
30 def test_step_inst(self):
31 """Test thread creation during step-inst handling."""
32 self.build(dictionary=self.getBuildFlags())
33 self.create_during_step_base(
34 "thread step-inst -m all-threads",
35 'stop reason = instruction step')
39 bugnumber="llvm.org/pr15824 thread states not properly maintained")
41 oslist=lldbplatformutil.getDarwinOSTriples(),
42 bugnumber="llvm.org/pr15824 thread states not properly maintained, <rdar://problem/28557237>")
45 bugnumber="llvm.org/pr18190 thread states not properly maintained")
48 bugnumber="llvm.org/pr24668: Breakpoints not resolved correctly")
49 @expectedFailureNetBSD
50 def test_step_over(self):
51 """Test thread creation during step-over handling."""
52 self.build(dictionary=self.getBuildFlags())
53 self.create_during_step_base(
54 "thread step-over -m all-threads",
55 'stop reason = step over')
59 bugnumber="llvm.org/pr15824 thread states not properly maintained")
61 oslist=lldbplatformutil.getDarwinOSTriples(),
62 bugnumber="<rdar://problem/28574077>")
65 bugnumber="llvm.org/pr18190 thread states not properly maintained")
68 bugnumber="llvm.org/pr24668: Breakpoints not resolved correctly")
69 @expectedFailureNetBSD
70 def test_step_in(self):
71 """Test thread creation during step-in handling."""
72 self.build(dictionary=self.getBuildFlags())
73 self.create_during_step_base(
74 "thread step-in -m all-threads",
75 'stop reason = step in')
78 # Call super's setUp().
80 # Find the line numbers to break and continue.
81 self.breakpoint = line_number('main.cpp', '// Set breakpoint here')
82 self.continuepoint = line_number('main.cpp', '// Continue from here')
84 def create_during_step_base(self, step_cmd, step_stop_reason):
85 """Test thread creation while using step-in."""
86 exe = self.getBuildArtifact("a.out")
87 self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
89 # Get the target process
90 target = self.dbg.GetSelectedTarget()
92 # This should create a breakpoint in the stepping thread.
93 self.bkpt = target.BreakpointCreateByLocation("main.cpp", self.breakpoint)
96 self.runCmd("run", RUN_SUCCEEDED)
98 process = target.GetProcess()
100 # The stop reason of the thread should be breakpoint.
101 stepping_thread = lldbutil.get_one_thread_stopped_at_breakpoint(process, self.bkpt)
102 self.assertTrue(stepping_thread.IsValid(), "We stopped at the right breakpoint")
104 # Get the number of threads
105 num_threads = process.GetNumThreads()
107 # Make sure we see only two threads
110 'Number of expected threads and actual threads do not match.')
112 # Get the thread objects
113 thread1 = process.GetThreadAtIndex(0)
114 thread2 = process.GetThreadAtIndex(1)
116 current_line = self.breakpoint
117 # Keep stepping until we've reached our designated continue point
118 while current_line != self.continuepoint:
119 if stepping_thread != process.GetSelectedThread():
120 process.SetSelectedThread(stepping_thread)
122 self.runCmd(step_cmd)
124 frame = stepping_thread.GetFrameAtIndex(0)
125 current_line = frame.GetLineEntry().GetLine()
127 # Make sure we're still where we thought we were
129 current_line >= self.breakpoint,
130 "Stepped to unexpected line, " +
133 current_line <= self.continuepoint,
134 "Stepped to unexpected line, " +
137 # Update the number of threads
138 num_threads = process.GetNumThreads()
140 # Check to see that we increased the number of threads as expected
143 'Number of expected threads and actual threads do not match after thread exit.')
145 stop_reason = stepping_thread.GetStopReason()
146 self.assertEqual(stop_reason, lldb.eStopReasonPlanComplete, "Stopped for plan completion")
149 self.runCmd("process continue")
151 # At this point, the inferior process should have exited.
153 process.GetState() == lldb.eStateExited,