[lldb/Interpreter] Remove Interpreter's layering dependency on API - #213754
Merged
medismailben merged 1 commit intoAug 4, 2026
Conversation
|
@llvm/pr-subscribers-lldb Author: Med Ismail Bennani (medismailben) Changes
Patch is 34.88 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/213754.diff 26 Files Affected:
diff --git a/lldb/include/lldb/API/SBAttachInfo.h b/lldb/include/lldb/API/SBAttachInfo.h
index c18655fee77e0..94f687cd56649 100644
--- a/lldb/include/lldb/API/SBAttachInfo.h
+++ b/lldb/include/lldb/API/SBAttachInfo.h
@@ -199,7 +199,7 @@ class LLDB_API SBAttachInfo {
friend class SBTarget;
friend class SBPlatform;
- friend class lldb_private::ScriptInterpreter;
+ friend class lldb_private::ScriptInterpreterBridge;
lldb_private::ProcessAttachInfo &ref();
diff --git a/lldb/include/lldb/API/SBBreakpoint.h b/lldb/include/lldb/API/SBBreakpoint.h
index fe19ba998ea67..95c32fbb583bc 100644
--- a/lldb/include/lldb/API/SBBreakpoint.h
+++ b/lldb/include/lldb/API/SBBreakpoint.h
@@ -171,7 +171,7 @@ class LLDB_API SBBreakpoint {
friend class SBBreakpointName;
friend class SBTarget;
- friend class lldb_private::ScriptInterpreter;
+ friend class lldb_private::ScriptInterpreterBridge;
friend class lldb_private::python::SWIGBridge;
SBBreakpoint(const lldb::BreakpointSP &bp_sp);
diff --git a/lldb/include/lldb/API/SBBreakpointLocation.h b/lldb/include/lldb/API/SBBreakpointLocation.h
index 9b0d4839aca82..3255a51d9269f 100644
--- a/lldb/include/lldb/API/SBBreakpointLocation.h
+++ b/lldb/include/lldb/API/SBBreakpointLocation.h
@@ -24,7 +24,7 @@ class SWIGBridge;
namespace lldb {
class LLDB_API SBBreakpointLocation {
- friend class lldb_private::ScriptInterpreter;
+ friend class lldb_private::ScriptInterpreterBridge;
public:
SBBreakpointLocation();
diff --git a/lldb/include/lldb/API/SBCommandReturnObject.h b/lldb/include/lldb/API/SBCommandReturnObject.h
index b80a11b52c77f..4a7ea3f955305 100644
--- a/lldb/include/lldb/API/SBCommandReturnObject.h
+++ b/lldb/include/lldb/API/SBCommandReturnObject.h
@@ -145,7 +145,7 @@ class LLDB_API SBCommandReturnObject {
friend class lldb_private::CommandPluginInterfaceImplementation;
friend class lldb_private::python::SWIGBridge;
- friend class lldb_private::ScriptInterpreter;
+ friend class lldb_private::ScriptInterpreterBridge;
SBCommandReturnObject(lldb_private::CommandReturnObject &ref);
diff --git a/lldb/include/lldb/API/SBData.h b/lldb/include/lldb/API/SBData.h
index 89a699f2f713a..d2fe33a3e0b83 100644
--- a/lldb/include/lldb/API/SBData.h
+++ b/lldb/include/lldb/API/SBData.h
@@ -154,7 +154,7 @@ class LLDB_API SBData {
friend class SBTarget;
friend class SBValue;
- friend class lldb_private::ScriptInterpreter;
+ friend class lldb_private::ScriptInterpreterBridge;
lldb::DataExtractorSP m_opaque_sp;
};
diff --git a/lldb/include/lldb/API/SBDebugger.h b/lldb/include/lldb/API/SBDebugger.h
index 3e302f121f5ec..bb13413e7a556 100644
--- a/lldb/include/lldb/API/SBDebugger.h
+++ b/lldb/include/lldb/API/SBDebugger.h
@@ -678,7 +678,7 @@ class LLDB_API SBDebugger {
protected:
friend class lldb_private::CommandPluginInterfaceImplementation;
friend class lldb_private::python::SWIGBridge;
- friend class lldb_private::ScriptInterpreter;
+ friend class lldb_private::ScriptInterpreterBridge;
friend class lldb_private::SystemInitializerFull;
SBDebugger(const lldb::DebuggerSP &debugger_sp);
diff --git a/lldb/include/lldb/API/SBError.h b/lldb/include/lldb/API/SBError.h
index dd8c0f939775f..5f2717120006a 100644
--- a/lldb/include/lldb/API/SBError.h
+++ b/lldb/include/lldb/API/SBError.h
@@ -109,7 +109,7 @@ class LLDB_API SBError {
friend class SBValueList;
friend class SBWatchpoint;
- friend class lldb_private::ScriptInterpreter;
+ friend class lldb_private::ScriptInterpreterBridge;
friend class lldb_private::python::SWIGBridge;
SBError(lldb_private::Status &&error);
diff --git a/lldb/include/lldb/API/SBEvent.h b/lldb/include/lldb/API/SBEvent.h
index 85b401ca8cc10..99f13fc90124d 100644
--- a/lldb/include/lldb/API/SBEvent.h
+++ b/lldb/include/lldb/API/SBEvent.h
@@ -74,7 +74,7 @@ class LLDB_API SBEvent {
friend class SBThread;
friend class SBWatchpoint;
- friend class lldb_private::ScriptInterpreter;
+ friend class lldb_private::ScriptInterpreterBridge;
friend class lldb_private::python::SWIGBridge;
SBEvent(lldb::EventSP &event_sp);
diff --git a/lldb/include/lldb/API/SBExecutionContext.h b/lldb/include/lldb/API/SBExecutionContext.h
index 20584271ff36c..3b2d0e0aa139d 100644
--- a/lldb/include/lldb/API/SBExecutionContext.h
+++ b/lldb/include/lldb/API/SBExecutionContext.h
@@ -57,7 +57,7 @@ class LLDB_API SBExecutionContext {
protected:
friend class SBInstructionList;
friend class lldb_private::python::SWIGBridge;
- friend class lldb_private::ScriptInterpreter;
+ friend class lldb_private::ScriptInterpreterBridge;
lldb_private::ExecutionContextRef *get() const;
diff --git a/lldb/include/lldb/API/SBFrame.h b/lldb/include/lldb/API/SBFrame.h
index eaf9a4bfece96..7094ce3ad8fb7 100644
--- a/lldb/include/lldb/API/SBFrame.h
+++ b/lldb/include/lldb/API/SBFrame.h
@@ -231,7 +231,7 @@ class LLDB_API SBFrame {
friend class SBThread;
friend class SBValue;
- friend class lldb_private::ScriptInterpreter;
+ friend class lldb_private::ScriptInterpreterBridge;
friend class lldb_private::python::SWIGBridge;
friend class lldb_private::lua::SWIGBridge;
diff --git a/lldb/include/lldb/API/SBFrameList.h b/lldb/include/lldb/API/SBFrameList.h
index 0039ffb1f863f..ef38510d9fa66 100644
--- a/lldb/include/lldb/API/SBFrameList.h
+++ b/lldb/include/lldb/API/SBFrameList.h
@@ -78,7 +78,7 @@ class LLDB_API SBFrameList {
friend class lldb_private::python::SWIGBridge;
friend class lldb_private::lua::SWIGBridge;
- friend class lldb_private::ScriptInterpreter;
+ friend class lldb_private::ScriptInterpreterBridge;
private:
SBFrameList(const lldb::StackFrameListSP &frame_list_sp);
diff --git a/lldb/include/lldb/API/SBLaunchInfo.h b/lldb/include/lldb/API/SBLaunchInfo.h
index 06e72efc30f9f..043a9a54734a1 100644
--- a/lldb/include/lldb/API/SBLaunchInfo.h
+++ b/lldb/include/lldb/API/SBLaunchInfo.h
@@ -210,7 +210,7 @@ class LLDB_API SBLaunchInfo {
friend class SBPlatform;
friend class SBTarget;
- friend class lldb_private::ScriptInterpreter;
+ friend class lldb_private::ScriptInterpreterBridge;
const lldb_private::ProcessLaunchInfo &ref() const;
void set_ref(const lldb_private::ProcessLaunchInfo &info);
diff --git a/lldb/include/lldb/API/SBMemoryRegionInfo.h b/lldb/include/lldb/API/SBMemoryRegionInfo.h
index dc5aa0858e1e3..034279f6e5593 100644
--- a/lldb/include/lldb/API/SBMemoryRegionInfo.h
+++ b/lldb/include/lldb/API/SBMemoryRegionInfo.h
@@ -132,7 +132,7 @@ class LLDB_API SBMemoryRegionInfo {
friend class SBProcess;
friend class SBMemoryRegionInfoList;
friend class SBSaveCoreOptions;
- friend class lldb_private::ScriptInterpreter;
+ friend class lldb_private::ScriptInterpreterBridge;
lldb_private::MemoryRegionInfo &ref();
diff --git a/lldb/include/lldb/API/SBStream.h b/lldb/include/lldb/API/SBStream.h
index 21f9d21e0e717..1ba375b600df6 100644
--- a/lldb/include/lldb/API/SBStream.h
+++ b/lldb/include/lldb/API/SBStream.h
@@ -108,7 +108,7 @@ class LLDB_API SBStream {
friend class SBValue;
friend class SBWatchpoint;
- friend class lldb_private::ScriptInterpreter;
+ friend class lldb_private::ScriptInterpreterBridge;
lldb_private::Stream *operator->();
diff --git a/lldb/include/lldb/API/SBSymbolContext.h b/lldb/include/lldb/API/SBSymbolContext.h
index 19f29c629d094..5b644cb1449f1 100644
--- a/lldb/include/lldb/API/SBSymbolContext.h
+++ b/lldb/include/lldb/API/SBSymbolContext.h
@@ -66,7 +66,7 @@ class LLDB_API SBSymbolContext {
friend class SBTarget;
friend class SBSymbolContextList;
- friend class lldb_private::ScriptInterpreter;
+ friend class lldb_private::ScriptInterpreterBridge;
friend class lldb_private::python::SWIGBridge;
SBSymbolContext(const lldb_private::SymbolContext &sc_ptr);
@@ -81,7 +81,7 @@ class LLDB_API SBSymbolContext {
lldb_private::SymbolContext *get() const;
- friend class lldb_private::ScriptInterpreter;
+ friend class lldb_private::ScriptInterpreterBridge;
private:
std::unique_ptr<lldb_private::SymbolContext> m_opaque_up;
diff --git a/lldb/include/lldb/API/SBTarget.h b/lldb/include/lldb/API/SBTarget.h
index fd795c843330e..84cbcfb4e69d2 100644
--- a/lldb/include/lldb/API/SBTarget.h
+++ b/lldb/include/lldb/API/SBTarget.h
@@ -1067,7 +1067,7 @@ class LLDB_API SBTarget {
friend class lldb_private::python::SWIGBridge;
friend class lldb_private::lua::SWIGBridge;
- friend class lldb_private::ScriptInterpreter;
+ friend class lldb_private::ScriptInterpreterBridge;
// Constructors are private, use static Target::Create function to create an
// instance of this class.
diff --git a/lldb/include/lldb/API/SBThread.h b/lldb/include/lldb/API/SBThread.h
index 97d3b838492fb..a5edb529c2c6a 100644
--- a/lldb/include/lldb/API/SBThread.h
+++ b/lldb/include/lldb/API/SBThread.h
@@ -256,7 +256,7 @@ class LLDB_API SBThread {
friend class SBThreadPlan;
friend class SBTrace;
- friend class lldb_private::ScriptInterpreter;
+ friend class lldb_private::ScriptInterpreterBridge;
friend class lldb_private::python::SWIGBridge;
SBThread(const lldb::ThreadSP &lldb_object_sp);
diff --git a/lldb/include/lldb/API/SBValue.h b/lldb/include/lldb/API/SBValue.h
index 9d746f74c9b09..68ae063295418 100644
--- a/lldb/include/lldb/API/SBValue.h
+++ b/lldb/include/lldb/API/SBValue.h
@@ -532,7 +532,7 @@ class LLDB_API SBValue {
bool use_synthetic, const char *name);
protected:
- friend class lldb_private::ScriptInterpreter;
+ friend class lldb_private::ScriptInterpreterBridge;
private:
typedef std::shared_ptr<lldb_private::ValueImpl> ValueImplSP;
diff --git a/lldb/include/lldb/Interpreter/ScriptInterpreter.h b/lldb/include/lldb/Interpreter/ScriptInterpreter.h
index 925b7b08e3291..7ad530b3233f2 100644
--- a/lldb/include/lldb/Interpreter/ScriptInterpreter.h
+++ b/lldb/include/lldb/Interpreter/ScriptInterpreter.h
@@ -9,21 +9,6 @@
#ifndef LLDB_INTERPRETER_SCRIPTINTERPRETER_H
#define LLDB_INTERPRETER_SCRIPTINTERPRETER_H
-#include "lldb/API/SBAttachInfo.h"
-#include "lldb/API/SBBreakpoint.h"
-#include "lldb/API/SBBreakpointLocation.h"
-#include "lldb/API/SBCommandReturnObject.h"
-#include "lldb/API/SBData.h"
-#include "lldb/API/SBDebugger.h"
-#include "lldb/API/SBError.h"
-#include "lldb/API/SBEvent.h"
-#include "lldb/API/SBExecutionContext.h"
-#include "lldb/API/SBFrameList.h"
-#include "lldb/API/SBLaunchInfo.h"
-#include "lldb/API/SBMemoryRegionInfo.h"
-#include "lldb/API/SBStream.h"
-#include "lldb/API/SBSymbolContext.h"
-#include "lldb/API/SBThread.h"
#include "lldb/Breakpoint/BreakpointOptions.h"
#include "lldb/Core/PluginInterface.h"
#include "lldb/Core/SearchFilter.h"
@@ -37,7 +22,6 @@
#include "lldb/Interpreter/Interfaces/ScriptedProcessInterface.h"
#include "lldb/Interpreter/Interfaces/ScriptedThreadInterface.h"
#include "lldb/Interpreter/ScriptObject.h"
-#include "lldb/Symbol/SymbolContext.h"
#include "lldb/Utility/Broadcaster.h"
#include "lldb/Utility/Status.h"
#include "lldb/Utility/StructuredData.h"
@@ -531,54 +515,6 @@ class ScriptInterpreter : public PluginInterface {
virtual SanitizedScriptingModuleName
GetSanitizedScriptingModuleName(llvm::StringRef name);
- lldb::DataExtractorSP
- GetDataExtractorFromSBData(const lldb::SBData &data) const;
-
- Status GetStatusFromSBError(const lldb::SBError &error) const;
-
- Event *GetOpaqueTypeFromSBEvent(const lldb::SBEvent &event) const;
-
- lldb::StreamSP GetOpaqueTypeFromSBStream(const lldb::SBStream &stream) const;
-
- lldb::ThreadSP GetOpaqueTypeFromSBThread(const lldb::SBThread &exe_ctx) const;
-
- lldb::StackFrameSP GetOpaqueTypeFromSBFrame(const lldb::SBFrame &frame) const;
-
- SymbolContext
- GetOpaqueTypeFromSBSymbolContext(const lldb::SBSymbolContext &sym_ctx) const;
-
- lldb::BreakpointSP
- GetOpaqueTypeFromSBBreakpoint(const lldb::SBBreakpoint &breakpoint) const;
-
- lldb::BreakpointLocationSP GetOpaqueTypeFromSBBreakpointLocation(
- const lldb::SBBreakpointLocation &break_loc) const;
-
- CommandReturnObject *GetOpaqueTypeFromSBCommandReturnObject(
- const lldb::SBCommandReturnObject &cmd_retobj) const;
-
- lldb::DebuggerSP
- GetOpaqueTypeFromSBDebugger(const lldb::SBDebugger &debugger) const;
-
- lldb::ProcessAttachInfoSP
- GetOpaqueTypeFromSBAttachInfo(const lldb::SBAttachInfo &attach_info) const;
-
- lldb::ProcessLaunchInfoSP
- GetOpaqueTypeFromSBLaunchInfo(const lldb::SBLaunchInfo &launch_info) const;
-
- std::optional<MemoryRegionInfo> GetOpaqueTypeFromSBMemoryRegionInfo(
- const lldb::SBMemoryRegionInfo &mem_region) const;
-
- lldb::ExecutionContextRefSP GetOpaqueTypeFromSBExecutionContext(
- const lldb::SBExecutionContext &exe_ctx) const;
-
- lldb::StackFrameListSP
- GetOpaqueTypeFromSBFrameList(const lldb::SBFrameList &exe_ctx) const;
-
- lldb::ValueObjectSP
- GetOpaqueTypeFromSBValue(const lldb::SBValue &value) const;
-
- lldb::TargetSP GetOpaqueTypeFromSBTarget(const lldb::SBTarget &target) const;
-
/// Get the debugger associated with this script interpreter.
Debugger &GetDebugger() { return m_debugger; }
const Debugger &GetDebugger() const { return m_debugger; }
diff --git a/lldb/include/lldb/Utility/StreamString.h b/lldb/include/lldb/Utility/StreamString.h
index 1a6444fc29c24..5fcda832d4cf8 100644
--- a/lldb/include/lldb/Utility/StreamString.h
+++ b/lldb/include/lldb/Utility/StreamString.h
@@ -47,7 +47,7 @@ class StreamString : public Stream {
void FillLastLineToColumn(uint32_t column, char fill_char);
protected:
- friend class ScriptInterpreter;
+ friend class ScriptInterpreterBridge;
std::string m_packet;
size_t WriteImpl(const void *s, size_t length) override;
diff --git a/lldb/include/lldb/lldb-forward.h b/lldb/include/lldb/lldb-forward.h
index 2a4044e9a9b88..47362915d6a56 100644
--- a/lldb/include/lldb/lldb-forward.h
+++ b/lldb/include/lldb/lldb-forward.h
@@ -188,6 +188,7 @@ class RichManglingContext;
class SaveCoreOptions;
class Scalar;
class ScriptInterpreter;
+class ScriptInterpreterBridge;
class ScriptInterpreterLocker;
class ScriptedFrameInterface;
class ScriptedFrameProviderInterface;
diff --git a/lldb/source/API/CMakeLists.txt b/lldb/source/API/CMakeLists.txt
index 83ecb428d8ea4..d3a417a260270 100644
--- a/lldb/source/API/CMakeLists.txt
+++ b/lldb/source/API/CMakeLists.txt
@@ -116,6 +116,7 @@ add_lldb_library(liblldb SHARED ${option_framework}
SBVariablesOptions.cpp
SBWatchpoint.cpp
SBWatchpointOptions.cpp
+ ScriptInterpreterBridge.cpp
SystemInitializerFull.cpp
ADDITIONAL_HEADER_DIRS
diff --git a/lldb/source/API/ScriptInterpreterBridge.cpp b/lldb/source/API/ScriptInterpreterBridge.cpp
new file mode 100644
index 0000000000000..2b0ae4aa6d7d6
--- /dev/null
+++ b/lldb/source/API/ScriptInterpreterBridge.cpp
@@ -0,0 +1,147 @@
+//===-- ScriptInterpreterBridge.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 "ScriptInterpreterBridge.h"
+#include "API/SBCommandReturnObjectImpl.h"
+#include "lldb/API/SBAttachInfo.h"
+#include "lldb/API/SBBreakpoint.h"
+#include "lldb/API/SBBreakpointLocation.h"
+#include "lldb/API/SBCommandReturnObject.h"
+#include "lldb/API/SBData.h"
+#include "lldb/API/SBDebugger.h"
+#include "lldb/API/SBError.h"
+#include "lldb/API/SBEvent.h"
+#include "lldb/API/SBExecutionContext.h"
+#include "lldb/API/SBFrame.h"
+#include "lldb/API/SBFrameList.h"
+#include "lldb/API/SBLaunchInfo.h"
+#include "lldb/API/SBMemoryRegionInfo.h"
+#include "lldb/API/SBStream.h"
+#include "lldb/API/SBSymbolContext.h"
+#include "lldb/API/SBTarget.h"
+#include "lldb/API/SBThread.h"
+#include "lldb/API/SBValue.h"
+#include "lldb/Host/ProcessLaunchInfo.h"
+#include "lldb/Interpreter/CommandReturnObject.h"
+#include "lldb/Target/ExecutionContext.h"
+#include "lldb/Utility/StreamString.h"
+#include "lldb/ValueObject/ValueObject.h"
+
+using namespace lldb;
+using namespace lldb_private;
+
+lldb::DataExtractorSP
+ScriptInterpreterBridge::GetDataExtractor(const lldb::SBData &data) {
+ return data.m_opaque_sp;
+}
+
+lldb::BreakpointSP
+ScriptInterpreterBridge::GetBreakpoint(const lldb::SBBreakpoint &breakpoint) {
+ return breakpoint.m_opaque_wp.lock();
+}
+
+lldb::BreakpointLocationSP ScriptInterpreterBridge::GetBreakpointLocation(
+ const lldb::SBBreakpointLocation &break_loc) {
+ return break_loc.m_opaque_wp.lock();
+}
+
+CommandReturnObject *ScriptInterpreterBridge::GetCommandReturnObject(
+ const lldb::SBCommandReturnObject &cmd_retobj) {
+ return cmd_retobj.m_opaque_up->get();
+}
+
+lldb::DebuggerSP
+ScriptInterpreterBridge::GetDebugger(const lldb::SBDebugger &debugger) {
+ return debugger.m_opaque_sp;
+}
+
+lldb::ProcessAttachInfoSP ScriptInterpreterBridge::GetProcessAttachInfo(
+ const lldb::SBAttachInfo &attach_info) {
+ return attach_info.m_opaque_sp;
+}
+
+lldb::ProcessLaunchInfoSP ScriptInterpreterBridge::GetProcessLaunchInfo(
+ const lldb::SBLaunchInfo &launch_info) {
+ return std::make_shared<ProcessLaunchInfo>(
+ *reinterpret_cast<ProcessLaunchInfo *>(launch_info.m_opaque_sp.get()));
+}
+
+Status ScriptInterpreterBridge::GetStatus(const lldb::SBError &error) {
+ if (error.m_opaque_up)
+ return error.m_opaque_up->Clone();
+
+ return Status();
+}
+
+lldb::ThreadSP
+ScriptInterpreterBridge::GetThread(const lldb::SBThread &thread) {
+ if (thread.m_opaque_sp)
+ return thread.m_opaque_sp->GetThreadSP();
+ return nullptr;
+}
+
+lldb::StackFrameSP
+ScriptInterpreterBridge::GetStackFrame(const lldb::SBFrame &frame) {
+ if (frame.m_opaque_sp)
+ return frame.m_opaque_sp->GetFrameSP();
+ return nullptr;
+}
+
+Event *ScriptInterpreterBridge::GetEvent(const lldb::SBEvent &event) {
+ return event.m_opaque_ptr;
+}
+
+lldb::StreamSP
+ScriptInterpreterBridge::GetStream(const lldb::SBStream &stream) {
+ if (stream.m_opaque_up) {
+ lldb::StreamSP s = std::make_shared<lldb_private::StreamString>();
+ *s << reinterpret_cast<StreamString *>(stream.m_opaque_up.get())->m_packet;
+ return s;
+ }
+
+ return nullptr;
+}
+
+SymbolContext ScriptInterpreterBridge::GetSymbolContext(
+ const lldb::SBSymbolContext &sb_sym_ctx) {
+ if (sb_sym_ctx.m_opaque_up)
+ return *sb_sym_ctx.m_opaque_up;
+ return {};
+}
+
+std::optional<lldb_private::MemoryRegionInfo>
+ScriptInterpreterBridge::GetMemoryRegionInfo(
+ const lldb::SBMemoryRegionInfo &mem_region) {
+ if (!mem_region.m_opaque_up)
+ return std::nullopt;
+ return *mem_region.m_opaque_up.get();
+}
+
+lldb::ExecutionContextRefSP ScriptInterpreterBridge::GetExecutionContextRef(
+ const lldb::SBExecutionContext &exe_ctx) {
+ return exe_ctx.m_exe_ctx_sp;
+}
+
+lldb::StackFrameListSP ScriptInterpreterBridge::GetStackFrameList(
+ const lldb::SBFrameList &frame_list) {
+ return frame_list.m_opaque_sp;
+}
+
+lldb::TargetSP
+ScriptInterpreterBridge::GetTarget(const lldb::SBTarget &target) {
+ return target.m_opaque_sp;
+}
+
+lldb::ValueObjectSP
+ScriptInterpreterBridge::GetValueObject(const lldb::SBValue &value) {
+ if (!value.m_opaque_sp)
+ return lldb::ValueObjectSP();
+
+ lldb_private::ValueLocker locker;
+ return locker.GetLockedSP(*value.m_opaque_sp);
+}
diff --git a/lldb/source/API/ScriptInterpreterBridge.h b/lldb/source/API/ScriptInterpreterBridge.h
new file mode 100644
index 0000000000000..d0dbb049a6aff
--- /dev/null
+++ b/lldb/source/API/ScriptInterpreterBridge.h
@@ -0,0 +1,78 @@
+//===-- ScriptInterpreterBridge.h ------------------------------*- C++ -*-===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLDB_SOURCE_API_SCRIPTINTERPRETERBRIDGE_H
+#define LLDB_SOURCE_API_SCRIPTINTERPRETERBRIDGE_H
+
+#include "lldb/API/SBDefines.h"
+#include "lldb/Symbol/SymbolContext.h"
+#include "lldb/Target/MemoryRegionInfo.h"
+#include "lldb/Utility/Status.h"
+#include "lldb/lldb-forward.h"
+#include <optional>
+
+namespace lldb_private {
+
+class CommandReturnObject;
+class Event;
+
+/// Unwraps the opaque internal object hel...
[truncated]
|
bulbazord
approved these changes
Aug 3, 2026
bulbazord
left a comment
Member
There was a problem hiding this comment.
lgtm modulo a few tiny things. :)
ScriptInterpreter reached into the private state of 18 SB classes to unwrap opaque objects for scripting callbacks, pulling lldb/API/*.h into lldbInterpreter's public header and requiring friend access from a class that conceptually sits below the API layer. Move that unwrapping into a new ScriptInterpreterBridge class in source/API, which is where reaching into an SB class's own internals belongs. Drop the one remaining stray API include (an unused SBValueList.h in ScriptedFrameInterface.h) and enable ALLOWED_INTERNAL_DEPENDENCIES on lldbInterpreter, the same configure-time layering check already enforced on lldbUtility and lldbHost. lldbAPI is deliberately left off that allowlist, so any future #include "lldb/API/..." in lldbInterpreter now fails the build immediately instead of silently working via macOS's static linking. Signed-off-by: Med Ismail Bennani <ismail@bennani.ma>
medismailben
force-pushed
the
interpreter-layering-violation
branch
from
August 4, 2026 01:17
4c962ae to
3103e09
Compare
tfzee
pushed a commit
to tfzee/llvm-project
that referenced
this pull request
Aug 6, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ScriptInterpreterreached into the private state of 18 SB classes to unwrap opaque objects for scripting callbacks, pullinglldb/API/*.hintolldbInterpreter's public header and requiring friend access from a class that conceptually sits below theAPIlayer. Move that unwrapping into a newScriptInterpreterBridgeclass insource/API, which is where reaching into an SB class's own internals belongs.