aboutsummaryrefslogtreecommitdiff
path: root/lldb/examples
diff options
context:
space:
mode:
authorMed Ismail Bennani <medismail.bennani@gmail.com>2023-04-14 14:54:01 -0700
committerMed Ismail Bennani <medismail.bennani@gmail.com>2023-04-25 15:02:34 -0700
commit6c961ae1b5073699285fcdec242cdb4e84602c05 (patch)
treed8565a4c9ed6d2a28e81967266000ed6f00aef8a /lldb/examples
parent0d77e034749f57676fd79e4a5b560be4d5b52b48 (diff)
downloadllvm-6c961ae1b5073699285fcdec242cdb4e84602c05.zip
llvm-6c961ae1b5073699285fcdec242cdb4e84602c05.tar.gz
llvm-6c961ae1b5073699285fcdec242cdb4e84602c05.tar.bz2
[lldb] Move ScriptedProcess private state update to implementation
While debugging a Scripted Process, in order to update its state and work nicely with lldb's execution model, it needs to toggle its private state from running to stopped, which will result in broadcasting a process state changed event to the debugger listener. Originally, this state update was done systematically in the Scripted Process C++ plugin, however in order to make scripted process interactive, we need to be able to update their state dynamically. This patch makes use of the recent addition of the SBProcess::ForceScriptedState to programatically, and moves the process private state update to the python implementation of the resume method instead of doing it in ScriptedProcess::DoResume. This patch also removes the unused ShouldStop & Stop scripted process APIs, and adds new ScriptedInterface transform methods for boolean arguments. This allow the user to programmatically decide if after running the process, we should stop it (which is the default setting). Differential Revision: https://reviews.llvm.org/D145295 Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
Diffstat (limited to 'lldb/examples')
-rw-r--r--lldb/examples/python/scripted_process/scripted_process.py31
1 files changed, 13 insertions, 18 deletions
diff --git a/lldb/examples/python/scripted_process/scripted_process.py b/lldb/examples/python/scripted_process/scripted_process.py
index e4d2521..5cd78ad 100644
--- a/lldb/examples/python/scripted_process/scripted_process.py
+++ b/lldb/examples/python/scripted_process/scripted_process.py
@@ -161,30 +161,25 @@ class ScriptedProcess(metaclass=ABCMeta):
"""
return lldb.SBError()
- def resume(self):
+ def resume(self, should_stop=True):
""" Simulate the scripted process resume.
- Returns:
- lldb.SBError: An `lldb.SBError` with error code 0.
- """
- return lldb.SBError()
-
- @abstractmethod
- def should_stop(self):
- """ Check if the scripted process plugin should produce the stop event.
-
- Returns:
- bool: True if scripted process should broadcast a stop event.
- False otherwise.
- """
- pass
-
- def stop(self):
- """ Trigger the scripted process stop.
+ Args:
+ should_stop (bool): If True, resume will also force the process
+ state to stopped after running it.
Returns:
lldb.SBError: An `lldb.SBError` with error code 0.
"""
+ process = self.target.GetProcess()
+ if not process:
+ error = lldb.SBError()
+ error.SetErrorString("Invalid process.")
+ return error
+
+ process.ForceScriptedState(lldb.eStateRunning);
+ if (should_stop):
+ process.ForceScriptedState(lldb.eStateStopped);
return lldb.SBError()
@abstractmethod