diff options
| author | Med Ismail Bennani <ismail@bennani.ma> | 2024-05-09 10:39:05 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-05-09 10:39:05 -0700 |
| commit | b3a835e129ed8a67cf393f9ee26989b36a3eff1c (patch) | |
| tree | 5559960f9c1f125081d3f331e2a95a901141b9f0 /lldb/test/API/functionalities/scripted_process/dummy_scripted_process.py | |
| parent | 7c1b2898302c9f84fa43952f746d79817e1ead40 (diff) | |
[lldb] Verify target stop-hooks support with scripted process (#91107)
This patch makes sure that scripted process are compatible with target
stop-hooks. This wasn't tested in the past, but it turned out to be
working out of the box.
rdar://124396534
Signed-off-by: Med Ismail Bennani <ismail@bennani.ma>
Diffstat (limited to 'lldb/test/API/functionalities/scripted_process/dummy_scripted_process.py')
| -rw-r--r-- | lldb/test/API/functionalities/scripted_process/dummy_scripted_process.py | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/lldb/test/API/functionalities/scripted_process/dummy_scripted_process.py b/lldb/test/API/functionalities/scripted_process/dummy_scripted_process.py index 5aff3aa4bb55..cb07bf32c508 100644 --- a/lldb/test/API/functionalities/scripted_process/dummy_scripted_process.py +++ b/lldb/test/API/functionalities/scripted_process/dummy_scripted_process.py @@ -7,6 +7,16 @@ from lldb.plugins.scripted_process import ScriptedProcess from lldb.plugins.scripted_process import ScriptedThread +class DummyStopHook: + def __init__(self, target, args, internal_dict): + self.target = target + self.args = args + + def handle_stop(self, exe_ctx, stream): + print("My DummyStopHook triggered. Printing args: \n%s" % self.args) + sp = exe_ctx.process.GetScriptedImplementation() + sp.handled_stop = True + class DummyScriptedProcess(ScriptedProcess): memory = None @@ -18,6 +28,7 @@ class DummyScriptedProcess(ScriptedProcess): debugger = self.target.GetDebugger() index = debugger.GetIndexOfTarget(self.target) self.memory[addr] = "Hello, target " + str(index) + self.handled_stop = False def read_memory_at_address( self, addr: int, size: int, error: lldb.SBError @@ -99,8 +110,14 @@ class DummyScriptedThread(ScriptedThread): def __lldb_init_module(debugger, dict): + # This is used when loading the script in an interactive debug session to + # automatically, register the stop-hook and launch the scripted process. if not "SKIP_SCRIPTED_PROCESS_LAUNCH" in os.environ: debugger.HandleCommand( + "target stop-hook add -k first -v 1 -k second -v 2 -P %s.%s" + % (__name__, DummyStopHook.__name__) + ) + debugger.HandleCommand( "process launch -C %s.%s" % (__name__, DummyScriptedProcess.__name__) ) else: @@ -108,3 +125,7 @@ def __lldb_init_module(debugger, dict): "Name of the class that will manage the scripted process: '%s.%s'" % (__name__, DummyScriptedProcess.__name__) ) + print( + "Name of the class that will manage the stop-hook: '%s.%s'" + % (__name__, DummyStopHook.__name__) + ) |
