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