Todd Fiala | 9b09578 | 2014-06-23 20:56:48 +0000 | [diff] [blame] | 1 | """ |
| 2 | Test SBProcess APIs, including ReadMemory(), WriteMemory(), and others. |
| 3 | """ |
| 4 | |
| 5 | import os, time |
| 6 | import unittest2 |
| 7 | import lldb |
| 8 | from lldbutil import get_stopped_thread, state_type_to_str |
| 9 | from lldbtest import * |
| 10 | |
| 11 | class SignalsAPITestCase(TestBase): |
Greg Clayton | 4184c79 | 2014-08-01 22:10:13 +0000 | [diff] [blame^] | 12 | mydir = TestBase.compute_mydir(__file__) |
Todd Fiala | 9b09578 | 2014-06-23 20:56:48 +0000 | [diff] [blame] | 13 | |
| 14 | @python_api_test |
| 15 | def test_ignore_signal(self): |
| 16 | """Test Python SBUnixSignals.Suppress/Stop/Notify() API.""" |
| 17 | self.buildDefault() |
| 18 | exe = os.path.join(os.getcwd(), "a.out") |
| 19 | self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) |
| 20 | |
| 21 | target = self.dbg.CreateTarget(exe) |
| 22 | self.assertTrue(target, VALID_TARGET) |
| 23 | |
| 24 | line = line_number("main.cpp", "// Set break point at this line and setup signal ignores.") |
| 25 | breakpoint = target.BreakpointCreateByLocation("main.cpp", line) |
| 26 | self.assertTrue(breakpoint, VALID_BREAKPOINT) |
| 27 | |
| 28 | # Launch the process, and do not stop at the entry point. |
| 29 | process = target.LaunchSimple (None, None, self.get_process_working_directory()) |
| 30 | |
| 31 | thread = get_stopped_thread(process, lldb.eStopReasonBreakpoint) |
| 32 | self.assertTrue(thread.IsValid(), "There should be a thread stopped due to breakpoint") |
| 33 | |
| 34 | unix_signals = process.GetUnixSignals() |
| 35 | sigint = unix_signals.GetSignalNumberFromName("SIGINT") |
| 36 | unix_signals.SetShouldSuppress(sigint, True) |
| 37 | unix_signals.SetShouldStop(sigint, False) |
| 38 | unix_signals.SetShouldNotify(sigint, False) |
| 39 | |
| 40 | process.Continue() |
| 41 | self.assertTrue(process.state == lldb.eStateExited, "The process should have exited") |
| 42 | self.assertTrue(process.GetExitStatus() == 0, "The process should have returned 0") |
| 43 | |
| 44 | |
| 45 | if __name__ == '__main__': |
| 46 | import atexit |
| 47 | lldb.SBDebugger.Initialize() |
| 48 | atexit.register(lambda: lldb.SBDebugger.Terminate()) |
| 49 | unittest2.main() |