summaryrefslogtreecommitdiffstats
path: root/lldb/packages/Python/lldbsuite/test/functionalities/signal
diff options
context:
space:
mode:
Diffstat (limited to 'lldb/packages/Python/lldbsuite/test/functionalities/signal')
-rw-r--r--lldb/packages/Python/lldbsuite/test/functionalities/signal/TestSendSignal.py27
-rw-r--r--lldb/packages/Python/lldbsuite/test/functionalities/signal/handle-segv/TestHandleSegv.py21
-rw-r--r--lldb/packages/Python/lldbsuite/test/functionalities/signal/raise/TestRaise.py150
3 files changed, 133 insertions, 65 deletions
diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/signal/TestSendSignal.py b/lldb/packages/Python/lldbsuite/test/functionalities/signal/TestSendSignal.py
index 1da4d701a59..0a2756d87fb 100644
--- a/lldb/packages/Python/lldbsuite/test/functionalities/signal/TestSendSignal.py
+++ b/lldb/packages/Python/lldbsuite/test/functionalities/signal/TestSendSignal.py
@@ -3,8 +3,9 @@
from __future__ import print_function
-
-import os, time, signal
+import os
+import time
+import signal
import lldb
from lldbsuite.test.decorators import *
from lldbsuite.test.lldbtest import *
@@ -21,8 +22,10 @@ class SendSignalTestCase(TestBase):
# Find the line number to break inside main().
self.line = line_number('main.c', 'Put breakpoint here')
- @expectedFailureAll(oslist=['freebsd'], bugnumber="llvm.org/pr23318: does not report running state")
- @skipIfWindows # Windows does not support signals
+ @expectedFailureAll(
+ oslist=['freebsd'],
+ bugnumber="llvm.org/pr23318: does not report running state")
+ @skipIfWindows # Windows does not support signals
def test_with_run_command(self):
"""Test that lldb command 'process signal SIGUSR1' sends a signal to the inferior process."""
self.build()
@@ -57,14 +60,17 @@ class SendSignalTestCase(TestBase):
self.runCmd("process handle -n False -p True -s True SIGUSR1")
- thread = lldbutil.get_stopped_thread(process, lldb.eStopReasonBreakpoint)
+ thread = lldbutil.get_stopped_thread(
+ process, lldb.eStopReasonBreakpoint)
self.assertTrue(thread.IsValid(), "We hit the first breakpoint.")
# After resuming the process, send it a SIGUSR1 signal.
self.setAsync(True)
- self.assertTrue(process_listener.IsValid(), "Got a good process listener")
+ self.assertTrue(
+ process_listener.IsValid(),
+ "Got a good process listener")
# Disable our breakpoint, we don't want to hit it anymore...
breakpoint.SetEnabled(False)
@@ -88,9 +94,12 @@ class SendSignalTestCase(TestBase):
self.assertTrue(len(threads) == 1, "One thread stopped for a signal.")
thread = threads[0]
- self.assertTrue(thread.GetStopReasonDataCount() >= 1, "There was data in the event.")
- self.assertTrue(thread.GetStopReasonDataAtIndex(0) == lldbutil.get_signal_number('SIGUSR1'),
- "The stop signal was SIGUSR1")
+ self.assertTrue(
+ thread.GetStopReasonDataCount() >= 1,
+ "There was data in the event.")
+ self.assertTrue(
+ thread.GetStopReasonDataAtIndex(0) == lldbutil.get_signal_number('SIGUSR1'),
+ "The stop signal was SIGUSR1")
def match_state(self, process_listener, expected_state):
num_seconds = 5
diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/signal/handle-segv/TestHandleSegv.py b/lldb/packages/Python/lldbsuite/test/functionalities/signal/handle-segv/TestHandleSegv.py
index d8dbb7f6893..16681fdbcde 100644
--- a/lldb/packages/Python/lldbsuite/test/functionalities/signal/handle-segv/TestHandleSegv.py
+++ b/lldb/packages/Python/lldbsuite/test/functionalities/signal/handle-segv/TestHandleSegv.py
@@ -3,7 +3,6 @@
from __future__ import print_function
-
import os
import re
@@ -17,9 +16,11 @@ class HandleSegvTestCase(TestBase):
mydir = TestBase.compute_mydir(__file__)
- @skipIfWindows # signals do not exist on Windows
+ @skipIfWindows # signals do not exist on Windows
@skipIfDarwin
- @expectedFailureAll(oslist=['freebsd'], bugnumber="llvm.org/pr23699 SIGSEGV is reported as exception, not signal")
+ @expectedFailureAll(
+ oslist=['freebsd'],
+ bugnumber="llvm.org/pr23699 SIGSEGV is reported as exception, not signal")
def test_inferior_handle_sigsegv(self):
self.build()
exe = os.path.join(os.getcwd(), "a.out")
@@ -29,15 +30,21 @@ class HandleSegvTestCase(TestBase):
self.assertTrue(target, VALID_TARGET)
# launch
- process = target.LaunchSimple(None, None, self.get_process_working_directory())
+ process = target.LaunchSimple(
+ None, None, self.get_process_working_directory())
self.assertTrue(process, PROCESS_IS_VALID)
self.assertEqual(process.GetState(), lldb.eStateStopped)
signo = process.GetUnixSignals().GetSignalNumberFromName("SIGSEGV")
thread = lldbutil.get_stopped_thread(process, lldb.eStopReasonSignal)
- self.assertTrue(thread and thread.IsValid(), "Thread should be stopped due to a signal")
- self.assertTrue(thread.GetStopReasonDataCount() >= 1, "There was data in the event.")
- self.assertEqual(thread.GetStopReasonDataAtIndex(0), signo, "The stop signal was SIGSEGV")
+ self.assertTrue(
+ thread and thread.IsValid(),
+ "Thread should be stopped due to a signal")
+ self.assertTrue(
+ thread.GetStopReasonDataCount() >= 1,
+ "There was data in the event.")
+ self.assertEqual(thread.GetStopReasonDataAtIndex(0),
+ signo, "The stop signal was SIGSEGV")
# Continue until we exit.
process.Continue()
diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/signal/raise/TestRaise.py b/lldb/packages/Python/lldbsuite/test/functionalities/signal/raise/TestRaise.py
index 2c30f69d7b2..efadea51f66 100644
--- a/lldb/packages/Python/lldbsuite/test/functionalities/signal/raise/TestRaise.py
+++ b/lldb/packages/Python/lldbsuite/test/functionalities/signal/raise/TestRaise.py
@@ -3,7 +3,6 @@
from __future__ import print_function
-
import os
import lldb
import re
@@ -13,7 +12,7 @@ from lldbsuite.test.lldbtest import *
from lldbsuite.test import lldbutil
-@skipIfWindows # signals do not exist on Windows
+@skipIfWindows # signals do not exist on Windows
class RaiseTestCase(TestBase):
mydir = TestBase.compute_mydir(__file__)
@@ -21,9 +20,10 @@ class RaiseTestCase(TestBase):
def test_sigstop(self):
self.build()
self.signal_test('SIGSTOP', False)
- # passing of SIGSTOP is not correctly handled, so not testing that scenario: https://llvm.org/bugs/show_bug.cgi?id=23574
+ # passing of SIGSTOP is not correctly handled, so not testing that
+ # scenario: https://llvm.org/bugs/show_bug.cgi?id=23574
- @skipIfDarwin # darwin does not support real time signals
+ @skipIfDarwin # darwin does not support real time signals
@skipIfTargetAndroid()
def test_sigsigrtmin(self):
self.build()
@@ -31,20 +31,25 @@ class RaiseTestCase(TestBase):
def launch(self, target, signal):
# launch the process, do not stop at entry point.
- process = target.LaunchSimple([signal], None, self.get_process_working_directory())
+ process = target.LaunchSimple(
+ [signal], None, self.get_process_working_directory())
self.assertTrue(process, PROCESS_IS_VALID)
self.assertEqual(process.GetState(), lldb.eStateStopped)
- thread = lldbutil.get_stopped_thread(process, lldb.eStopReasonBreakpoint)
- self.assertTrue(thread.IsValid(), "Thread should be stopped due to a breakpoint")
+ thread = lldbutil.get_stopped_thread(
+ process, lldb.eStopReasonBreakpoint)
+ self.assertTrue(
+ thread.IsValid(),
+ "Thread should be stopped due to a breakpoint")
return process
def set_handle(self, signal, pass_signal, stop_at_signal, notify_signal):
return_obj = lldb.SBCommandReturnObject()
self.dbg.GetCommandInterpreter().HandleCommand(
- "process handle %s -p %s -s %s -n %s" % (signal, pass_signal, stop_at_signal, notify_signal),
- return_obj)
- self.assertTrue (return_obj.Succeeded() == True, "Setting signal handling failed")
-
+ "process handle %s -p %s -s %s -n %s" %
+ (signal, pass_signal, stop_at_signal, notify_signal), return_obj)
+ self.assertTrue(
+ return_obj.Succeeded(),
+ "Setting signal handling failed")
def signal_test(self, signal, test_passing):
"""Test that we handle inferior raising signals"""
@@ -61,9 +66,12 @@ class RaiseTestCase(TestBase):
# retrieve default signal disposition
return_obj = lldb.SBCommandReturnObject()
- self.dbg.GetCommandInterpreter().HandleCommand("process handle %s " % signal, return_obj)
- match = re.match('NAME *PASS *STOP *NOTIFY.*(false|true) *(false|true) *(false|true)',
- return_obj.GetOutput(), re.IGNORECASE | re.DOTALL)
+ self.dbg.GetCommandInterpreter().HandleCommand(
+ "process handle %s " % signal, return_obj)
+ match = re.match(
+ 'NAME *PASS *STOP *NOTIFY.*(false|true) *(false|true) *(false|true)',
+ return_obj.GetOutput(),
+ re.IGNORECASE | re.DOTALL)
if not match:
self.fail('Unable to retrieve default signal disposition.')
default_pass = match.group(1)
@@ -75,10 +83,14 @@ class RaiseTestCase(TestBase):
process.Continue()
self.assertEqual(process.GetState(), lldb.eStateStopped)
thread = lldbutil.get_stopped_thread(process, lldb.eStopReasonSignal)
- self.assertTrue(thread.IsValid(), "Thread should be stopped due to a signal")
- self.assertTrue(thread.GetStopReasonDataCount() >= 1, "There was data in the event.")
+ self.assertTrue(
+ thread.IsValid(),
+ "Thread should be stopped due to a signal")
+ self.assertTrue(
+ thread.GetStopReasonDataCount() >= 1,
+ "There was data in the event.")
self.assertEqual(thread.GetStopReasonDataAtIndex(0), signo,
- "The stop signal was %s" % signal)
+ "The stop signal was %s" % signal)
# Continue until we exit.
process.Continue()
@@ -88,18 +100,27 @@ class RaiseTestCase(TestBase):
# launch again
process = self.launch(target, signal)
- # Make sure we do not stop at the signal. We should still get the notification.
+ # Make sure we do not stop at the signal. We should still get the
+ # notification.
self.set_handle(signal, "false", "false", "true")
- self.expect("process continue", substrs=["stopped and restarted", signal])
+ self.expect(
+ "process continue",
+ substrs=[
+ "stopped and restarted",
+ signal])
self.assertEqual(process.GetState(), lldb.eStateExited)
self.assertEqual(process.GetExitStatus(), 0)
# launch again
process = self.launch(target, signal)
- # Make sure we do not stop at the signal, and we do not get the notification.
+ # Make sure we do not stop at the signal, and we do not get the
+ # notification.
self.set_handle(signal, "false", "false", "false")
- self.expect("process continue", substrs=["stopped and restarted"], matching=False)
+ self.expect(
+ "process continue",
+ substrs=["stopped and restarted"],
+ matching=False)
self.assertEqual(process.GetState(), lldb.eStateExited)
self.assertEqual(process.GetExitStatus(), 0)
@@ -116,11 +137,17 @@ class RaiseTestCase(TestBase):
process.Continue()
self.assertEqual(process.GetState(), lldb.eStateStopped)
thread = lldbutil.get_stopped_thread(process, lldb.eStopReasonSignal)
- self.assertTrue(thread.IsValid(), "Thread should be stopped due to a signal")
- self.assertTrue(thread.GetStopReasonDataCount() >= 1, "There was data in the event.")
- self.assertEqual(thread.GetStopReasonDataAtIndex(0),
- process.GetUnixSignals().GetSignalNumberFromName(signal),
- "The stop signal was %s" % signal)
+ self.assertTrue(
+ thread.IsValid(),
+ "Thread should be stopped due to a signal")
+ self.assertTrue(
+ thread.GetStopReasonDataCount() >= 1,
+ "There was data in the event.")
+ self.assertEqual(
+ thread.GetStopReasonDataAtIndex(0),
+ process.GetUnixSignals().GetSignalNumberFromName(signal),
+ "The stop signal was %s" %
+ signal)
# Continue until we exit. The process should receive the signal.
process.Continue()
@@ -133,7 +160,11 @@ class RaiseTestCase(TestBase):
# Make sure we do not stop at the signal. We should still get the notification. Process
# should receive the signal.
self.set_handle(signal, "true", "false", "true")
- self.expect("process continue", substrs=["stopped and restarted", signal])
+ self.expect(
+ "process continue",
+ substrs=[
+ "stopped and restarted",
+ signal])
self.assertEqual(process.GetState(), lldb.eStateExited)
self.assertEqual(process.GetExitStatus(), signo)
@@ -143,14 +174,20 @@ class RaiseTestCase(TestBase):
# Make sure we do not stop at the signal, and we do not get the notification. Process
# should receive the signal.
self.set_handle(signal, "true", "false", "false")
- self.expect("process continue", substrs=["stopped and restarted"], matching=False)
+ self.expect(
+ "process continue",
+ substrs=["stopped and restarted"],
+ matching=False)
self.assertEqual(process.GetState(), lldb.eStateExited)
self.assertEqual(process.GetExitStatus(), signo)
# reset signal handling to default
self.set_handle(signal, default_pass, default_stop, default_notify)
- @expectedFailureAll(oslist=["linux"]+getDarwinOSTriples(), bugnumber="llvm.org/pr20231")
+ @expectedFailureAll(
+ oslist=["linux"] +
+ getDarwinOSTriples(),
+ bugnumber="llvm.org/pr20231")
def test_restart_bug(self):
"""Test that we catch a signal in the edge case where the process receives it while we are
about to interrupt it"""
@@ -167,16 +204,16 @@ class RaiseTestCase(TestBase):
self.dbg.SetAsync(True)
error = lldb.SBError()
listener = lldb.SBListener("my listener")
- process = target.Launch (listener,
- ["SIGSTOP"], # argv
- None, # envp
- None, # stdin_path
- None, # stdout_path
- None, # stderr_path
- None, # working directory
- 0, # launch flags
- False, # Stop at entry
- error) # error
+ process = target.Launch(listener,
+ ["SIGSTOP"], # argv
+ None, # envp
+ None, # stdin_path
+ None, # stdout_path
+ None, # stderr_path
+ None, # working directory
+ 0, # launch flags
+ False, # Stop at entry
+ error) # error
self.assertTrue(process and process.IsValid(), PROCESS_IS_VALID)
@@ -187,12 +224,18 @@ class RaiseTestCase(TestBase):
# The last WaitForEvent call will time out after 2 seconds.
while listener.WaitForEvent(2, event):
if self.TraceOn():
- print("Process changing state to:", self.dbg.StateAsCString(process.GetStateFromEvent(event)))
+ print(
+ "Process changing state to:",
+ self.dbg.StateAsCString(
+ process.GetStateFromEvent(event)))
# now the process should be stopped
- self.assertEqual(process.GetState(), lldb.eStateStopped, PROCESS_STOPPED)
- self.assertEqual(len(lldbutil.get_threads_stopped_at_breakpoint(process, bkpt)), 1,
- "A thread should be stopped at breakpoint")
+ self.assertEqual(
+ process.GetState(),
+ lldb.eStateStopped,
+ PROCESS_STOPPED)
+ self.assertEqual(len(lldbutil.get_threads_stopped_at_breakpoint(
+ process, bkpt)), 1, "A thread should be stopped at breakpoint")
# Remove all breakpoints. This makes sure we don't have to single-step over them when we
# resume the process below
@@ -200,23 +243,32 @@ class RaiseTestCase(TestBase):
# resume the process and immediately try to set another breakpoint. When using the remote
# stub, this will trigger a request to stop the process just as it is about to stop
- # naturally due to a SIGSTOP signal it raises. Make sure we do not lose this signal.
+ # naturally due to a SIGSTOP signal it raises. Make sure we do not lose
+ # this signal.
process.Continue()
- self.assertTrue(target.BreakpointCreateByName("handler").IsValid(), VALID_BREAKPOINT)
+ self.assertTrue(target.BreakpointCreateByName(
+ "handler").IsValid(), VALID_BREAKPOINT)
# Clear the events again
while listener.WaitForEvent(2, event):
if self.TraceOn():
- print("Process changing state to:", self.dbg.StateAsCString(process.GetStateFromEvent(event)))
+ print(
+ "Process changing state to:",
+ self.dbg.StateAsCString(
+ process.GetStateFromEvent(event)))
# The process should be stopped due to a signal
self.assertEqual(process.GetState(), lldb.eStateStopped)
thread = lldbutil.get_stopped_thread(process, lldb.eStopReasonSignal)
- self.assertTrue(thread.IsValid(), "Thread should be stopped due to a signal")
- self.assertTrue(thread.GetStopReasonDataCount() >= 1, "There was data in the event.")
+ self.assertTrue(
+ thread.IsValid(),
+ "Thread should be stopped due to a signal")
+ self.assertTrue(
+ thread.GetStopReasonDataCount() >= 1,
+ "There was data in the event.")
signo = process.GetUnixSignals().GetSignalNumberFromName("SIGSTOP")
self.assertEqual(thread.GetStopReasonDataAtIndex(0), signo,
- "The stop signal was %s" % signal)
+ "The stop signal was %s" % signal)
# We are done
process.Kill()
OpenPOWER on IntegriCloud