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 mydir = TestBase.compute_mydir(__file__) 16 NO_DEBUG_INFO_TESTCASE = True 17 18 @skipIfWindows # Windows doesn't have signals 19 def test_ignore_signal(self): 20 """Test Python SBUnixSignals.Suppress/Stop/Notify() API.""" 21 self.build() 22 exe = self.getBuildArtifact("a.out") 23 self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) 24 25 target = self.dbg.CreateTarget(exe) 26 self.assertTrue(target, VALID_TARGET) 27 28 line = line_number( 29 "main.cpp", 30 "// Set break point at this line and setup signal ignores.") 31 breakpoint = target.BreakpointCreateByLocation("main.cpp", line) 32 self.assertTrue(breakpoint, VALID_BREAKPOINT) 33 34 # Launch the process, and do not stop at the entry point. 35 process = target.LaunchSimple( 36 None, None, self.get_process_working_directory()) 37 38 thread = get_stopped_thread(process, lldb.eStopReasonBreakpoint) 39 self.assertTrue( 40 thread.IsValid(), 41 "There should be a thread stopped due to breakpoint") 42 43 unix_signals = process.GetUnixSignals() 44 sigint = unix_signals.GetSignalNumberFromName("SIGINT") 45 unix_signals.SetShouldSuppress(sigint, True) 46 unix_signals.SetShouldStop(sigint, False) 47 unix_signals.SetShouldNotify(sigint, False) 48 49 process.Continue() 50 self.assertEqual( 51 process.state, lldb.eStateExited, 52 "The process should have exited") 53 self.assertEqual( 54 process.GetExitStatus(), 0, 55 "The process should have returned 0") 56