1""" 2Test SBProcess APIs, including ReadMemory(), WriteMemory(), and others. 3""" 4 5 6 7import lldb 8from lldbsuite.test.decorators import * 9from lldbsuite.test.lldbtest import * 10from lldbsuite.test import lldbutil 11from lldbsuite.test.lldbutil import get_stopped_thread, state_type_to_str 12 13 14class SignalsAPITestCase(TestBase): 15 NO_DEBUG_INFO_TESTCASE = True 16 17 @skipIfWindows # Windows doesn't have signals 18 def test_ignore_signal(self): 19 """Test Python SBUnixSignals.Suppress/Stop/Notify() API.""" 20 self.build() 21 exe = self.getBuildArtifact("a.out") 22 self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) 23 24 target = self.dbg.CreateTarget(exe) 25 self.assertTrue(target, VALID_TARGET) 26 27 line = line_number( 28 "main.cpp", 29 "// Set break point at this line and setup signal ignores.") 30 breakpoint = target.BreakpointCreateByLocation("main.cpp", line) 31 self.assertTrue(breakpoint, VALID_BREAKPOINT) 32 33 # Launch the process, and do not stop at the entry point. 34 process = target.LaunchSimple( 35 None, None, self.get_process_working_directory()) 36 37 thread = get_stopped_thread(process, lldb.eStopReasonBreakpoint) 38 self.assertTrue( 39 thread.IsValid(), 40 "There should be a thread stopped due to breakpoint") 41 42 unix_signals = process.GetUnixSignals() 43 sigint = unix_signals.GetSignalNumberFromName("SIGINT") 44 unix_signals.SetShouldSuppress(sigint, True) 45 unix_signals.SetShouldStop(sigint, False) 46 unix_signals.SetShouldNotify(sigint, False) 47 48 process.Continue() 49 self.assertEqual( 50 process.state, lldb.eStateExited, 51 "The process should have exited") 52 self.assertEqual( 53 process.GetExitStatus(), 0, 54 "The process should have returned 0") 55