From a52054cfa29d665c43141c66c20a7b8f7a96b546 Mon Sep 17 00:00:00 2001 From: Alex Langford Date: Tue, 28 Mar 2023 14:00:13 -0700 Subject: [PATCH] [lldb] Move ObjectFileJIT to lldbExpression In the spirit of not having lldbExpression rely on plugins, this move makes the most sense. ObjectFileJIT is not really a "plugin" in the sense that without it, expression evaluation doesn't work at all. This is different than something like ObjectFileELF where lldb can still technically debug non-ELF targets without it. For that reason, moving ObjectFileJIT into Expression where it will be used in conjunction with IRExecutionUnit makes the most sense. Differential Revision: https://reviews.llvm.org/D147084 --- lldb/include/lldb/Expression/IRExecutionUnit.h | 2 +- .../lldb/Expression}/ObjectFileJIT.h | 34 ++++++++++++++++------ lldb/include/lldb/Symbol/ObjectFile.h | 19 ------------ lldb/source/Expression/CMakeLists.txt | 4 +-- lldb/source/Expression/IRExecutionUnit.cpp | 2 +- .../JIT => Expression}/ObjectFileJIT.cpp | 17 +++-------- lldb/source/Plugins/ObjectFile/CMakeLists.txt | 1 - lldb/source/Plugins/ObjectFile/JIT/CMakeLists.txt | 11 ------- 8 files changed, 33 insertions(+), 57 deletions(-) rename lldb/{source/Plugins/ObjectFile/JIT => include/lldb/Expression}/ObjectFileJIT.h (76%) rename lldb/source/{Plugins/ObjectFile/JIT => Expression}/ObjectFileJIT.cpp (94%) delete mode 100644 lldb/source/Plugins/ObjectFile/JIT/CMakeLists.txt diff --git a/lldb/include/lldb/Expression/IRExecutionUnit.h b/lldb/include/lldb/Expression/IRExecutionUnit.h index ef53ca5..58f12bf 100644 --- a/lldb/include/lldb/Expression/IRExecutionUnit.h +++ b/lldb/include/lldb/Expression/IRExecutionUnit.h @@ -18,7 +18,7 @@ #include "llvm/IR/Module.h" #include "lldb/Expression/IRMemoryMap.h" -#include "lldb/Symbol/ObjectFile.h" +#include "lldb/Expression/ObjectFileJIT.h" #include "lldb/Symbol/SymbolContext.h" #include "lldb/Utility/DataBufferHeap.h" #include "lldb/lldb-forward.h" diff --git a/lldb/source/Plugins/ObjectFile/JIT/ObjectFileJIT.h b/lldb/include/lldb/Expression/ObjectFileJIT.h similarity index 76% rename from lldb/source/Plugins/ObjectFile/JIT/ObjectFileJIT.h rename to lldb/include/lldb/Expression/ObjectFileJIT.h index 91fdd20..7e50340 100644 --- a/lldb/source/Plugins/ObjectFile/JIT/ObjectFileJIT.h +++ b/lldb/include/lldb/Expression/ObjectFileJIT.h @@ -6,15 +6,31 @@ // //===----------------------------------------------------------------------===// -#ifndef LLDB_SOURCE_PLUGINS_OBJECTFILE_JIT_OBJECTFILEJIT_H -#define LLDB_SOURCE_PLUGINS_OBJECTFILE_JIT_OBJECTFILEJIT_H +#ifndef LLDB_EXPRESSION_OBJECTFILEJIT_H +#define LLDB_EXPRESSION_OBJECTFILEJIT_H #include "lldb/Core/Address.h" +#include "lldb/Core/Section.h" #include "lldb/Symbol/ObjectFile.h" +#include "lldb/Symbol/Symtab.h" +#include "lldb/Utility/ArchSpec.h" -// This class needs to be hidden as eventually belongs in a plugin that -// will export the ObjectFile protocol -class ObjectFileJIT : public lldb_private::ObjectFile { +namespace lldb_private { + +class ObjectFileJITDelegate { +public: + ObjectFileJITDelegate() = default; + virtual ~ObjectFileJITDelegate() = default; + virtual lldb::ByteOrder GetByteOrder() const = 0; + virtual uint32_t GetAddressByteSize() const = 0; + virtual void PopulateSymtab(lldb_private::ObjectFile *obj_file, + lldb_private::Symtab &symtab) = 0; + virtual void PopulateSectionList(lldb_private::ObjectFile *obj_file, + lldb_private::SectionList §ion_list) = 0; + virtual ArchSpec GetArchitecture() = 0; +}; + +class ObjectFileJIT : public ObjectFile { public: ObjectFileJIT(const lldb::ModuleSP &module_sp, const lldb::ObjectFileJITDelegateSP &delegate_sp); @@ -85,9 +101,8 @@ public: lldb::offset_t section_offset, void *dst, size_t dst_len) override; - size_t - ReadSectionData(lldb_private::Section *section, - lldb_private::DataExtractor §ion_data) override; + size_t ReadSectionData(lldb_private::Section *section, + lldb_private::DataExtractor §ion_data) override; lldb_private::Address GetEntryPointAddress() override; @@ -103,5 +118,6 @@ public: protected: lldb::ObjectFileJITDelegateWP m_delegate_wp; }; +} // namespace lldb_private -#endif // LLDB_SOURCE_PLUGINS_OBJECTFILE_JIT_OBJECTFILEJIT_H +#endif // LLDB_EXPRESSION_OBJECTFILEJIT_H diff --git a/lldb/include/lldb/Symbol/ObjectFile.h b/lldb/include/lldb/Symbol/ObjectFile.h index e2e0623..8f7806f 100644 --- a/lldb/include/lldb/Symbol/ObjectFile.h +++ b/lldb/include/lldb/Symbol/ObjectFile.h @@ -25,25 +25,6 @@ namespace lldb_private { -class ObjectFileJITDelegate { -public: - ObjectFileJITDelegate() = default; - - virtual ~ObjectFileJITDelegate() = default; - - virtual lldb::ByteOrder GetByteOrder() const = 0; - - virtual uint32_t GetAddressByteSize() const = 0; - - virtual void PopulateSymtab(lldb_private::ObjectFile *obj_file, - lldb_private::Symtab &symtab) = 0; - - virtual void PopulateSectionList(lldb_private::ObjectFile *obj_file, - lldb_private::SectionList §ion_list) = 0; - - virtual ArchSpec GetArchitecture() = 0; -}; - /// \class ObjectFile ObjectFile.h "lldb/Symbol/ObjectFile.h" /// A plug-in interface definition class for object file parsers. /// diff --git a/lldb/source/Expression/CMakeLists.txt b/lldb/source/Expression/CMakeLists.txt index 7e4fd81..4194cfe 100644 --- a/lldb/source/Expression/CMakeLists.txt +++ b/lldb/source/Expression/CMakeLists.txt @@ -1,5 +1,5 @@ # TODO: Add property `NO_PLUGIN_DEPENDENCIES` to lldbExpression -add_lldb_library(lldbExpression +add_lldb_library(lldbExpression NO_PLUGIN_DEPENDENCIES DiagnosticManager.cpp DWARFExpression.cpp DWARFExpressionList.cpp @@ -11,6 +11,7 @@ add_lldb_library(lldbExpression IRMemoryMap.cpp LLVMUserExpression.cpp Materializer.cpp + ObjectFileJIT.cpp REPL.cpp UserExpression.cpp UtilityFunction.cpp @@ -25,7 +26,6 @@ add_lldb_library(lldbExpression lldbSymbol lldbTarget lldbUtility - lldbPluginObjectFileJIT LINK_COMPONENTS Core diff --git a/lldb/source/Expression/IRExecutionUnit.cpp b/lldb/source/Expression/IRExecutionUnit.cpp index f3cf0f6..5a4ba04 100644 --- a/lldb/source/Expression/IRExecutionUnit.cpp +++ b/lldb/source/Expression/IRExecutionUnit.cpp @@ -21,6 +21,7 @@ #include "lldb/Core/Module.h" #include "lldb/Core/Section.h" #include "lldb/Expression/IRExecutionUnit.h" +#include "lldb/Expression/ObjectFileJIT.h" #include "lldb/Host/HostInfo.h" #include "lldb/Symbol/CompileUnit.h" #include "lldb/Symbol/SymbolContext.h" @@ -36,7 +37,6 @@ #include "lldb/Utility/LLDBLog.h" #include "lldb/Utility/Log.h" -#include "lldb/../../source/Plugins/ObjectFile/JIT/ObjectFileJIT.h" #include using namespace lldb_private; diff --git a/lldb/source/Plugins/ObjectFile/JIT/ObjectFileJIT.cpp b/lldb/source/Expression/ObjectFileJIT.cpp similarity index 94% rename from lldb/source/Plugins/ObjectFile/JIT/ObjectFileJIT.cpp rename to lldb/source/Expression/ObjectFileJIT.cpp index 2ea83e4..106652d 100644 --- a/lldb/source/Plugins/ObjectFile/JIT/ObjectFileJIT.cpp +++ b/lldb/source/Expression/ObjectFileJIT.cpp @@ -8,17 +8,12 @@ #include "llvm/ADT/StringRef.h" -#include "ObjectFileJIT.h" -#include "lldb/Core/Debugger.h" #include "lldb/Core/FileSpecList.h" #include "lldb/Core/Module.h" #include "lldb/Core/ModuleSpec.h" #include "lldb/Core/PluginManager.h" #include "lldb/Core/Section.h" -#include "lldb/Core/StreamFile.h" -#include "lldb/Host/Host.h" -#include "lldb/Symbol/ObjectFile.h" -#include "lldb/Target/Platform.h" +#include "lldb/Expression/ObjectFileJIT.h" #include "lldb/Target/Process.h" #include "lldb/Target/SectionLoadList.h" #include "lldb/Target/Target.h" @@ -27,8 +22,6 @@ #include "lldb/Utility/DataBufferHeap.h" #include "lldb/Utility/FileSpec.h" #include "lldb/Utility/Log.h" -#include "lldb/Utility/RangeMap.h" -#include "lldb/Utility/StreamString.h" #include "lldb/Utility/Timer.h" #include "lldb/Utility/UUID.h" @@ -39,8 +32,6 @@ using namespace lldb; using namespace lldb_private; -LLDB_PLUGIN_DEFINE(ObjectFileJIT) - char ObjectFileJIT::ID; void ObjectFileJIT::Initialize() { @@ -217,9 +208,9 @@ size_t ObjectFileJIT::ReadSectionData(lldb_private::Section *section, return 0; } -size_t ObjectFileJIT::ReadSectionData( - lldb_private::Section *section, - lldb_private::DataExtractor §ion_data) { +size_t +ObjectFileJIT::ReadSectionData(lldb_private::Section *section, + lldb_private::DataExtractor §ion_data) { if (section->GetFileSize()) { const void *src = (void *)(uintptr_t)section->GetFileOffset(); diff --git a/lldb/source/Plugins/ObjectFile/CMakeLists.txt b/lldb/source/Plugins/ObjectFile/CMakeLists.txt index 6b5ec86..851b680 100644 --- a/lldb/source/Plugins/ObjectFile/CMakeLists.txt +++ b/lldb/source/Plugins/ObjectFile/CMakeLists.txt @@ -1,6 +1,5 @@ add_subdirectory(Breakpad) add_subdirectory(ELF) -add_subdirectory(JIT) add_subdirectory(JSON) add_subdirectory(Mach-O) add_subdirectory(Minidump) diff --git a/lldb/source/Plugins/ObjectFile/JIT/CMakeLists.txt b/lldb/source/Plugins/ObjectFile/JIT/CMakeLists.txt deleted file mode 100644 index fd57553..0000000 --- a/lldb/source/Plugins/ObjectFile/JIT/CMakeLists.txt +++ /dev/null @@ -1,11 +0,0 @@ -add_lldb_library(lldbPluginObjectFileJIT PLUGIN - ObjectFileJIT.cpp - - LINK_LIBS - lldbCore - lldbHost - lldbSymbol - lldbTarget - LINK_COMPONENTS - Support - ) -- 2.7.4