[Lldb-commits] [lldb] r333182 - Move ObjectFile initialization out of SystemInitializerCommon
Pavel Labath via lldb-commits
lldb-commits at lists.llvm.org
Thu May 24 05:44:18 PDT 2018
Author: labath
Date: Thu May 24 05:44:18 2018
New Revision: 333182
URL: http://llvm.org/viewvc/llvm-project?rev=333182&view=rev
Log:
Move ObjectFile initialization out of SystemInitializerCommon
Summary:
For lldb-server, it is sufficient to parse only the native object file
format for its target OS (no other file can be loaded into a running
process). This moves the object file initialization code into specific
initializer classes: lldb-test and liblldb get all object files;
lldb-server gets only one of them. For this to work, I've needed to
create a special SystemInitializer for use in lldb-server, instead of it
calling directly into the common one.
This reduces the size of lldb-server by about 2%, which is not
earth-shattering, but it's an easy win, and it helps.
Reviewers: zturner, clayborg
Subscribers: mgorny, lldb-commits
Differential Revision: https://reviews.llvm.org/D47250
Added:
lldb/trunk/tools/lldb-server/SystemInitializerLLGS.cpp
lldb/trunk/tools/lldb-server/SystemInitializerLLGS.h
Modified:
lldb/trunk/source/API/SystemInitializerFull.cpp
lldb/trunk/source/Initialization/CMakeLists.txt
lldb/trunk/source/Initialization/SystemInitializerCommon.cpp
lldb/trunk/tools/lldb-server/CMakeLists.txt
lldb/trunk/tools/lldb-server/lldb-server.cpp
lldb/trunk/tools/lldb-test/SystemInitializerTest.cpp
Modified: lldb/trunk/source/API/SystemInitializerFull.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SystemInitializerFull.cpp?rev=333182&r1=333181&r2=333182&view=diff
==============================================================================
--- lldb/trunk/source/API/SystemInitializerFull.cpp (original)
+++ lldb/trunk/source/API/SystemInitializerFull.cpp Thu May 24 05:44:18 2018
@@ -70,6 +70,9 @@
#include "Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h"
#include "Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h"
#include "Plugins/MemoryHistory/asan/MemoryHistoryASan.h"
+#include "Plugins/ObjectFile/ELF/ObjectFileELF.h"
+#include "Plugins/ObjectFile/Mach-O/ObjectFileMachO.h"
+#include "Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h"
#include "Plugins/OperatingSystem/Go/OperatingSystemGo.h"
#include "Plugins/OperatingSystem/Python/OperatingSystemPython.h"
#include "Plugins/Platform/Android/PlatformAndroid.h"
@@ -251,6 +254,11 @@ SystemInitializerFull::~SystemInitialize
void SystemInitializerFull::Initialize() {
SystemInitializerCommon::Initialize();
+
+ ObjectFileELF::Initialize();
+ ObjectFileMachO::Initialize();
+ ObjectFilePECOFF::Initialize();
+
ScriptInterpreterNone::Initialize();
#ifndef LLDB_DISABLE_PYTHON
@@ -514,6 +522,10 @@ void SystemInitializerFull::Terminate()
PlatformDarwinKernel::Terminate();
#endif
+ ObjectFileELF::Terminate();
+ ObjectFileMachO::Terminate();
+ ObjectFilePECOFF::Terminate();
+
// Now shutdown the common parts, in reverse order.
SystemInitializerCommon::Terminate();
}
Modified: lldb/trunk/source/Initialization/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Initialization/CMakeLists.txt?rev=333182&r1=333181&r2=333182&view=diff
==============================================================================
--- lldb/trunk/source/Initialization/CMakeLists.txt (original)
+++ lldb/trunk/source/Initialization/CMakeLists.txt Thu May 24 05:44:18 2018
@@ -19,9 +19,6 @@ add_lldb_library(lldbInitialization
lldbPluginInstructionMIPS64
lldbPluginObjectContainerBSDArchive
lldbPluginObjectContainerMachOArchive
- lldbPluginObjectFileELF
- lldbPluginObjectFileMachO
- lldbPluginObjectFilePECOFF
lldbPluginProcessGDBRemote
${EXTRA_PLUGINS}
${LLDB_SYSTEM_LIBS}
Modified: lldb/trunk/source/Initialization/SystemInitializerCommon.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Initialization/SystemInitializerCommon.cpp?rev=333182&r1=333181&r2=333182&view=diff
==============================================================================
--- lldb/trunk/source/Initialization/SystemInitializerCommon.cpp (original)
+++ lldb/trunk/source/Initialization/SystemInitializerCommon.cpp Thu May 24 05:44:18 2018
@@ -14,14 +14,11 @@
#include "Plugins/Instruction/MIPS64/EmulateInstructionMIPS64.h"
#include "Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.h"
#include "Plugins/ObjectContainer/Universal-Mach-O/ObjectContainerUniversalMachO.h"
-#include "Plugins/ObjectFile/ELF/ObjectFileELF.h"
-#include "Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h"
#include "Plugins/Process/gdb-remote/ProcessGDBRemoteLog.h"
#include "lldb/Host/Host.h"
#include "lldb/Host/HostInfo.h"
#include "lldb/Utility/Log.h"
#include "lldb/Utility/Timer.h"
-#include "Plugins/ObjectFile/Mach-O/ObjectFileMachO.h"
#if defined(__linux__) || defined(__FreeBSD__) || defined(__NetBSD__)
#include "Plugins/Process/POSIX/ProcessPOSIXLog.h"
@@ -78,9 +75,6 @@ void SystemInitializerCommon::Initialize
// Initialize plug-ins
ObjectContainerBSDArchive::Initialize();
- ObjectFileELF::Initialize();
- ObjectFileMachO::Initialize();
- ObjectFilePECOFF::Initialize();
EmulateInstructionARM::Initialize();
EmulateInstructionMIPS::Initialize();
@@ -103,9 +97,6 @@ void SystemInitializerCommon::Terminate(
static Timer::Category func_cat(LLVM_PRETTY_FUNCTION);
Timer scoped_timer(func_cat, LLVM_PRETTY_FUNCTION);
ObjectContainerBSDArchive::Terminate();
- ObjectFileELF::Terminate();
- ObjectFileMachO::Terminate();
- ObjectFilePECOFF::Terminate();
EmulateInstructionARM::Terminate();
EmulateInstructionMIPS::Terminate();
Modified: lldb/trunk/tools/lldb-server/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-server/CMakeLists.txt?rev=333182&r1=333181&r2=333182&view=diff
==============================================================================
--- lldb/trunk/tools/lldb-server/CMakeLists.txt (original)
+++ lldb/trunk/tools/lldb-server/CMakeLists.txt Thu May 24 05:44:18 2018
@@ -34,12 +34,21 @@ if(CMAKE_SYSTEM_NAME MATCHES "NetBSD")
list(APPEND LLDB_PLUGINS lldbPluginProcessNetBSD)
endif()
+if(CMAKE_SYSTEM_NAME MATCHES "Darwin")
+ list(APPEND LLDB_PLUGINS lldbPluginObjectFileMachO)
+elseif(CMAKE_SYSTEM_NAME MATCHES "Windows")
+ list(APPEND LLDB_PLUGINS lldbPluginObjectFilePECOFF)
+else()
+ list(APPEND LLDB_PLUGINS lldbPluginObjectFileELF)
+endif()
+
add_lldb_tool(lldb-server INCLUDE_IN_FRAMEWORK
Acceptor.cpp
lldb-gdbserver.cpp
lldb-platform.cpp
lldb-server.cpp
LLDBServerUtilities.cpp
+ SystemInitializerLLGS.cpp
LINK_LIBS
lldbBase
Added: lldb/trunk/tools/lldb-server/SystemInitializerLLGS.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-server/SystemInitializerLLGS.cpp?rev=333182&view=auto
==============================================================================
--- lldb/trunk/tools/lldb-server/SystemInitializerLLGS.cpp (added)
+++ lldb/trunk/tools/lldb-server/SystemInitializerLLGS.cpp Thu May 24 05:44:18 2018
@@ -0,0 +1,33 @@
+//===-- SystemInitializerLLGS.cpp -------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "SystemInitializerLLGS.h"
+
+#if defined(__APPLE__)
+#include "Plugins/ObjectFile/Mach-O/ObjectFileMachO.h"
+using HostObjectFile = lldb_private::ObjectFileMachO;
+#elif defined(_WIN32)
+#include "Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h"
+using HostObjectFile = lldb_private::ObjectFilePECOFF;
+#else
+#include "Plugins/ObjectFile/ELF/ObjectFileELF.h"
+using HostObjectFile = ObjectFileELF;
+#endif
+
+using namespace lldb_private;
+
+void SystemInitializerLLGS::Initialize() {
+ SystemInitializerCommon::Initialize();
+ HostObjectFile::Initialize();
+}
+
+void SystemInitializerLLGS::Terminate() {
+ HostObjectFile::Terminate();
+ SystemInitializerCommon::Terminate();
+}
Added: lldb/trunk/tools/lldb-server/SystemInitializerLLGS.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-server/SystemInitializerLLGS.h?rev=333182&view=auto
==============================================================================
--- lldb/trunk/tools/lldb-server/SystemInitializerLLGS.h (added)
+++ lldb/trunk/tools/lldb-server/SystemInitializerLLGS.h Thu May 24 05:44:18 2018
@@ -0,0 +1,21 @@
+//===-- SystemInitializerLLGS.h ---------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLDB_SYSTEMINITIALIZERLLGS_H
+#define LLDB_SYSTEMINITIALIZERLLGS_H
+
+#include "lldb/Initialization/SystemInitializerCommon.h"
+
+class SystemInitializerLLGS : public lldb_private::SystemInitializerCommon {
+public:
+ void Initialize() override;
+ void Terminate() override;
+};
+
+#endif // LLDB_SYSTEMINITIALIZERLLGS_H
Modified: lldb/trunk/tools/lldb-server/lldb-server.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-server/lldb-server.cpp?rev=333182&r1=333181&r2=333182&view=diff
==============================================================================
--- lldb/trunk/tools/lldb-server/lldb-server.cpp (original)
+++ lldb/trunk/tools/lldb-server/lldb-server.cpp Thu May 24 05:44:18 2018
@@ -7,7 +7,7 @@
//
//===----------------------------------------------------------------------===//
-#include "lldb/Initialization/SystemInitializerCommon.h"
+#include "SystemInitializerLLGS.h"
#include "lldb/Initialization/SystemLifetimeManager.h"
#include "lldb/lldb-private.h"
@@ -35,8 +35,8 @@ int main_gdbserver(int argc, char *argv[
int main_platform(int argc, char *argv[]);
static void initialize() {
- g_debugger_lifetime->Initialize(
- llvm::make_unique<lldb_private::SystemInitializerCommon>(), nullptr);
+ g_debugger_lifetime->Initialize(llvm::make_unique<SystemInitializerLLGS>(),
+ nullptr);
}
static void terminate() { g_debugger_lifetime->Terminate(); }
Modified: lldb/trunk/tools/lldb-test/SystemInitializerTest.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-test/SystemInitializerTest.cpp?rev=333182&r1=333181&r2=333182&view=diff
==============================================================================
--- lldb/trunk/tools/lldb-test/SystemInitializerTest.cpp (original)
+++ lldb/trunk/tools/lldb-test/SystemInitializerTest.cpp Thu May 24 05:44:18 2018
@@ -60,6 +60,9 @@
#include "Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h"
#include "Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h"
#include "Plugins/MemoryHistory/asan/MemoryHistoryASan.h"
+#include "Plugins/ObjectFile/ELF/ObjectFileELF.h"
+#include "Plugins/ObjectFile/Mach-O/ObjectFileMachO.h"
+#include "Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h"
#include "Plugins/OperatingSystem/Go/OperatingSystemGo.h"
#include "Plugins/Platform/Android/PlatformAndroid.h"
#include "Plugins/Platform/FreeBSD/PlatformFreeBSD.h"
@@ -119,6 +122,11 @@ SystemInitializerTest::~SystemInitialize
void SystemInitializerTest::Initialize() {
SystemInitializerCommon::Initialize();
+
+ ObjectFileELF::Initialize();
+ ObjectFileMachO::Initialize();
+ ObjectFilePECOFF::Initialize();
+
ScriptInterpreterNone::Initialize();
OperatingSystemGo::Initialize();
@@ -345,6 +353,10 @@ void SystemInitializerTest::Terminate()
PlatformDarwinKernel::Terminate();
#endif
+ ObjectFileELF::Terminate();
+ ObjectFileMachO::Terminate();
+ ObjectFilePECOFF::Terminate();
+
// Now shutdown the common parts, in reverse order.
SystemInitializerCommon::Terminate();
}
More information about the lldb-commits
mailing list