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 mydir = TestBase.compute_mydir(__file__) 15 16 @skipIfWindows # signals do not exist on Windows 17 @skipIfDarwin 18 @expectedFailureNetBSD 19 def test_inferior_handle_sigsegv(self): 20 self.build() 21 exe = self.getBuildArtifact("a.out") 22 23 # Create a target by the debugger. 24 target = self.dbg.CreateTarget(exe) 25 self.assertTrue(target, VALID_TARGET) 26 27 # launch 28 process = target.LaunchSimple( 29 None, None, self.get_process_working_directory()) 30 self.assertTrue(process, PROCESS_IS_VALID) 31 self.assertEqual(process.GetState(), lldb.eStateStopped) 32 signo = process.GetUnixSignals().GetSignalNumberFromName("SIGSEGV") 33 34 thread = lldbutil.get_stopped_thread(process, lldb.eStopReasonSignal) 35 self.assertTrue( 36 thread and thread.IsValid(), 37 "Thread should be stopped due to a signal") 38 self.assertTrue( 39 thread.GetStopReasonDataCount() >= 1, 40 "There was data in the event.") 41 self.assertEqual(thread.GetStopReasonDataAtIndex(0), 42 signo, "The stop signal was SIGSEGV") 43 44 # Continue until we exit. 45 process.Continue() 46 self.assertEqual(process.GetState(), lldb.eStateExited) 47 self.assertEqual(process.GetExitStatus(), 0) 48