Zachary Turner | fbb79bb | 2015-09-02 16:47:01 +0000 | [diff] [blame] | 1 | """ |
Andrew Kaylor | dbbe36b | 2013-04-23 21:42:03 +0000 | [diff] [blame] | 2 | Test thread states. |
| 3 | """ |
| 4 | |
| 5 | import os, time |
| 6 | import unittest2 |
| 7 | import lldb |
| 8 | from lldbtest import * |
| 9 | import lldbutil |
| 10 | |
Andrew Kaylor | 93132f5 | 2013-05-28 23:04:25 +0000 | [diff] [blame] | 11 | class ThreadStateTestCase(TestBase): |
Andrew Kaylor | dbbe36b | 2013-04-23 21:42:03 +0000 | [diff] [blame] | 12 | |
Greg Clayton | 4570d3e | 2013-12-10 23:19:29 +0000 | [diff] [blame] | 13 | mydir = TestBase.compute_mydir(__file__) |
Andrew Kaylor | dbbe36b | 2013-04-23 21:42:03 +0000 | [diff] [blame] | 14 | |
Enrico Granata | 03e474b | 2013-11-01 00:57:53 +0000 | [diff] [blame] | 15 | @expectedFailureDarwin("rdar://15367566") |
Chaoren Lin | 72b8f05 | 2015-02-03 01:51:18 +0000 | [diff] [blame] | 16 | @expectedFailureFreeBSD('llvm.org/pr15824') |
Pavel Labath | b36f917 | 2015-06-24 14:43:20 +0000 | [diff] [blame] | 17 | @expectedFailureLinux("llvm.org/pr15824") # thread states not properly maintained |
Zachary Turner | 656ef0b | 2015-09-02 16:47:29 +0000 | [diff] [blame] | 18 | @expectedFailureWindows("llvm.org/pr24668") # Breakpoints not resolved correctly |
Tamas Berghammer | c8fd130 | 2015-09-30 10:12:40 +0000 | [diff] [blame^] | 19 | def test_state_after_breakpoint(self): |
Andrew Kaylor | 9f6c535 | 2013-04-30 23:39:14 +0000 | [diff] [blame] | 20 | """Test thread state after breakpoint.""" |
Tamas Berghammer | c8fd130 | 2015-09-30 10:12:40 +0000 | [diff] [blame^] | 21 | self.build(dictionary=self.getBuildFlags(use_cpp11=False)) |
Andrew Kaylor | 9f6c535 | 2013-04-30 23:39:14 +0000 | [diff] [blame] | 22 | self.thread_state_after_breakpoint_test() |
| 23 | |
Ying Chen | 1135e70 | 2015-05-28 21:03:26 +0000 | [diff] [blame] | 24 | @skipIfDarwin # 'llvm.org/pr23669', cause Python crash randomly |
| 25 | @expectedFailureDarwin('llvm.org/pr23669') |
Zachary Turner | fbb79bb | 2015-09-02 16:47:01 +0000 | [diff] [blame] | 26 | @expectedFailureWindows("llvm.org/pr24660") |
Tamas Berghammer | c8fd130 | 2015-09-30 10:12:40 +0000 | [diff] [blame^] | 27 | def test_state_after_continue(self): |
Andrew Kaylor | 9f6c535 | 2013-04-30 23:39:14 +0000 | [diff] [blame] | 28 | """Test thread state after continue.""" |
Tamas Berghammer | c8fd130 | 2015-09-30 10:12:40 +0000 | [diff] [blame^] | 29 | self.build(dictionary=self.getBuildFlags(use_cpp11=False)) |
Andrew Kaylor | 9f6c535 | 2013-04-30 23:39:14 +0000 | [diff] [blame] | 30 | self.thread_state_after_continue_test() |
| 31 | |
Ying Chen | 1135e70 | 2015-05-28 21:03:26 +0000 | [diff] [blame] | 32 | @skipIfDarwin # 'llvm.org/pr23669', cause Python crash randomly |
| 33 | @expectedFailureDarwin('llvm.org/pr23669') |
Zachary Turner | fbb79bb | 2015-09-02 16:47:01 +0000 | [diff] [blame] | 34 | @expectedFailureWindows("llvm.org/pr24660") |
Tamas Berghammer | c8fd130 | 2015-09-30 10:12:40 +0000 | [diff] [blame^] | 35 | def test_state_after_expression(self): |
Andrew Kaylor | 9f6c535 | 2013-04-30 23:39:14 +0000 | [diff] [blame] | 36 | """Test thread state after expression.""" |
Tamas Berghammer | c8fd130 | 2015-09-30 10:12:40 +0000 | [diff] [blame^] | 37 | self.build(dictionary=self.getBuildFlags(use_cpp11=False)) |
Andrew Kaylor | 9f6c535 | 2013-04-30 23:39:14 +0000 | [diff] [blame] | 38 | self.thread_state_after_continue_test() |
| 39 | |
Andrew Kaylor | 93132f5 | 2013-05-28 23:04:25 +0000 | [diff] [blame] | 40 | @unittest2.expectedFailure("llvm.org/pr16712") # thread states not properly maintained |
Zachary Turner | 656ef0b | 2015-09-02 16:47:29 +0000 | [diff] [blame] | 41 | @expectedFailureWindows("llvm.org/pr24668") # Breakpoints not resolved correctly |
Tamas Berghammer | c8fd130 | 2015-09-30 10:12:40 +0000 | [diff] [blame^] | 42 | def test_process_interrupt(self): |
Andrew Kaylor | 9f6c535 | 2013-04-30 23:39:14 +0000 | [diff] [blame] | 43 | """Test process interrupt.""" |
Tamas Berghammer | c8fd130 | 2015-09-30 10:12:40 +0000 | [diff] [blame^] | 44 | self.build(dictionary=self.getBuildFlags(use_cpp11=False)) |
Andrew Kaylor | 9f6c535 | 2013-04-30 23:39:14 +0000 | [diff] [blame] | 45 | self.process_interrupt_test() |
| 46 | |
Daniel Malea | e8bdd1f | 2013-05-15 18:48:32 +0000 | [diff] [blame] | 47 | @unittest2.expectedFailure("llvm.org/pr15824") # thread states not properly maintained |
Zachary Turner | 656ef0b | 2015-09-02 16:47:29 +0000 | [diff] [blame] | 48 | @expectedFailureWindows("llvm.org/pr24668") # Breakpoints not resolved correctly |
Tamas Berghammer | c8fd130 | 2015-09-30 10:12:40 +0000 | [diff] [blame^] | 49 | def test_process_state(self): |
Andrew Kaylor | 9f6c535 | 2013-04-30 23:39:14 +0000 | [diff] [blame] | 50 | """Test thread states (comprehensive).""" |
Tamas Berghammer | c8fd130 | 2015-09-30 10:12:40 +0000 | [diff] [blame^] | 51 | self.build(dictionary=self.getBuildFlags(use_cpp11=False)) |
Andrew Kaylor | dbbe36b | 2013-04-23 21:42:03 +0000 | [diff] [blame] | 52 | self.thread_states_test() |
| 53 | |
| 54 | def setUp(self): |
| 55 | # Call super's setUp(). |
| 56 | TestBase.setUp(self) |
| 57 | # Find the line numbers for our breakpoints. |
Zachary Turner | d1c5b6f | 2015-08-25 22:25:21 +0000 | [diff] [blame] | 58 | self.break_1 = line_number('main.cpp', '// Set first breakpoint here') |
| 59 | self.break_2 = line_number('main.cpp', '// Set second breakpoint here') |
Andrew Kaylor | dbbe36b | 2013-04-23 21:42:03 +0000 | [diff] [blame] | 60 | |
Andrew Kaylor | 9f6c535 | 2013-04-30 23:39:14 +0000 | [diff] [blame] | 61 | def thread_state_after_breakpoint_test(self): |
| 62 | """Test thread state after breakpoint.""" |
| 63 | exe = os.path.join(os.getcwd(), "a.out") |
| 64 | self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) |
| 65 | |
| 66 | # This should create a breakpoint in the main thread. |
Zachary Turner | d1c5b6f | 2015-08-25 22:25:21 +0000 | [diff] [blame] | 67 | lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.break_1, num_expected_locations=1) |
Andrew Kaylor | 9f6c535 | 2013-04-30 23:39:14 +0000 | [diff] [blame] | 68 | |
| 69 | # The breakpoint list should show 1 breakpoint with 1 location. |
| 70 | self.expect("breakpoint list -f", "Breakpoint location shown correctly", |
Zachary Turner | d1c5b6f | 2015-08-25 22:25:21 +0000 | [diff] [blame] | 71 | substrs = ["1: file = 'main.cpp', line = %d, locations = 1" % self.break_1]) |
Andrew Kaylor | 9f6c535 | 2013-04-30 23:39:14 +0000 | [diff] [blame] | 72 | |
| 73 | # Run the program. |
Sean Callanan | 05834cd | 2015-07-01 23:56:30 +0000 | [diff] [blame] | 74 | self.runCmd("run", RUN_SUCCEEDED) |
Andrew Kaylor | 9f6c535 | 2013-04-30 23:39:14 +0000 | [diff] [blame] | 75 | |
| 76 | # The stop reason of the thread should be breakpoint. |
| 77 | self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, |
| 78 | substrs = ['stopped', |
| 79 | '* thread #1', |
| 80 | 'stop reason = breakpoint']) |
| 81 | |
| 82 | # Get the target process |
| 83 | target = self.dbg.GetSelectedTarget() |
| 84 | process = target.GetProcess() |
| 85 | |
| 86 | # Get the number of threads |
| 87 | num_threads = process.GetNumThreads() |
| 88 | |
| 89 | self.assertTrue(num_threads == 1, 'Number of expected threads and actual threads do not match.') |
| 90 | |
| 91 | # Get the thread object |
| 92 | thread = process.GetThreadAtIndex(0) |
| 93 | |
| 94 | # Make sure the thread is in the stopped state. |
| 95 | self.assertTrue(thread.IsStopped(), "Thread state isn't \'stopped\' during breakpoint 1.") |
| 96 | self.assertFalse(thread.IsSuspended(), "Thread state is \'suspended\' during breakpoint 1.") |
| 97 | |
| 98 | # Kill the process |
| 99 | self.runCmd("process kill") |
| 100 | |
| 101 | def thread_state_after_continue_test(self): |
| 102 | """Test thread state after continue.""" |
| 103 | exe = os.path.join(os.getcwd(), "a.out") |
| 104 | self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) |
| 105 | |
| 106 | # This should create a breakpoint in the main thread. |
Zachary Turner | d1c5b6f | 2015-08-25 22:25:21 +0000 | [diff] [blame] | 107 | lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.break_1, num_expected_locations=1) |
| 108 | lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.break_2, num_expected_locations=1) |
Andrew Kaylor | 9f6c535 | 2013-04-30 23:39:14 +0000 | [diff] [blame] | 109 | |
| 110 | # The breakpoint list should show 1 breakpoints with 1 location. |
| 111 | self.expect("breakpoint list -f", "Breakpoint location shown correctly", |
Zachary Turner | d1c5b6f | 2015-08-25 22:25:21 +0000 | [diff] [blame] | 112 | substrs = ["1: file = 'main.cpp', line = %d, exact_match = 0, locations = 1" % self.break_1]) |
Andrew Kaylor | 9f6c535 | 2013-04-30 23:39:14 +0000 | [diff] [blame] | 113 | |
| 114 | # Run the program. |
Sean Callanan | 05834cd | 2015-07-01 23:56:30 +0000 | [diff] [blame] | 115 | self.runCmd("run", RUN_SUCCEEDED) |
Andrew Kaylor | 9f6c535 | 2013-04-30 23:39:14 +0000 | [diff] [blame] | 116 | |
| 117 | # The stop reason of the thread should be breakpoint. |
| 118 | self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, |
| 119 | substrs = ['stopped', |
| 120 | '* thread #1', |
| 121 | 'stop reason = breakpoint']) |
| 122 | |
| 123 | # Get the target process |
| 124 | target = self.dbg.GetSelectedTarget() |
| 125 | process = target.GetProcess() |
| 126 | |
| 127 | # Get the number of threads |
| 128 | num_threads = process.GetNumThreads() |
| 129 | |
| 130 | self.assertTrue(num_threads == 1, 'Number of expected threads and actual threads do not match.') |
| 131 | |
| 132 | # Get the thread object |
| 133 | thread = process.GetThreadAtIndex(0) |
| 134 | |
| 135 | # Continue, the inferior will go into an infinite loop waiting for 'g_test' to change. |
| 136 | self.dbg.SetAsync(True) |
| 137 | self.runCmd("continue") |
| 138 | time.sleep(1) |
| 139 | |
| 140 | # Check the thread state. It should be running. |
| 141 | self.assertFalse(thread.IsStopped(), "Thread state is \'stopped\' when it should be running.") |
| 142 | self.assertFalse(thread.IsSuspended(), "Thread state is \'suspended\' when it should be running.") |
| 143 | |
| 144 | # Go back to synchronous interactions |
| 145 | self.dbg.SetAsync(False) |
| 146 | |
| 147 | # Kill the process |
| 148 | self.runCmd("process kill") |
| 149 | |
| 150 | def thread_state_after_expression_test(self): |
| 151 | """Test thread state after expression.""" |
| 152 | exe = os.path.join(os.getcwd(), "a.out") |
| 153 | self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) |
| 154 | |
| 155 | # This should create a breakpoint in the main thread. |
Zachary Turner | d1c5b6f | 2015-08-25 22:25:21 +0000 | [diff] [blame] | 156 | lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.break_1, num_expected_locations=1) |
| 157 | lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.break_2, num_expected_locations=1) |
Andrew Kaylor | 9f6c535 | 2013-04-30 23:39:14 +0000 | [diff] [blame] | 158 | |
| 159 | # The breakpoint list should show 1 breakpoints with 1 location. |
| 160 | self.expect("breakpoint list -f", "Breakpoint location shown correctly", |
Zachary Turner | d1c5b6f | 2015-08-25 22:25:21 +0000 | [diff] [blame] | 161 | substrs = ["1: file = 'main.cpp', line = %d, locations = 1" % self.break_1]) |
Andrew Kaylor | 9f6c535 | 2013-04-30 23:39:14 +0000 | [diff] [blame] | 162 | |
| 163 | # Run the program. |
Sean Callanan | 05834cd | 2015-07-01 23:56:30 +0000 | [diff] [blame] | 164 | self.runCmd("run", RUN_SUCCEEDED) |
Andrew Kaylor | 9f6c535 | 2013-04-30 23:39:14 +0000 | [diff] [blame] | 165 | |
| 166 | # The stop reason of the thread should be breakpoint. |
| 167 | self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, |
| 168 | substrs = ['stopped', |
| 169 | '* thread #1', |
| 170 | 'stop reason = breakpoint']) |
| 171 | |
| 172 | # Get the target process |
| 173 | target = self.dbg.GetSelectedTarget() |
| 174 | process = target.GetProcess() |
| 175 | |
| 176 | # Get the number of threads |
| 177 | num_threads = process.GetNumThreads() |
| 178 | |
| 179 | self.assertTrue(num_threads == 1, 'Number of expected threads and actual threads do not match.') |
| 180 | |
| 181 | # Get the thread object |
| 182 | thread = process.GetThreadAtIndex(0) |
| 183 | |
| 184 | # Get the inferior out of its loop |
| 185 | self.runCmd("expression g_test = 1") |
| 186 | |
| 187 | # Check the thread state |
| 188 | self.assertTrue(thread.IsStopped(), "Thread state isn't \'stopped\' after expression evaluation.") |
| 189 | self.assertFalse(thread.IsSuspended(), "Thread state is \'suspended\' after expression evaluation.") |
| 190 | |
| 191 | # Let the process run to completion |
| 192 | self.runCmd("process continue") |
| 193 | |
| 194 | |
| 195 | def process_interrupt_test(self): |
| 196 | """Test process interrupt and continue.""" |
| 197 | exe = os.path.join(os.getcwd(), "a.out") |
| 198 | self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) |
| 199 | |
| 200 | # This should create a breakpoint in the main thread. |
Zachary Turner | d1c5b6f | 2015-08-25 22:25:21 +0000 | [diff] [blame] | 201 | lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.break_1, num_expected_locations=1) |
Andrew Kaylor | 9f6c535 | 2013-04-30 23:39:14 +0000 | [diff] [blame] | 202 | |
| 203 | # The breakpoint list should show 1 breakpoints with 1 location. |
| 204 | self.expect("breakpoint list -f", "Breakpoint location shown correctly", |
Zachary Turner | d1c5b6f | 2015-08-25 22:25:21 +0000 | [diff] [blame] | 205 | substrs = ["1: file = 'main.cpp', line = %d, locations = 1" % self.break_1]) |
Andrew Kaylor | 9f6c535 | 2013-04-30 23:39:14 +0000 | [diff] [blame] | 206 | |
| 207 | # Run the program. |
Sean Callanan | 05834cd | 2015-07-01 23:56:30 +0000 | [diff] [blame] | 208 | self.runCmd("run", RUN_SUCCEEDED) |
Andrew Kaylor | 9f6c535 | 2013-04-30 23:39:14 +0000 | [diff] [blame] | 209 | |
| 210 | # The stop reason of the thread should be breakpoint. |
| 211 | self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, |
| 212 | substrs = ['stopped', |
| 213 | '* thread #1', |
| 214 | 'stop reason = breakpoint']) |
| 215 | |
| 216 | # Get the target process |
| 217 | target = self.dbg.GetSelectedTarget() |
| 218 | process = target.GetProcess() |
| 219 | |
| 220 | # Get the number of threads |
| 221 | num_threads = process.GetNumThreads() |
| 222 | |
| 223 | self.assertTrue(num_threads == 1, 'Number of expected threads and actual threads do not match.') |
| 224 | |
| 225 | # Continue, the inferior will go into an infinite loop waiting for 'g_test' to change. |
| 226 | self.dbg.SetAsync(True) |
| 227 | self.runCmd("continue") |
| 228 | time.sleep(1) |
| 229 | |
| 230 | # Go back to synchronous interactions |
| 231 | self.dbg.SetAsync(False) |
| 232 | |
| 233 | # Stop the process |
| 234 | self.runCmd("process interrupt") |
| 235 | |
| 236 | # The stop reason of the thread should be signal. |
| 237 | self.expect("process status", STOPPED_DUE_TO_SIGNAL, |
| 238 | substrs = ['stopped', |
| 239 | '* thread #1', |
| 240 | 'stop reason = signal']) |
| 241 | |
| 242 | # Get the inferior out of its loop |
| 243 | self.runCmd("expression g_test = 1") |
| 244 | |
| 245 | # Run to completion |
| 246 | self.runCmd("continue") |
| 247 | |
Andrew Kaylor | dbbe36b | 2013-04-23 21:42:03 +0000 | [diff] [blame] | 248 | def thread_states_test(self): |
Andrew Kaylor | 9f6c535 | 2013-04-30 23:39:14 +0000 | [diff] [blame] | 249 | """Test thread states (comprehensive).""" |
Andrew Kaylor | dbbe36b | 2013-04-23 21:42:03 +0000 | [diff] [blame] | 250 | exe = os.path.join(os.getcwd(), "a.out") |
| 251 | self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) |
| 252 | |
| 253 | # This should create a breakpoint in the main thread. |
Zachary Turner | d1c5b6f | 2015-08-25 22:25:21 +0000 | [diff] [blame] | 254 | lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.break_1, num_expected_locations=1) |
| 255 | lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.break_2, num_expected_locations=1) |
Andrew Kaylor | dbbe36b | 2013-04-23 21:42:03 +0000 | [diff] [blame] | 256 | |
| 257 | # The breakpoint list should show 2 breakpoints with 1 location each. |
| 258 | self.expect("breakpoint list -f", "Breakpoint location shown correctly", |
Zachary Turner | d1c5b6f | 2015-08-25 22:25:21 +0000 | [diff] [blame] | 259 | substrs = ["1: file = 'main.cpp', line = %d, locations = 1" % self.break_1, |
| 260 | "2: file = 'main.cpp', line = %d, locations = 1" % self.break_2]) |
Andrew Kaylor | dbbe36b | 2013-04-23 21:42:03 +0000 | [diff] [blame] | 261 | |
| 262 | # Run the program. |
Sean Callanan | 05834cd | 2015-07-01 23:56:30 +0000 | [diff] [blame] | 263 | self.runCmd("run", RUN_SUCCEEDED) |
Andrew Kaylor | dbbe36b | 2013-04-23 21:42:03 +0000 | [diff] [blame] | 264 | |
| 265 | # The stop reason of the thread should be breakpoint. |
| 266 | self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, |
| 267 | substrs = ['stopped', |
| 268 | '* thread #1', |
| 269 | 'stop reason = breakpoint']) |
| 270 | |
| 271 | # Get the target process |
| 272 | target = self.dbg.GetSelectedTarget() |
| 273 | process = target.GetProcess() |
| 274 | |
| 275 | # Get the number of threads |
| 276 | num_threads = process.GetNumThreads() |
| 277 | |
| 278 | self.assertTrue(num_threads == 1, 'Number of expected threads and actual threads do not match.') |
| 279 | |
| 280 | # Get the thread object |
| 281 | thread = process.GetThreadAtIndex(0) |
| 282 | |
| 283 | # Make sure the thread is in the stopped state. |
| 284 | self.assertTrue(thread.IsStopped(), "Thread state isn't \'stopped\' during breakpoint 1.") |
| 285 | self.assertFalse(thread.IsSuspended(), "Thread state is \'suspended\' during breakpoint 1.") |
| 286 | |
| 287 | # Continue, the inferior will go into an infinite loop waiting for 'g_test' to change. |
| 288 | self.dbg.SetAsync(True) |
| 289 | self.runCmd("continue") |
| 290 | time.sleep(1) |
| 291 | |
| 292 | # Check the thread state. It should be running. |
| 293 | self.assertFalse(thread.IsStopped(), "Thread state is \'stopped\' when it should be running.") |
| 294 | self.assertFalse(thread.IsSuspended(), "Thread state is \'suspended\' when it should be running.") |
| 295 | |
Andrew Kaylor | dbbe36b | 2013-04-23 21:42:03 +0000 | [diff] [blame] | 296 | # Go back to synchronous interactions |
| 297 | self.dbg.SetAsync(False) |
| 298 | |
| 299 | # Stop the process |
| 300 | self.runCmd("process interrupt") |
| 301 | |
| 302 | # The stop reason of the thread should be signal. |
| 303 | self.expect("process status", STOPPED_DUE_TO_SIGNAL, |
| 304 | substrs = ['stopped', |
| 305 | '* thread #1', |
| 306 | 'stop reason = signal']) |
| 307 | |
Andrew Kaylor | dbbe36b | 2013-04-23 21:42:03 +0000 | [diff] [blame] | 308 | # Check the thread state |
| 309 | self.assertTrue(thread.IsStopped(), "Thread state isn't \'stopped\' after process stop.") |
| 310 | self.assertFalse(thread.IsSuspended(), "Thread state is \'suspended\' after process stop.") |
| 311 | |
| 312 | # Get the inferior out of its loop |
| 313 | self.runCmd("expression g_test = 1") |
| 314 | |
| 315 | # Check the thread state |
| 316 | self.assertTrue(thread.IsStopped(), "Thread state isn't \'stopped\' after expression evaluation.") |
| 317 | self.assertFalse(thread.IsSuspended(), "Thread state is \'suspended\' after expression evaluation.") |
| 318 | |
Andrew Kaylor | 9f6c535 | 2013-04-30 23:39:14 +0000 | [diff] [blame] | 319 | # The stop reason of the thread should be signal. |
| 320 | self.expect("process status", STOPPED_DUE_TO_SIGNAL, |
| 321 | substrs = ['stopped', |
| 322 | '* thread #1', |
| 323 | 'stop reason = signal']) |
| 324 | |
Andrew Kaylor | dbbe36b | 2013-04-23 21:42:03 +0000 | [diff] [blame] | 325 | # Run to breakpoint 2 |
| 326 | self.runCmd("continue") |
| 327 | |
Andrew Kaylor | 9f6c535 | 2013-04-30 23:39:14 +0000 | [diff] [blame] | 328 | # The stop reason of the thread should be breakpoint. |
| 329 | self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, |
| 330 | substrs = ['stopped', |
| 331 | '* thread #1', |
| 332 | 'stop reason = breakpoint']) |
| 333 | |
Andrew Kaylor | dbbe36b | 2013-04-23 21:42:03 +0000 | [diff] [blame] | 334 | # Make sure both threads are stopped |
| 335 | self.assertTrue(thread.IsStopped(), "Thread state isn't \'stopped\' during breakpoint 2.") |
| 336 | self.assertFalse(thread.IsSuspended(), "Thread state is \'suspended\' during breakpoint 2.") |
| 337 | |
| 338 | # Run to completion |
| 339 | self.runCmd("continue") |
| 340 | |
| 341 | # At this point, the inferior process should have exited. |
| 342 | self.assertTrue(process.GetState() == lldb.eStateExited, PROCESS_EXITED) |
| 343 | |
| 344 | if __name__ == '__main__': |
| 345 | import atexit |
| 346 | lldb.SBDebugger.Initialize() |
| 347 | atexit.register(lambda: lldb.SBDebugger.Terminate()) |
| 348 | unittest2.main() |