1"""Test that we can debug inferiors that handle SIGSEGV by themselves""" 2 3 4 5 6import lldb 7from lldbsuite.test.decorators import * 8from lldbsuite.test.lldbtest import * 9from lldbsuite.test import lldbutil 10 11 12class HandleSegvTestCase(TestBase): 13 14 @skipIfWindows # signals do not exist on Windows 15 @skipIfDarwin 16 @expectedFailureNetBSD 17 def test_inferior_handle_sigsegv(self): 18 self.build() 19 exe = self.getBuildArtifact("a.out") 20 21 # Create a target by the debugger. 22 target = self.dbg.CreateTarget(exe) 23 self.assertTrue(target, VALID_TARGET) 24 25 # launch 26 process = target.LaunchSimple( 27 None, None, self.get_process_working_directory()) 28 self.assertTrue(process, PROCESS_IS_VALID) 29 self.assertState(process.GetState(), lldb.eStateStopped) 30 signo = process.GetUnixSignals().GetSignalNumberFromName("SIGSEGV") 31 32 thread = lldbutil.get_stopped_thread(process, lldb.eStopReasonSignal) 33 self.assertTrue( 34 thread and thread.IsValid(), 35 "Thread should be stopped due to a signal") 36 self.assertTrue( 37 thread.GetStopReasonDataCount() >= 1, 38 "There was data in the event.") 39 self.assertEqual(thread.GetStopReasonDataAtIndex(0), 40 signo, "The stop signal was SIGSEGV") 41 42 # Continue until we exit. 43 process.Continue() 44 self.assertState(process.GetState(), lldb.eStateExited) 45 self.assertEqual(process.GetExitStatus(), 0) 46