[Lldb-commits] [lldb] a52054c - [lldb] Move ObjectFileJIT to lldbExpression

Alex Langford via lldb-commits lldb-commits at lists.llvm.org
Fri Mar 31 13:40:17 PDT 2023


Author: Alex Langford
Date: 2023-03-31T13:38:37-07:00
New Revision: a52054cfa29d665c43141c66c20a7b8f7a96b546

URL: https://github.com/llvm/llvm-project/commit/a52054cfa29d665c43141c66c20a7b8f7a96b546
DIFF: https://github.com/llvm/llvm-project/commit/a52054cfa29d665c43141c66c20a7b8f7a96b546.diff

LOG: [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

Added: 
    lldb/include/lldb/Expression/ObjectFileJIT.h
    lldb/source/Expression/ObjectFileJIT.cpp

Modified: 
    lldb/include/lldb/Expression/IRExecutionUnit.h
    lldb/include/lldb/Symbol/ObjectFile.h
    lldb/source/Expression/CMakeLists.txt
    lldb/source/Expression/IRExecutionUnit.cpp
    lldb/source/Plugins/ObjectFile/CMakeLists.txt

Removed: 
    lldb/source/Plugins/ObjectFile/JIT/CMakeLists.txt
    lldb/source/Plugins/ObjectFile/JIT/ObjectFileJIT.cpp
    lldb/source/Plugins/ObjectFile/JIT/ObjectFileJIT.h


################################################################################
diff  --git a/lldb/include/lldb/Expression/IRExecutionUnit.h b/lldb/include/lldb/Expression/IRExecutionUnit.h
index ef53ca512d75e..58f12bf8b64f5 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 91fdd205eb200..7e50340ca84bd 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 &section_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 @@ class ObjectFileJIT : public lldb_private::ObjectFile {
                          lldb::offset_t section_offset, void *dst,
                          size_t dst_len) override;
 
-  size_t
-  ReadSectionData(lldb_private::Section *section,
-                  lldb_private::DataExtractor &section_data) override;
+  size_t ReadSectionData(lldb_private::Section *section,
+                         lldb_private::DataExtractor &section_data) override;
 
   lldb_private::Address GetEntryPointAddress() override;
 
@@ -103,5 +118,6 @@ class ObjectFileJIT : public lldb_private::ObjectFile {
 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 e2e0623c9f9ed..8f7806f682ede 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 &section_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 7e4fd81f2afdc..4194cfe02113f 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 f3cf0f623d24f..5a4ba04bff04e 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 <optional>
 
 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 2ea83e4b68831..106652d4499d2 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 &section_data) {
+size_t
+ObjectFileJIT::ReadSectionData(lldb_private::Section *section,
+                               lldb_private::DataExtractor &section_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 6b5ec86399117..851b680dc3c35 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 fd575532db4c7..0000000000000
--- 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
-  )


        


More information about the lldb-commits mailing list