10#include "lldb/Host/Config.h"
20#include "../lldb-python.h"
23#include "../SWIGPythonBridge.h"
24#include "../ScriptInterpreterPythonImpl.h"
30using Locker = ScriptInterpreterPythonImpl::Locker;
32ScriptedPlatformPythonInterface::ScriptedPlatformPythonInterface(
33 ScriptInterpreterPythonImpl &interpreter)
36llvm::Expected<StructuredData::GenericSP>
37ScriptedPlatformPythonInterface::CreatePluginObject(
41 std::make_shared<ExecutionContextRef>(exe_ctx);
43 return ScriptedPythonInterface::CreatePluginObject(class_name, script_obj,
44 exe_ctx_ref_sp, sd_impl);
50 Dispatch<StructuredData::DictionarySP>(
"list_processes",
error);
52 if (!dict_sp || !dict_sp->IsValid() ||
error.Fail()) {
53 return ScriptedInterface::ErrorWithMessage<StructuredData::DictionarySP>(
55 llvm::Twine(
"Null or invalid object (" +
56 llvm::Twine(
error.AsCString()) + llvm::Twine(
")."))
65ScriptedPlatformPythonInterface::GetProcessInfo(
lldb::pid_t pid) {
68 Dispatch<StructuredData::DictionarySP>(
"get_process_info",
error, pid);
70 if (!dict_sp || !dict_sp->IsValid() ||
error.Fail()) {
71 return ScriptedInterface::ErrorWithMessage<StructuredData::DictionarySP>(
73 llvm::Twine(
"Null or invalid object (" +
74 llvm::Twine(
error.AsCString()) + llvm::Twine(
")."))
82Status ScriptedPlatformPythonInterface::AttachToProcess(
85 return GetStatusFromMethod(
"attach_to_process");
88Status ScriptedPlatformPythonInterface::LaunchProcess(
91 return GetStatusFromMethod(
"launch_process");
95 return GetStatusFromMethod(
"kill_process", pid);
98void ScriptedPlatformPythonInterface::Initialize() {
99 PluginManager::RegisterPlugin(
100 GetPluginNameStatic(),
"Mock platform and interact with its processes.",
101 CreateInstance, eScriptLanguagePython, {});
104void ScriptedPlatformPythonInterface::Terminate() {
105 PluginManager::UnregisterPlugin(CreateInstance);
static llvm::raw_ostream & error(Stream &strm)
"lldb/Target/ExecutionContext.h" A class that contains an execution context.
std::shared_ptr< Dictionary > DictionarySP
A class that represents a running process on the host machine.
std::shared_ptr< lldb_private::ProcessAttachInfo > ProcessAttachInfoSP
std::shared_ptr< lldb_private::ProcessLaunchInfo > ProcessLaunchInfoSP
std::shared_ptr< lldb_private::ExecutionContextRef > ExecutionContextRefSP