aboutsummaryrefslogtreecommitdiff
path: root/lldb/source/Plugins/ScriptInterpreter/Python
diff options
context:
space:
mode:
authorMed Ismail Bennani <medismail.bennani@gmail.com>2021-07-20 13:00:54 +0000
committerMed Ismail Bennani <medismail.bennani@gmail.com>2021-07-22 14:47:33 +0200
commit312b43da05002bbe4a06de925e34b216252bc412 (patch)
treef28294c85aee052bbeca2f03b94ffc7d2d570d9c /lldb/source/Plugins/ScriptInterpreter/Python
parentb9b696bba6702a31ac0995a494cd31c730ade5ec (diff)
downloadllvm-312b43da05002bbe4a06de925e34b216252bc412.zip
llvm-312b43da05002bbe4a06de925e34b216252bc412.tar.gz
llvm-312b43da05002bbe4a06de925e34b216252bc412.tar.bz2
[lldb/Plugins] Add ScriptedProcess Process Plugin
This patch introduces Scripted Processes to lldb. The goal, here, is to be able to attach in the debugger to fake processes that are backed by script files (in Python, Lua, Swift, etc ...) and inspect them statically. Scripted Processes can be used in cooperative multithreading environments like the XNU Kernel or other real-time operating systems, but it can also help us improve the debugger testing infrastructure by writting synthetic tests that simulates hard-to-reproduce process/thread states. Although ScriptedProcess is not feature-complete at the moment, it has basic execution capabilities and will improve in the following patches. rdar://65508855 Differential Revision: https://reviews.llvm.org/D100384 Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
Diffstat (limited to 'lldb/source/Plugins/ScriptInterpreter/Python')
-rw-r--r--lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.cpp17
-rw-r--r--lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.h6
2 files changed, 17 insertions, 6 deletions
diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.cpp b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.cpp
index 03f745e..51168f8 100644
--- a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.cpp
+++ b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.cpp
@@ -55,15 +55,23 @@ StructuredData::GenericSP ScriptedProcessPythonInterface::CreatePluginObject(
}
Status ScriptedProcessPythonInterface::Launch() {
- return LaunchOrResume("launch");
+ return GetStatusFromMethod("launch");
}
Status ScriptedProcessPythonInterface::Resume() {
- return LaunchOrResume("resume");
+ return GetStatusFromMethod("resume");
}
-Status
-ScriptedProcessPythonInterface::LaunchOrResume(llvm::StringRef method_name) {
+bool ScriptedProcessPythonInterface::ShouldStop() {
+ return GetGenericInteger("shuold_stop");
+}
+
+Status ScriptedProcessPythonInterface::Stop() {
+ return GetStatusFromMethod("stop");
+}
+
+Status ScriptedProcessPythonInterface::GetStatusFromMethod(
+ llvm::StringRef method_name) {
Locker py_lock(&m_interpreter, Locker::AcquireLock | Locker::NoSTDIN,
Locker::FreeLock);
@@ -281,7 +289,6 @@ lldb::pid_t ScriptedProcessPythonInterface::GetProcessID() {
bool ScriptedProcessPythonInterface::IsAlive() {
return GetGenericInteger("is_alive");
- ;
}
#endif
diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.h b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.h
index fc07c92..5d53462 100644
--- a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.h
+++ b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.h
@@ -30,6 +30,10 @@ public:
Status Resume() override;
+ bool ShouldStop() override;
+
+ Status Stop() override;
+
lldb::MemoryRegionInfoSP
GetMemoryRegionContainingAddress(lldb::addr_t address) override;
@@ -48,7 +52,7 @@ public:
protected:
size_t GetGenericInteger(llvm::StringRef method_name);
- Status LaunchOrResume(llvm::StringRef method_name);
+ Status GetStatusFromMethod(llvm::StringRef method_name);
private:
// The lifetime is managed by the ScriptInterpreter