2014-06-23 20:56:48 +00:00
|
|
|
"""
|
|
|
|
|
Test SBProcess APIs, including ReadMemory(), WriteMemory(), and others.
|
|
|
|
|
"""
|
|
|
|
|
|
2015-10-23 17:04:29 +00:00
|
|
|
from __future__ import print_function
|
|
|
|
|
|
2015-11-03 19:20:39 +00:00
|
|
|
|
2016-09-06 20:57:50 +00:00
|
|
|
import os
|
|
|
|
|
import time
|
2014-06-23 20:56:48 +00:00
|
|
|
import lldb
|
2016-02-04 23:04:17 +00:00
|
|
|
from lldbsuite.test.decorators import *
|
2015-11-03 02:06:18 +00:00
|
|
|
from lldbsuite.test.lldbtest import *
|
2016-02-04 23:04:17 +00:00
|
|
|
from lldbsuite.test import lldbutil
|
|
|
|
|
from lldbsuite.test.lldbutil import get_stopped_thread, state_type_to_str
|
2014-06-23 20:56:48 +00:00
|
|
|
|
2016-09-06 20:57:50 +00:00
|
|
|
|
2014-06-23 20:56:48 +00:00
|
|
|
class SignalsAPITestCase(TestBase):
|
2014-08-01 22:10:13 +00:00
|
|
|
mydir = TestBase.compute_mydir(__file__)
|
2014-06-23 20:56:48 +00:00
|
|
|
|
2015-10-26 09:28:32 +00:00
|
|
|
@add_test_categories(['pyapi'])
|
2016-09-06 20:57:50 +00:00
|
|
|
@skipIfWindows # Windows doesn't have signals
|
2014-06-23 20:56:48 +00:00
|
|
|
def test_ignore_signal(self):
|
|
|
|
|
"""Test Python SBUnixSignals.Suppress/Stop/Notify() API."""
|
2015-09-30 10:12:40 +00:00
|
|
|
self.build()
|
2018-01-19 23:24:35 +00:00
|
|
|
exe = self.getBuildArtifact("a.out")
|
2014-06-23 20:56:48 +00:00
|
|
|
self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
|
|
|
|
|
|
|
|
|
|
target = self.dbg.CreateTarget(exe)
|
|
|
|
|
self.assertTrue(target, VALID_TARGET)
|
|
|
|
|
|
2016-09-06 20:57:50 +00:00
|
|
|
line = line_number(
|
|
|
|
|
"main.cpp",
|
|
|
|
|
"// Set break point at this line and setup signal ignores.")
|
2014-06-23 20:56:48 +00:00
|
|
|
breakpoint = target.BreakpointCreateByLocation("main.cpp", line)
|
|
|
|
|
self.assertTrue(breakpoint, VALID_BREAKPOINT)
|
|
|
|
|
|
|
|
|
|
# Launch the process, and do not stop at the entry point.
|
2016-09-06 20:57:50 +00:00
|
|
|
process = target.LaunchSimple(
|
|
|
|
|
None, None, self.get_process_working_directory())
|
2014-06-23 20:56:48 +00:00
|
|
|
|
|
|
|
|
thread = get_stopped_thread(process, lldb.eStopReasonBreakpoint)
|
2016-09-06 20:57:50 +00:00
|
|
|
self.assertTrue(
|
|
|
|
|
thread.IsValid(),
|
|
|
|
|
"There should be a thread stopped due to breakpoint")
|
2014-06-23 20:56:48 +00:00
|
|
|
|
|
|
|
|
unix_signals = process.GetUnixSignals()
|
|
|
|
|
sigint = unix_signals.GetSignalNumberFromName("SIGINT")
|
|
|
|
|
unix_signals.SetShouldSuppress(sigint, True)
|
|
|
|
|
unix_signals.SetShouldStop(sigint, False)
|
|
|
|
|
unix_signals.SetShouldNotify(sigint, False)
|
|
|
|
|
|
|
|
|
|
process.Continue()
|
2016-09-06 20:57:50 +00:00
|
|
|
self.assertTrue(
|
|
|
|
|
process.state == lldb.eStateExited,
|
|
|
|
|
"The process should have exited")
|
|
|
|
|
self.assertTrue(
|
|
|
|
|
process.GetExitStatus() == 0,
|
|
|
|
|
"The process should have returned 0")
|