58 lines · cpp
1//===----------------------------------------------------------------------===//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-exception6//7//===----------------------------------------------------------------------===//8 9#include "lldb/Host/Config.h"10#include "lldb/Target/Thread.h"11#include "lldb/Utility/Log.h"12#include "lldb/lldb-enumerations.h"13 14#if LLDB_ENABLE_PYTHON15 16// LLDB Python header must be included first17#include "../lldb-python.h"18 19#include "../SWIGPythonBridge.h"20#include "../ScriptInterpreterPythonImpl.h"21#include "ScriptedFrameProviderPythonInterface.h"22#include <optional>23 24using namespace lldb;25using namespace lldb_private;26using namespace lldb_private::python;27using Locker = ScriptInterpreterPythonImpl::Locker;28 29ScriptedFrameProviderPythonInterface::ScriptedFrameProviderPythonInterface(30 ScriptInterpreterPythonImpl &interpreter)31 : ScriptedFrameProviderInterface(), ScriptedPythonInterface(interpreter) {}32 33llvm::Expected<StructuredData::GenericSP>34ScriptedFrameProviderPythonInterface::CreatePluginObject(35 const llvm::StringRef class_name, lldb::StackFrameListSP input_frames,36 StructuredData::DictionarySP args_sp) {37 if (!input_frames)38 return llvm::createStringError("Invalid frame list");39 40 StructuredDataImpl sd_impl(args_sp);41 return ScriptedPythonInterface::CreatePluginObject(class_name, nullptr,42 input_frames, sd_impl);43}44 45StructuredData::ObjectSP46ScriptedFrameProviderPythonInterface::GetFrameAtIndex(uint32_t index) {47 Status error;48 StructuredData::ObjectSP obj = Dispatch("get_frame_at_index", error, index);49 50 if (!ScriptedInterface::CheckStructuredDataObject(LLVM_PRETTY_FUNCTION, obj,51 error))52 return {};53 54 return obj;55}56 57#endif58