[Lldb-commits] [lldb] 03e81ea - [LLDB] Add a GetTargetSP() accessor to ObjectFileJITDelegate. (NFC) (#215893)
via lldb-commits
lldb-commits at lists.llvm.org
Thu Aug 13 10:57:50 PDT 2026
Author: Adrian Prantl
Date: 2026-08-13T10:57:37-07:00
New Revision: 03e81eabcdb7ef913e5cc0491e9083c2b31fcb39
URL: https://github.com/llvm/llvm-project/commit/03e81eabcdb7ef913e5cc0491e9083c2b31fcb39
DIFF: https://github.com/llvm/llvm-project/commit/03e81eabcdb7ef913e5cc0491e9083c2b31fcb39.diff
LOG: [LLDB] Add a GetTargetSP() accessor to ObjectFileJITDelegate. (NFC) (#215893)
This is needed to implement the Swift REPL and potentially generally
useful to other expression evaluators.
Added:
Modified:
lldb/include/lldb/Expression/IRExecutionUnit.h
lldb/include/lldb/Expression/ObjectFileJIT.h
lldb/source/Expression/ObjectFileJIT.cpp
Removed:
################################################################################
diff --git a/lldb/include/lldb/Expression/IRExecutionUnit.h b/lldb/include/lldb/Expression/IRExecutionUnit.h
index 10bd1a0f46cf0..5832029cd2ffb 100644
--- a/lldb/include/lldb/Expression/IRExecutionUnit.h
+++ b/lldb/include/lldb/Expression/IRExecutionUnit.h
@@ -100,6 +100,8 @@ class IRExecutionUnit : public std::enable_shared_from_this<IRExecutionUnit>,
ArchSpec GetArchitecture() override;
+ lldb::TargetSP GetTargetSP() override { return GetTarget(); }
+
lldb::ModuleSP GetJITModule();
lldb::addr_t FindSymbol(ConstString name, bool &missing_weak);
diff --git a/lldb/include/lldb/Expression/ObjectFileJIT.h b/lldb/include/lldb/Expression/ObjectFileJIT.h
index b4ba88afa4f11..61e364fda4240 100644
--- a/lldb/include/lldb/Expression/ObjectFileJIT.h
+++ b/lldb/include/lldb/Expression/ObjectFileJIT.h
@@ -28,6 +28,9 @@ class ObjectFileJITDelegate {
virtual void PopulateSectionList(lldb_private::ObjectFile *obj_file,
lldb_private::SectionList §ion_list) = 0;
virtual ArchSpec GetArchitecture() = 0;
+ /// Returns the Target this JIT-compiled code was produced for, or null
+ /// if the delegate that created this ObjectFile no longer exists.
+ virtual lldb::TargetSP GetTargetSP() = 0;
};
class ObjectFileJIT : public ObjectFile {
@@ -92,6 +95,10 @@ class ObjectFileJIT : public ObjectFile {
lldb_private::ArchSpec GetArchitecture() override;
+ /// Returns the Target this JIT-compiled code was produced for, or null
+ /// if the delegate that created this ObjectFile no longer exists.
+ lldb::TargetSP GetTargetSP();
+
lldb_private::UUID GetUUID() override;
uint32_t GetDependentModules(lldb_private::FileSpecList &files) override;
diff --git a/lldb/source/Expression/ObjectFileJIT.cpp b/lldb/source/Expression/ObjectFileJIT.cpp
index 17bc42e8e6a80..b4fe84e868e76 100644
--- a/lldb/source/Expression/ObjectFileJIT.cpp
+++ b/lldb/source/Expression/ObjectFileJIT.cpp
@@ -167,6 +167,12 @@ ArchSpec ObjectFileJIT::GetArchitecture() {
return ArchSpec();
}
+TargetSP ObjectFileJIT::GetTargetSP() {
+ if (ObjectFileJITDelegateSP delegate_sp = m_delegate_wp.lock())
+ return delegate_sp->GetTargetSP();
+ return nullptr;
+}
+
bool ObjectFileJIT::SetLoadAddress(Target &target, lldb::addr_t value,
bool value_is_offset) {
size_t num_loaded_sections = 0;
More information about the lldb-commits
mailing list