1""" 2Test that step-inst over a crash behaves correctly. 3""" 4 5 6 7import lldb 8from lldbsuite.test.decorators import * 9from lldbsuite.test.lldbtest import * 10from lldbsuite.test import lldbutil 11 12 13class CrashDuringStepTestCase(TestBase): 14 15 mydir = TestBase.compute_mydir(__file__) 16 17 def setUp(self): 18 TestBase.setUp(self) 19 self.breakpoint = line_number('main.cpp', '// Set breakpoint here') 20 21 # IO error due to breakpoint at invalid address 22 @expectedFailureAll(triple=re.compile('^mips')) 23 @skipIf(oslist=['windows'], archs=['aarch64']) 24 def test_step_inst_with(self): 25 """Test thread creation during step-inst handling.""" 26 self.build() 27 exe = self.getBuildArtifact("a.out") 28 29 target = self.dbg.CreateTarget(exe) 30 self.assertTrue(target and target.IsValid(), "Target is valid") 31 32 self.bp_num = lldbutil.run_break_set_by_file_and_line( 33 self, "main.cpp", self.breakpoint, num_expected_locations=1) 34 35 # Run the program. 36 process = target.LaunchSimple( 37 None, None, self.get_process_working_directory()) 38 self.assertTrue(process and process.IsValid(), PROCESS_IS_VALID) 39 40 # The stop reason should be breakpoint. 41 self.assertEqual( 42 process.GetState(), 43 lldb.eStateStopped, 44 PROCESS_STOPPED) 45 thread = lldbutil.get_stopped_thread( 46 process, lldb.eStopReasonBreakpoint) 47 self.assertTrue(thread.IsValid(), STOPPED_DUE_TO_BREAKPOINT) 48 49 # Keep stepping until the inferior crashes 50 while process.GetState() == lldb.eStateStopped and not lldbutil.is_thread_crashed(self, thread): 51 thread.StepInstruction(False) 52 53 self.assertEqual( 54 process.GetState(), 55 lldb.eStateStopped, 56 PROCESS_STOPPED) 57 self.assertTrue( 58 lldbutil.is_thread_crashed( 59 self, 60 thread), 61 "Thread has crashed") 62 process.Kill() 63