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