Path: blob/main/contrib/llvm-project/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedThreadPlanPythonInterface.cpp
39688 views
//===-- ScriptedThreadPlanPythonInterface.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/Utility/Log.h"10#include "lldb/lldb-enumerations.h"1112#if LLDB_ENABLE_PYTHON1314// LLDB Python header must be included first15#include "../lldb-python.h"1617#include "../SWIGPythonBridge.h"18#include "../ScriptInterpreterPythonImpl.h"19#include "ScriptedThreadPlanPythonInterface.h"2021using namespace lldb;22using namespace lldb_private;23using namespace lldb_private::python;2425ScriptedThreadPlanPythonInterface::ScriptedThreadPlanPythonInterface(26ScriptInterpreterPythonImpl &interpreter)27: ScriptedThreadPlanInterface(), ScriptedPythonInterface(interpreter) {}2829llvm::Expected<StructuredData::GenericSP>30ScriptedThreadPlanPythonInterface::CreatePluginObject(31const llvm::StringRef class_name, lldb::ThreadPlanSP thread_plan_sp,32const StructuredDataImpl &args_sp) {33return ScriptedPythonInterface::CreatePluginObject(class_name, nullptr,34thread_plan_sp, args_sp);35}3637llvm::Expected<bool>38ScriptedThreadPlanPythonInterface::ExplainsStop(Event *event) {39Status error;40StructuredData::ObjectSP obj = Dispatch("explains_stop", error, event);4142if (!ScriptedInterface::CheckStructuredDataObject(LLVM_PRETTY_FUNCTION, obj,43error)) {44if (!obj)45return false;46return error.ToError();47}4849return obj->GetBooleanValue();50}5152llvm::Expected<bool>53ScriptedThreadPlanPythonInterface::ShouldStop(Event *event) {54Status error;55StructuredData::ObjectSP obj = Dispatch("should_stop", error, event);5657if (!ScriptedInterface::CheckStructuredDataObject(LLVM_PRETTY_FUNCTION, obj,58error)) {59if (!obj)60return false;61return error.ToError();62}6364return obj->GetBooleanValue();65}6667llvm::Expected<bool> ScriptedThreadPlanPythonInterface::IsStale() {68Status error;69StructuredData::ObjectSP obj = Dispatch("is_stale", error);7071if (!ScriptedInterface::CheckStructuredDataObject(LLVM_PRETTY_FUNCTION, obj,72error)) {73if (!obj)74return false;75return error.ToError();76}7778return obj->GetBooleanValue();79}8081lldb::StateType ScriptedThreadPlanPythonInterface::GetRunState() {82Status error;83StructuredData::ObjectSP obj = Dispatch("should_step", error);8485if (!ScriptedInterface::CheckStructuredDataObject(LLVM_PRETTY_FUNCTION, obj,86error))87return lldb::eStateStepping;8889return static_cast<lldb::StateType>(obj->GetUnsignedIntegerValue(90static_cast<uint32_t>(lldb::eStateStepping)));91}9293llvm::Error94ScriptedThreadPlanPythonInterface::GetStopDescription(lldb::StreamSP &stream) {95Status error;96Dispatch("stop_description", error, stream);9798if (error.Fail())99return error.ToError();100101return llvm::Error::success();102}103104#endif105106107