Path: blob/main/contrib/llvm-project/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/OperatingSystemPythonInterface.cpp
39688 views
//===-- ScriptedThreadPythonInterface.cpp ---------------------------------===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//78#include "lldb/Host/Config.h"9#include "lldb/Target/ExecutionContext.h"10#include "lldb/Utility/Log.h"11#include "lldb/lldb-enumerations.h"1213#if LLDB_ENABLE_PYTHON1415// LLDB Python header must be included first16#include "../lldb-python.h"1718#include "../SWIGPythonBridge.h"19#include "../ScriptInterpreterPythonImpl.h"20#include "OperatingSystemPythonInterface.h"2122using namespace lldb;23using namespace lldb_private;24using namespace lldb_private::python;25using Locker = ScriptInterpreterPythonImpl::Locker;2627OperatingSystemPythonInterface::OperatingSystemPythonInterface(28ScriptInterpreterPythonImpl &interpreter)29: OperatingSystemInterface(), ScriptedThreadPythonInterface(interpreter) {}3031llvm::Expected<StructuredData::GenericSP>32OperatingSystemPythonInterface::CreatePluginObject(33llvm::StringRef class_name, ExecutionContext &exe_ctx,34StructuredData::DictionarySP args_sp, StructuredData::Generic *script_obj) {35return ScriptedPythonInterface::CreatePluginObject(class_name, nullptr,36exe_ctx.GetProcessSP());37}3839StructuredData::DictionarySP40OperatingSystemPythonInterface::CreateThread(lldb::tid_t tid,41lldb::addr_t context) {42Status error;43StructuredData::DictionarySP dict = Dispatch<StructuredData::DictionarySP>(44"create_thread", error, tid, context);4546if (!ScriptedInterface::CheckStructuredDataObject(LLVM_PRETTY_FUNCTION, dict,47error))48return {};4950return dict;51}5253StructuredData::ArraySP OperatingSystemPythonInterface::GetThreadInfo() {54Status error;55StructuredData::ArraySP arr =56Dispatch<StructuredData::ArraySP>("get_thread_info", error);5758if (!ScriptedInterface::CheckStructuredDataObject(LLVM_PRETTY_FUNCTION, arr,59error))60return {};6162return arr;63}6465StructuredData::DictionarySP OperatingSystemPythonInterface::GetRegisterInfo() {66return ScriptedThreadPythonInterface::GetRegisterInfo();67}6869std::optional<std::string>70OperatingSystemPythonInterface::GetRegisterContextForTID(lldb::tid_t tid) {71Status error;72StructuredData::ObjectSP obj = Dispatch("get_register_data", error, tid);7374if (!ScriptedInterface::CheckStructuredDataObject(LLVM_PRETTY_FUNCTION, obj,75error))76return {};7778return obj->GetAsString()->GetValue().str();79}8081#endif828384