[Lldb-commits] [lldb] [lldb] Introduce ScriptedFrameProvider for real threads (PR #161870)
via lldb-commits
lldb-commits at lists.llvm.org
Fri Oct 31 11:22:15 PDT 2025
================
@@ -0,0 +1,232 @@
+//===-- ScriptedFrameProvider.cpp ----------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "ScriptedFrameProvider.h"
+#include "Plugins/Process/scripted/ScriptedFrame.h"
+#include "lldb/Core/Debugger.h"
+#include "lldb/Core/PluginManager.h"
+#include "lldb/Interpreter/Interfaces/ScriptedFrameProviderInterface.h"
+#include "lldb/Interpreter/ScriptInterpreter.h"
+#include "lldb/Target/Process.h"
+#include "lldb/Target/StackFrame.h"
+#include "lldb/Target/Thread.h"
+#include "lldb/Utility/ScriptedMetadata.h"
+#include "lldb/Utility/Status.h"
+#include "llvm/Support/Error.h"
+#include <cstdint>
+
+using namespace lldb;
+using namespace lldb_private;
+
+void ScriptedFrameProvider::Initialize() {
+ PluginManager::RegisterPlugin(GetPluginNameStatic(),
+ "Provides synthetic frames via scripting",
+ ScriptedFrameProvider::CreateInstance);
+}
+
+void ScriptedFrameProvider::Terminate() {
+ PluginManager::UnregisterPlugin(ScriptedFrameProvider::CreateInstance);
+}
+
+llvm::Expected<lldb::SyntheticFrameProviderSP>
+ScriptedFrameProvider::CreateInstance(lldb::ThreadSP thread_sp) {
+ if (!thread_sp)
+ return llvm::createStringError(
+ "failed to create scripted frame: invalid thread");
+
+ ProcessSP process_sp = thread_sp->GetProcess();
+ if (!process_sp)
+ return nullptr;
+
+ Target &target = process_sp->GetTarget();
+
+ Status error;
+ if (auto descriptor = target.GetScriptedFrameProviderDescriptor()) {
+ if (!descriptor->IsValid())
+ return llvm::createStringError(
+ "failed to create scripted frame: invalid scripted metadata");
+
+ if (!descriptor->AppliesToThread(thread_sp->GetID()))
----------------
jimingham wrote:
As discussed before, this should probably take the `thread_sp` since that allows the descriptor to decide which aspects of the thread to match against.
https://github.com/llvm/llvm-project/pull/161870
More information about the lldb-commits
mailing list