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
44 LLVM_PRETTY_FUNCTION);
45 if (!dict_sp || !dict_sp->IsValid())
46 return {};
47
48 return dict_sp;
49}
50
54 Dispatch<StructuredData::DictionarySP>("get_process_info", pid),
55 LLVM_PRETTY_FUNCTION);
56 if (!dict_sp || !dict_sp->IsValid())
57 return {};
58
59 return dict_sp;
60}
61
63 ProcessAttachInfoSP attach_info) {
64 // FIXME: Pass `attach_info` to method call
65 return GetStatusFromMethod("attach_to_process");
66}
67
69 ProcessLaunchInfoSP launch_info) {
70 // FIXME: Pass `launch_info` to method call
71 return GetStatusFromMethod("launch_process");
72}
73
77
84
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 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)
Call method_name and fold both failure channels into one Status: a failure to call the method at all,...
static T LogAndDefault(llvm::Expected< T > value_or_err, llvm::StringRef caller)
Log the failure in value_or_err and fall back to a default-constructed T.
ScriptedPythonInterface(ScriptInterpreterPythonImpl &interpreter)
llvm::Expected< T > Dispatch(llvm::StringRef method_name, Args &&...args)
Call method_name on the scripted object.
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
@ eScriptedExtensionScriptedPlatform
std::shared_ptr< lldb_private::ProcessAttachInfo > ProcessAttachInfoSP
uint64_t pid_t
Definition lldb-types.h:84
std::shared_ptr< lldb_private::ProcessLaunchInfo > ProcessLaunchInfoSP
std::shared_ptr< lldb_private::ExecutionContextRef > ExecutionContextRefSP