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