LLDB mainline
ScriptedPlatformPythonInterface.cpp
Go to the documentation of this file.
1//===-- ScriptedPlatformPythonInterface.cpp -------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
11#include "lldb/Utility/Log.h"
12#include "lldb/Utility/Status.h"
14
15// clang-format off
16// LLDB Python header must be included first
17#include "../lldb-python.h"
18//clang-format on
19
20#include "../SWIGPythonBridge.h"
23
24using namespace lldb;
25using namespace lldb_private;
26using namespace lldb_private::python;
28
32
33llvm::Expected<StructuredData::GenericSP>
35 llvm::StringRef class_name, ExecutionContext &exe_ctx,
37 ExecutionContextRefSP exe_ctx_ref_sp =
38 std::make_shared<ExecutionContextRef>(exe_ctx);
39 StructuredDataImpl sd_impl(args_sp);
40 return ScriptedPythonInterface::CreatePluginObject(class_name, script_obj,
41 exe_ctx_ref_sp, sd_impl);
42}
43
48
49 if (!dict_sp || !dict_sp->IsValid() || error.Fail()) {
51 LLVM_PRETTY_FUNCTION,
52 llvm::Twine("Null or invalid object (" +
53 llvm::Twine(error.AsCString()) + llvm::Twine(")."))
54 .str(),
55 error);
56 }
57
58 return dict_sp;
59}
60
65 Dispatch<StructuredData::DictionarySP>("get_process_info", error, pid);
66
67 if (!dict_sp || !dict_sp->IsValid() || error.Fail()) {
69 LLVM_PRETTY_FUNCTION,
70 llvm::Twine("Null or invalid object (" +
71 llvm::Twine(error.AsCString()) + llvm::Twine(")."))
72 .str(),
73 error);
74 }
75
76 return dict_sp;
77}
78
80 ProcessAttachInfoSP attach_info) {
81 // FIXME: Pass `attach_info` to method call
82 return GetStatusFromMethod("attach_to_process");
83}
84
86 ProcessLaunchInfoSP launch_info) {
87 // FIXME: Pass `launch_info` to method call
88 return GetStatusFromMethod("launch_process");
89}
90
94
97 GetPluginNameStatic(), "Mock platform and interact with its processes.",
99}
100
static llvm::raw_ostream & error(Stream &strm)
ScriptInterpreterPythonImpl::Locker Locker
"lldb/Target/ExecutionContext.h" A class that contains an execution context.
static bool RegisterPlugin(llvm::StringRef name, llvm::StringRef description, ABICreateInstance create_callback)
static bool UnregisterPlugin(ABICreateInstance create_callback)
static Ret ErrorWithMessage(llvm::StringRef caller_name, llvm::StringRef error_msg, Status &error, LLDBLog log_category=LLDBLog::Process)
static bool CreateInstance(lldb::ScriptLanguage language, ScriptedInterfaceUsages usages)
StructuredData::DictionarySP GetProcessInfo(lldb::pid_t) override
llvm::Expected< StructuredData::GenericSP > CreatePluginObject(const llvm::StringRef class_name, ExecutionContext &exe_ctx, StructuredData::DictionarySP args_sp, StructuredData::Generic *script_obj=nullptr) override
Status LaunchProcess(lldb::ProcessLaunchInfoSP launch_info) override
ScriptedPlatformPythonInterface(ScriptInterpreterPythonImpl &interpreter)
Status AttachToProcess(lldb::ProcessAttachInfoSP attach_info) override
Status GetStatusFromMethod(llvm::StringRef method_name, Args &&...args)
llvm::Expected< StructuredData::GenericSP > CreatePluginObject(llvm::StringRef class_name, StructuredData::Generic *script_obj, Args... args)
ScriptedPythonInterface(ScriptInterpreterPythonImpl &interpreter)
T Dispatch(llvm::StringRef method_name, Status &error, Args &&...args)
An error handling class.
Definition Status.h:118
std::shared_ptr< Dictionary > DictionarySP
A class that represents a running process on the host machine.
@ eScriptLanguagePython
std::shared_ptr< lldb_private::ProcessAttachInfo > ProcessAttachInfoSP
uint64_t pid_t
Definition lldb-types.h:83
std::shared_ptr< lldb_private::ProcessLaunchInfo > ProcessLaunchInfoSP
std::shared_ptr< lldb_private::ExecutionContextRef > ExecutionContextRefSP