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
9#include "../lldb-python.h"
10
13#include "lldb/Utility/Log.h"
15
16#include "../SWIGPythonBridge.h"
19
20using namespace lldb;
21using namespace lldb_private;
22using namespace lldb_private::python;
24
28
29llvm::Expected<StructuredData::GenericSP>
31 llvm::StringRef class_name, ExecutionContext &exe_ctx,
33 return ScriptedPythonInterface::CreatePluginObject(class_name, nullptr,
34 exe_ctx.GetProcessSP());
35}
36
39 lldb::addr_t context) {
42 "create_thread", error, tid, context);
43
44 if (!ScriptedInterface::CheckStructuredDataObject(LLVM_PRETTY_FUNCTION, dict,
45 error))
46 return {};
47
48 return dict;
49}
50
54 Dispatch<StructuredData::ArraySP>("get_thread_info", error);
55
56 if (!ScriptedInterface::CheckStructuredDataObject(LLVM_PRETTY_FUNCTION, arr,
57 error))
58 return {};
59
60 return arr;
61}
62
66
67std::optional<std::string>
70 StructuredData::ObjectSP obj = Dispatch("get_register_data", error, tid);
71
72 if (!ScriptedInterface::CheckStructuredDataObject(LLVM_PRETTY_FUNCTION, obj,
73 error))
74 return {};
75
76 return obj->GetAsString()->GetValue().str();
77}
78
81 StructuredData::ObjectSP obj = Dispatch("does_plugin_report_all_threads", error);
82 if (!ScriptedInterface::CheckStructuredDataObject(LLVM_PRETTY_FUNCTION, obj,
83 error))
84 return {};
85
86 return obj->GetAsBoolean()->GetValue();
87}
88
90 const std::vector<llvm::StringRef> ci_usages = {
91 "settings set target.process.python-os-plugin-path <script-path>",
92 "settings set process.experimental.os-plugin-reports-all-threads [0/1]"};
93 const std::vector<llvm::StringRef> api_usages = {};
95 GetPluginNameStatic(), llvm::StringRef("Mock thread state"),
96 CreateInstance, eScriptLanguagePython, {ci_usages, api_usages});
97}
98
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