aboutsummaryrefslogtreecommitdiff
path: root/lldb/packages/Python/lldbsuite/test/lldbutil.py
diff options
context:
space:
mode:
authorJim Ingham <jingham@apple.com>2022-05-18 14:39:03 -0700
committerJim Ingham <jingham@apple.com>2022-05-26 14:50:33 -0700
commit134d7f9a4b97e9035150d970bd9e376043c4577e (patch)
tree8ecfa87e6639f75e740c5b9458100d846f18712e /lldb/packages/Python/lldbsuite/test/lldbutil.py
parente267df8ce8d86ba14187b316ad2495afaebe9a44 (diff)
downloadllvm-134d7f9a4b97e9035150d970bd9e376043c4577e.zip
llvm-134d7f9a4b97e9035150d970bd9e376043c4577e.tar.gz
llvm-134d7f9a4b97e9035150d970bd9e376043c4577e.tar.bz2
Store a by name list of signals with their actions in the Target
so that they can be used to prime new Process runs. "process handle" was also changed to populate the dummy target if there's no selected target, so that the settings will get copied into new targets. Differential Revision: https://reviews.llvm.org/D126259
Diffstat (limited to 'lldb/packages/Python/lldbsuite/test/lldbutil.py')
-rw-r--r--lldb/packages/Python/lldbsuite/test/lldbutil.py36
1 files changed, 36 insertions, 0 deletions
diff --git a/lldb/packages/Python/lldbsuite/test/lldbutil.py b/lldb/packages/Python/lldbsuite/test/lldbutil.py
index af2c41d..e3e81a7 100644
--- a/lldb/packages/Python/lldbsuite/test/lldbutil.py
+++ b/lldb/packages/Python/lldbsuite/test/lldbutil.py
@@ -1527,6 +1527,42 @@ def get_signal_number(signal_name):
# No remote platform; fall back to using local python signals.
return getattr(signal, signal_name)
+def get_actions_for_signal(testcase, signal_name, from_target=False, expected_absent=False):
+ """Returns a triple of (pass, stop, notify)"""
+ return_obj = lldb.SBCommandReturnObject()
+ command = "process handle {0}".format(signal_name)
+ if from_target:
+ command += " -t"
+ testcase.dbg.GetCommandInterpreter().HandleCommand(
+ command, return_obj)
+ match = re.match(
+ 'NAME *PASS *STOP *NOTIFY.*(false|true|not set) *(false|true|not set) *(false|true|not set)',
+ return_obj.GetOutput(),
+ re.IGNORECASE | re.DOTALL)
+ if match and expected_absent:
+ testcase.fail('Signal "{0}" was supposed to be absent'.format(signal_name))
+ if not match:
+ if expected_absent:
+ return (None, None, None)
+ testcase.fail('Unable to retrieve default signal disposition.')
+ return (match.group(1), match.group(2), match.group(3))
+
+
+
+def set_actions_for_signal(testcase, signal_name, pass_action, stop_action, notify_action, expect_success=True):
+ return_obj = lldb.SBCommandReturnObject()
+ command = "process handle {0}".format(signal_name)
+ if pass_action != None:
+ command += " -p {0}".format(pass_action)
+ if stop_action != None:
+ command += " -s {0}".format(stop_action)
+ if notify_action != None:
+ command +=" -n {0}".format(notify_action)
+
+ testcase.dbg.GetCommandInterpreter().HandleCommand(command, return_obj)
+ testcase.assertEqual(expect_success,
+ return_obj.Succeeded(),
+ "Setting signal handling for {0} worked as expected".format(signal_name))
class PrintableRegex(object):