LLDB mainline
OperatingSystemPythonInterface.cpp
Go to the documentation of this file.
1//===-- ScriptedThreadPythonInterface.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"
13
14// clang-format off
15// LLDB Python header must be included first
16#include "../lldb-python.h"
17//clang-format on
18
19#include "../SWIGPythonBridge.h"
22
23using namespace lldb;
24using namespace lldb_private;
25using namespace lldb_private::python;
27
31
32llvm::Expected<StructuredData::GenericSP>
34 llvm::StringRef class_name, ExecutionContext &exe_ctx,
36 return ScriptedPythonInterface::CreatePluginObject(class_name, nullptr,
37 exe_ctx.GetProcessSP());
38}
39
42 lldb::addr_t context) {
45 "create_thread", error, tid, context);
46
47 if (!ScriptedInterface::CheckStructuredDataObject(LLVM_PRETTY_FUNCTION, dict,
48 error))
49 return {};
50
51 return dict;
52}
53
57 Dispatch<StructuredData::ArraySP>("get_thread_info", error);
58
59 if (!ScriptedInterface::CheckStructuredDataObject(LLVM_PRETTY_FUNCTION, arr,
60 error))
61 return {};
62
63 return arr;
64}
65
69
70std::optional<std::string>
73 StructuredData::ObjectSP obj = Dispatch("get_register_data", error, tid);
74
75 if (!ScriptedInterface::CheckStructuredDataObject(LLVM_PRETTY_FUNCTION, obj,
76 error))
77 return {};
78
79 return obj->GetAsString()->GetValue().str();
80}
81
84 StructuredData::ObjectSP obj = Dispatch("does_plugin_report_all_threads", error);
85 if (!ScriptedInterface::CheckStructuredDataObject(LLVM_PRETTY_FUNCTION, obj,
86 error))
87 return {};
88
89 return obj->GetAsBoolean()->GetValue();
90}
91
93 const std::vector<llvm::StringRef> ci_usages = {
94 "settings set target.process.python-os-plugin-path <script-path>",
95 "settings set process.experimental.os-plugin-reports-all-threads [0/1]"};
96 const std::vector<llvm::StringRef> api_usages = {};
98 GetPluginNameStatic(), llvm::StringRef("Mock thread state"),
99 CreateInstance, eScriptLanguagePython, {ci_usages, api_usages});
100}
101
static llvm::raw_ostream & error(Stream &strm)
ScriptInterpreterPythonImpl::Locker Locker
"lldb/Target/ExecutionContext.h" A class that contains an execution context.
const lldb::ProcessSP & GetProcessSP() const
Get accessor to get the process shared pointer.
llvm::Expected< StructuredData::GenericSP > CreatePluginObject(llvm::StringRef class_name, ExecutionContext &exe_ctx, StructuredData::DictionarySP args_sp, StructuredData::Generic *script_obj=nullptr) override
StructuredData::DictionarySP GetRegisterInfo() override
std::optional< std::string > GetRegisterContextForTID(lldb::tid_t tid) override
OperatingSystemPythonInterface(ScriptInterpreterPythonImpl &interpreter)
StructuredData::DictionarySP CreateThread(lldb::tid_t tid, lldb::addr_t context) override
static bool RegisterPlugin(llvm::StringRef name, llvm::StringRef description, ABICreateInstance create_callback)
static bool UnregisterPlugin(ABICreateInstance create_callback)
static bool CheckStructuredDataObject(llvm::StringRef caller, T obj, Status &error)
static bool CreateInstance(lldb::ScriptLanguage language, ScriptedInterfaceUsages usages)
llvm::Expected< StructuredData::GenericSP > CreatePluginObject(llvm::StringRef class_name, StructuredData::Generic *script_obj, Args... args)
T Dispatch(llvm::StringRef method_name, Status &error, Args &&...args)
StructuredData::DictionarySP GetRegisterInfo() override
ScriptedThreadPythonInterface(ScriptInterpreterPythonImpl &interpreter)
An error handling class.
Definition Status.h:118
std::shared_ptr< Dictionary > DictionarySP
std::shared_ptr< Object > ObjectSP
std::shared_ptr< Array > ArraySP
A class that represents a running process on the host machine.
@ eScriptLanguagePython
uint64_t addr_t
Definition lldb-types.h:80
uint64_t tid_t
Definition lldb-types.h:84