mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2025-01-09 09:32:20 +00:00
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 llvm-svn: 333182
This commit is contained in:
parent
ae8ae5dc78
commit
fa3fa5b90e
lldb
source
tools
@ -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::~SystemInitializerFull() {}
|
||||
|
||||
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();
|
||||
}
|
||||
|
@ -19,9 +19,6 @@ add_lldb_library(lldbInitialization
|
||||
lldbPluginInstructionMIPS64
|
||||
lldbPluginObjectContainerBSDArchive
|
||||
lldbPluginObjectContainerMachOArchive
|
||||
lldbPluginObjectFileELF
|
||||
lldbPluginObjectFileMachO
|
||||
lldbPluginObjectFilePECOFF
|
||||
lldbPluginProcessGDBRemote
|
||||
${EXTRA_PLUGINS}
|
||||
${LLDB_SYSTEM_LIBS}
|
||||
|
@ -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();
|
||||
|
@ -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
|
||||
|
33
lldb/tools/lldb-server/SystemInitializerLLGS.cpp
Normal file
33
lldb/tools/lldb-server/SystemInitializerLLGS.cpp
Normal file
@ -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();
|
||||
}
|
21
lldb/tools/lldb-server/SystemInitializerLLGS.h
Normal file
21
lldb/tools/lldb-server/SystemInitializerLLGS.h
Normal file
@ -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
|
@ -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(); }
|
||||
|
@ -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::~SystemInitializerTest() {}
|
||||
|
||||
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();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user