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
9#include "../lldb-python.h"
10
13#include "lldb/Utility/Log.h"
14#include "lldb/Utility/Status.h"
16
17#include "../SWIGPythonBridge.h"
20
21using namespace lldb;
22using namespace lldb_private;
23using namespace lldb_private::python;
25
29
30llvm::Expected<StructuredData::GenericSP>
32 llvm::StringRef class_name, ExecutionContext &exe_ctx,
34 ExecutionContextRefSP exe_ctx_ref_sp =
35 std::make_shared<ExecutionContextRef>(exe_ctx);
36 ScriptedMetadata scripted_metadata(class_name, args_sp);
38 scripted_metadata, script_obj, exe_ctx_ref_sp, args_sp);
39}
40
45
46 if (!dict_sp || !dict_sp->IsValid() || error.Fail()) {
48 LLVM_PRETTY_FUNCTION,
49 llvm::Twine("Null or invalid object (" +
50 llvm::Twine(error.AsCString()) + llvm::Twine(")."))
51 .str(),
52 error);
53 }
54
55 return dict_sp;
56}
57
62 Dispatch<StructuredData::DictionarySP>("get_process_info", error, pid);
63
64 if (!dict_sp || !dict_sp->IsValid() || error.Fail()) {
66 LLVM_PRETTY_FUNCTION,
67 llvm::Twine("Null or invalid object (" +
68 llvm::Twine(error.AsCString()) + llvm::Twine(")."))
69 .str(),
70 error);
71 }
72
73 return dict_sp;
74}
75
77 ProcessAttachInfoSP attach_info) {
78 // FIXME: Pass `attach_info` to method call
79 return GetStatusFromMethod("attach_to_process");
80}
81
83 ProcessLaunchInfoSP launch_info) {
84 // FIXME: Pass `launch_info` to method call
85 return GetStatusFromMethod("launch_process");
86}
87
91
94 GetPluginNameStatic(), "Mock platform and interact with its processes.",
96}
97
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)
ScriptedPythonInterface(ScriptInterpreterPythonImpl &interpreter)
T Dispatch(llvm::StringRef method_name, Status &error, Args &&...args)
llvm::Expected< StructuredData::GenericSP > CreatePluginObject(const ScriptedMetadata &scripted_metadata, StructuredData::Generic *script_obj, 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