[Lldb-commits] [lldb] r230963 - Reduce the number of components initialized by lldb-server to reduce static binary size.

Robert Flack flackr at gmail.com
Mon Mar 2 07:14:50 PST 2015


Author: flackr
Date: Mon Mar  2 09:14:50 2015
New Revision: 230963

URL: http://llvm.org/viewvc/llvm-project?rev=230963&view=rev
Log:
Reduce the number of components initialized by lldb-server to reduce static binary size.

Separate out the necessary component initialization for lldb-server such that the linker can greatly reduce the binary size. With this patch the size of lldb-server on my 64 bit linux release build drops from 46MB to 26MB.

Differential Revision: http://reviews.llvm.org/D7880

Modified:
    lldb/trunk/cmake/LLDBDependencies.cmake
    lldb/trunk/include/lldb/lldb-private.h
    lldb/trunk/lib/Makefile
    lldb/trunk/source/Plugins/Makefile
    lldb/trunk/source/Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.cpp
    lldb/trunk/source/Plugins/SystemRuntime/CMakeLists.txt
    lldb/trunk/source/lldb.cpp
    lldb/trunk/tools/lldb-server/lldb-gdbserver.cpp
    lldb/trunk/tools/lldb-server/lldb-platform.cpp
    lldb/trunk/tools/lldb-server/lldb-server.cpp

Modified: lldb/trunk/cmake/LLDBDependencies.cmake
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/cmake/LLDBDependencies.cmake?rev=230963&r1=230962&r2=230963&view=diff
==============================================================================
--- lldb/trunk/cmake/LLDBDependencies.cmake (original)
+++ lldb/trunk/cmake/LLDBDependencies.cmake Mon Mar  2 09:14:50 2015
@@ -53,6 +53,9 @@ set( LLDB_USED_LIBS
   lldbPluginOSPython
   lldbPluginMemoryHistoryASan
   lldbPluginInstrumentationRuntimeAddressSanitizer
+  lldbPluginSystemRuntimeMacOSX
+  lldbPluginProcessElfCore
+  lldbPluginJITLoaderGDB
   )
 
 # Windows-only libraries
@@ -101,9 +104,6 @@ if ( CMAKE_SYSTEM_NAME MATCHES "Darwin"
     lldbPluginProcessMachCore
     lldbPluginProcessMacOSXKernel
     lldbPluginSymbolVendorMacOSX
-    lldbPluginSystemRuntimeMacOSX
-    lldbPluginProcessElfCore
-    lldbPluginJITLoaderGDB
     )
 endif()
 

Modified: lldb/trunk/include/lldb/lldb-private.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/lldb-private.h?rev=230963&r1=230962&r2=230963&view=diff
==============================================================================
--- lldb/trunk/include/lldb/lldb-private.h (original)
+++ lldb/trunk/include/lldb/lldb-private.h Mon Mar  2 09:14:50 2015
@@ -38,6 +38,15 @@ namespace lldb_private {
 void
 Initialize();
 
+//------------------------------------------------------------------
+/// Initializes subset of lldb for LLGS.
+///
+/// This function only initializes the set of components and plugins
+/// necessary for lldb-platform and lldb-gdbserver, reducing the
+/// impact on the statically linked binary size.
+//------------------------------------------------------------------
+void
+InitializeForLLGS();
 
 //------------------------------------------------------------------
 /// Notifies any classes that lldb will be terminating soon.
@@ -70,6 +79,18 @@ WillTerminate();
 void
 Terminate();
 
+//------------------------------------------------------------------
+/// Terminates subset of lldb initialized by InitializeForLLGS
+///
+/// This function optionally can be called when clients are done
+/// using lldb functionality to free up any static resources
+/// that have been allocated during initialization or during
+/// function calls. No lldb functions should be called after
+/// calling this function without again calling DCInitialize()
+/// again.
+//------------------------------------------------------------------
+void
+TerminateLLGS();
 
 const char *
 GetVersion ();

Modified: lldb/trunk/lib/Makefile
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lib/Makefile?rev=230963&r1=230962&r2=230963&view=diff
==============================================================================
--- lldb/trunk/lib/Makefile (original)
+++ lldb/trunk/lib/Makefile Mon Mar  2 09:14:50 2015
@@ -49,6 +49,7 @@ USEDLIBS = lldbAPI.a \
 	lldbPluginLanguageRuntimeObjCAppleObjCRuntime.a \
 	lldbPluginMemoryHistoryASan.a \
 	lldbPluginObjectContainerBSDArchive.a \
+	lldbPluginObjectContainerUniversalMachO.a \
 	lldbPluginObjectFileELF.a \
 	lldbPluginObjectFileJIT.a \
 	lldbPluginSymbolVendorELF.a \
@@ -58,6 +59,7 @@ USEDLIBS = lldbAPI.a \
 	lldbPluginProcessGDBRemote.a \
 	lldbPluginSymbolFileDWARF.a \
 	lldbPluginSymbolFileSymtab.a \
+	lldbPluginSystemRuntimeMacOSX.a \
 	lldbPluginUnwindAssemblyInstEmulation.a \
 	lldbPluginUnwindAssemblyx86.a \
 	lldbPluginUtility.a \
@@ -105,12 +107,10 @@ ifeq ($(HOST_OS),Darwin)
               lldbHostPosix.a \
               lldbPluginDynamicLoaderMacOSX.a \
               lldbPluginDynamicLoaderDarwinKernel.a \
-              lldbPluginObjectContainerUniversalMachO.a \
               lldbPluginObjectFileMachO.a \
               lldbPluginSymbolVendorMacOSX.a \
               lldbPluginProcessDarwin.a \
               lldbPluginProcessMachCore.a \
-              lldbPluginSystemRuntimeMacOSX.a \
               lldbPluginProcessElfCore.a \
               lldbPluginJITLoaderGDB.a
 endif

Modified: lldb/trunk/source/Plugins/Makefile
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Makefile?rev=230963&r1=230962&r2=230963&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Makefile (original)
+++ lldb/trunk/source/Plugins/Makefile Mon Mar  2 09:14:50 2015
@@ -16,6 +16,7 @@ PARALLEL_DIRS := ABI/MacOSX-arm ABI/MacO
 	ABI/SysV-hexagon ABI/SysV-ppc ABI/SysV-ppc64 \
 	Disassembler/llvm \
 	ObjectContainer/BSD-Archive ObjectFile/ELF ObjectFile/PECOFF \
+	ObjectContainer/Universal-Mach-O ObjectFile/Mach-O \
 	ObjectFile/JIT SymbolFile/DWARF SymbolFile/Symtab Process/Utility \
 	DynamicLoader/Static Platform Process/gdb-remote \
 	Instruction/ARM Instruction/ARM64 \
@@ -25,6 +26,7 @@ PARALLEL_DIRS := ABI/MacOSX-arm ABI/MacO
 	DynamicLoader/POSIX-DYLD \
 	DynamicLoader/Hexagon-DYLD \
 	OperatingSystem/Python \
+	SystemRuntime/MacOSX \
 	SymbolVendor/ELF \
 	MemoryHistory/asan \
 	InstrumentationRuntime/AddressSanitizer
@@ -32,11 +34,9 @@ PARALLEL_DIRS := ABI/MacOSX-arm ABI/MacO
 ifeq ($(HOST_OS),Darwin)
 PARALLEL_DIRS += Process/MacOSX-Kernel
 PARALLEL_DIRS += DynamicLoader/MacOSX-DYLD DynamicLoader/Darwin-Kernel
-PARALLEL_DIRS +=	ObjectContainer/Universal-Mach-O ObjectFile/Mach-O
 PARALLEL_DIRS += SymbolVendor/MacOSX
 #PARALLEL_DIRS += Process/MacOSX-User
 PARALLEL_DIRS += Process/mach-core
-PARALLEL_DIRS += SystemRuntime/MacOSX
 PARALLEL_DIRS += Process/elf-core
 PARALLEL_DIRS += JITLoader/GDB
 endif

Modified: lldb/trunk/source/Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.cpp?rev=230963&r1=230962&r2=230963&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.cpp Mon Mar  2 09:14:50 2015
@@ -13,8 +13,6 @@
 #include <libxml/tree.h>
 #include <string.h>
 
-#include <AvailabilityMacros.h>
-
 #include "lldb/Core/Module.h"
 #include "lldb/Core/ModuleSpec.h"
 #include "lldb/Core/PluginManager.h"

Modified: lldb/trunk/source/Plugins/SystemRuntime/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SystemRuntime/CMakeLists.txt?rev=230963&r1=230962&r2=230963&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SystemRuntime/CMakeLists.txt (original)
+++ lldb/trunk/source/Plugins/SystemRuntime/CMakeLists.txt Mon Mar  2 09:14:50 2015
@@ -1,3 +1 @@
-if (CMAKE_SYSTEM_NAME MATCHES "Darwin")
-  add_subdirectory(MacOSX)
-endif()
+add_subdirectory(MacOSX)

Modified: lldb/trunk/source/lldb.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/lldb.cpp?rev=230963&r1=230962&r2=230963&view=diff
==============================================================================
--- lldb/trunk/source/lldb.cpp (original)
+++ lldb/trunk/source/lldb.cpp Mon Mar  2 09:14:50 2015
@@ -37,7 +37,6 @@
 #include "Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.h"
 #include "Plugins/Instruction/ARM/EmulateInstructionARM.h"
 #include "Plugins/Instruction/ARM64/EmulateInstructionARM64.h"
-#include "Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.h"
 #include "Plugins/JITLoader/GDB/JITLoaderGDB.h"
 #include "Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.h"
 #include "Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.h"
@@ -61,23 +60,24 @@
 #ifndef LLDB_DISABLE_PYTHON
 #include "Plugins/OperatingSystem/Python/OperatingSystemPython.h"
 #endif
-#if defined (__APPLE__)
+
 #include "Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.h"
-#include "Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.h"
 #include "Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.h"
 #include "Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h"
 #include "Plugins/ObjectContainer/Universal-Mach-O/ObjectContainerUniversalMachO.h"
-#include "Plugins/ObjectFile/Mach-O/ObjectFileMachO.h"
-#include "Plugins/Process/MacOSX-Kernel/ProcessKDP.h"
 #include "Plugins/Platform/MacOSX/PlatformMacOSX.h"
 #include "Plugins/Platform/MacOSX/PlatformRemoteiOS.h"
-#include "Plugins/Platform/MacOSX/PlatformDarwinKernel.h"
 #include "Plugins/Platform/MacOSX/PlatformiOSSimulator.h"
 #include "Plugins/SystemRuntime/MacOSX/SystemRuntimeMacOSX.h"
-#endif
 
+#if defined (__APPLE__)
+#include "Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.h"
+#include "Plugins/ObjectFile/Mach-O/ObjectFileMachO.h"
+#include "Plugins/Platform/MacOSX/PlatformDarwinKernel.h"
 #include "Plugins/Process/mach-core/ProcessMachCore.h"
-
+#include "Plugins/Process/MacOSX-Kernel/ProcessKDP.h"
+#include "Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.h"
+#endif
 
 #if defined (__linux__)
 #include "Plugins/Process/Linux/ProcessLinux.h"
@@ -110,7 +110,7 @@ static void fatal_error_handler(void *us
 }
 
 void
-lldb_private::Initialize ()
+lldb_private::InitializeForLLGS ()
 {
     // Make sure we initialize only once
     static Mutex g_inited_mutex(Mutex::eMutexTypeRecursive);
@@ -141,24 +141,13 @@ lldb_private::Initialize ()
 
         Log::Initialize();
         HostInfo::Initialize();
-        Timer::Initialize ();
-        Timer scoped_timer (__PRETTY_FUNCTION__, __PRETTY_FUNCTION__);
+        Timer::Initialize();
+        Timer scoped_timer(__PRETTY_FUNCTION__, __PRETTY_FUNCTION__);
 
-        // Initialize LLVM and Clang
-        llvm::InitializeAllTargets();
-        llvm::InitializeAllAsmPrinters();
-        llvm::InitializeAllTargetMCs();
-        llvm::InitializeAllDisassemblers();
         llvm::install_fatal_error_handler(fatal_error_handler, 0);
 
         // Initialize plug-ins
-        ABIMacOSX_i386::Initialize();
-        ABIMacOSX_arm::Initialize();
-        ABIMacOSX_arm64::Initialize();
-        ABISysV_x86_64::Initialize();
-        ABISysV_ppc::Initialize();
-        ABISysV_ppc64::Initialize();
-        DisassemblerLLVMC::Initialize();
+
         ObjectContainerBSDArchive::Initialize();
         ObjectFileELF::Initialize();
         SymbolVendorELF::Initialize();
@@ -166,10 +155,10 @@ lldb_private::Initialize ()
         SymbolFileSymtab::Initialize();
         UnwindAssemblyInstEmulation::Initialize();
         UnwindAssembly_x86::Initialize();
-        EmulateInstructionARM::Initialize ();
-        EmulateInstructionARM64::Initialize ();
-        ObjectFilePECOFF::Initialize ();
-        DynamicLoaderPOSIXDYLD::Initialize ();
+        EmulateInstructionARM::Initialize();
+        EmulateInstructionARM64::Initialize();
+        ObjectFilePECOFF::Initialize();
+        DynamicLoaderPOSIXDYLD::Initialize();
         PlatformFreeBSD::Initialize();
         PlatformLinux::Initialize();
         PlatformWindows::Initialize();
@@ -177,34 +166,65 @@ lldb_private::Initialize ()
         PlatformAndroid::Initialize();
         SymbolFileDWARFDebugMap::Initialize();
         ItaniumABILanguageRuntime::Initialize();
-#ifndef LLDB_DISABLE_PYTHON
-        ScriptInterpreterPython::InitializePrivate();
-        OperatingSystemPython::Initialize();
-#endif
-        JITLoaderGDB::Initialize();
-        ProcessElfCore::Initialize();
-        MemoryHistoryASan::Initialize();
-        AddressSanitizerRuntime::Initialize();
-        
-#if defined (__APPLE__)
+
         //----------------------------------------------------------------------
         // Apple/Darwin hosted plugins
         //----------------------------------------------------------------------
         DynamicLoaderMacOSXDYLD::Initialize();
-        DynamicLoaderDarwinKernel::Initialize();
         AppleObjCRuntimeV2::Initialize();
         AppleObjCRuntimeV1::Initialize();
         ObjectContainerUniversalMachO::Initialize();
-        ObjectFileMachO::Initialize();
-        ProcessKDP::Initialize();
-        ProcessMachCore::Initialize();
-        SymbolVendorMacOSX::Initialize();
-        PlatformDarwinKernel::Initialize();
+
         PlatformRemoteiOS::Initialize();
         PlatformMacOSX::Initialize();
         PlatformiOSSimulator::Initialize();
         SystemRuntimeMacOSX::Initialize();
+
+#if defined (__APPLE__)
+        SymbolVendorMacOSX::Initialize();
+        DynamicLoaderDarwinKernel::Initialize();
+        PlatformDarwinKernel::Initialize();
+        ObjectFileMachO::Initialize();
+#endif
+
+#ifndef LLDB_DISABLE_PYTHON
+        ScriptInterpreterPython::InitializePrivate();
+        OperatingSystemPython::Initialize();
 #endif
+    }
+}
+
+void
+lldb_private::Initialize ()
+{
+    // Make sure we initialize only once
+    static Mutex g_inited_mutex(Mutex::eMutexTypeRecursive);
+    static bool g_inited = false;
+
+    InitializeForLLGS();
+    Mutex::Locker locker(g_inited_mutex);
+    if (!g_inited)
+    {
+        g_inited = true;
+        // Initialize LLVM and Clang
+        llvm::InitializeAllTargets();
+        llvm::InitializeAllAsmPrinters();
+        llvm::InitializeAllTargetMCs();
+        llvm::InitializeAllDisassemblers();
+
+        ABIMacOSX_i386::Initialize();
+        ABIMacOSX_arm::Initialize();
+        ABIMacOSX_arm64::Initialize();
+        ABISysV_x86_64::Initialize();
+        ABISysV_ppc::Initialize();
+        ABISysV_ppc64::Initialize();
+        DisassemblerLLVMC::Initialize();
+
+        JITLoaderGDB::Initialize();
+        ProcessElfCore::Initialize();
+        MemoryHistoryASan::Initialize();
+        AddressSanitizerRuntime::Initialize();
+
 #if defined (__linux__)
         //----------------------------------------------------------------------
         // Linux hosted plugins
@@ -218,11 +238,15 @@ lldb_private::Initialize ()
 #if defined (__FreeBSD__)
         ProcessFreeBSD::Initialize();
 #endif
-
+#if defined (__APPLE__)
+        ProcessKDP::Initialize();
+        ProcessMachCore::Initialize();
+#endif
         //----------------------------------------------------------------------
         // Platform agnostic plugins
         //----------------------------------------------------------------------
-        PlatformRemoteGDBServer::Initialize ();
+        PlatformRemoteGDBServer::Initialize();
+
         ProcessGDBRemote::Initialize();
         DynamicLoaderStatic::Initialize();
 
@@ -231,8 +255,9 @@ lldb_private::Initialize ()
 
         // The process settings need to know about installed plug-ins, so the Settings must be initialized
         // AFTER PluginManager::Initialize is called.
-        
+
         Debugger::SettingsInitialize();
+
     }
 }
 
@@ -243,19 +268,9 @@ lldb_private::WillTerminate()
 }
 
 void
-lldb_private::Terminate ()
+lldb_private::TerminateLLGS ()
 {
     Timer scoped_timer (__PRETTY_FUNCTION__, __PRETTY_FUNCTION__);
-    
-    // Terminate and unload and loaded system or user LLDB plug-ins
-    PluginManager::Terminate();
-    ABIMacOSX_i386::Terminate();
-    ABIMacOSX_arm::Terminate();
-    ABIMacOSX_arm64::Terminate();
-    ABISysV_x86_64::Terminate();
-    ABISysV_ppc::Terminate();
-    ABISysV_ppc64::Terminate();
-    DisassemblerLLVMC::Terminate();
     ObjectContainerBSDArchive::Terminate();
     ObjectFileELF::Terminate();
     SymbolVendorELF::Terminate();
@@ -274,33 +289,51 @@ lldb_private::Terminate ()
     PlatformAndroid::Terminate();
     SymbolFileDWARFDebugMap::Terminate();
     ItaniumABILanguageRuntime::Terminate();
-#ifndef LLDB_DISABLE_PYTHON
-    OperatingSystemPython::Terminate();
-#endif
-    JITLoaderGDB::Terminate();
-    ProcessElfCore::Terminate();
-    MemoryHistoryASan::Terminate();
-    AddressSanitizerRuntime::Terminate();
-    
-#if defined (__APPLE__)
     DynamicLoaderMacOSXDYLD::Terminate();
-    DynamicLoaderDarwinKernel::Terminate();
     AppleObjCRuntimeV2::Terminate();
     AppleObjCRuntimeV1::Terminate();
     ObjectContainerUniversalMachO::Terminate();
-    ObjectFileMachO::Terminate();
-    ProcessMachCore::Terminate();
-    ProcessKDP::Terminate();
-    SymbolVendorMacOSX::Terminate();
     PlatformMacOSX::Terminate();
-    PlatformDarwinKernel::Terminate();
     PlatformRemoteiOS::Terminate();
     PlatformiOSSimulator::Terminate();
     SystemRuntimeMacOSX::Terminate();
+
+#if defined (__APPLE__)
+    DynamicLoaderDarwinKernel::Terminate();
+    ObjectFileMachO::Terminate();
+    PlatformDarwinKernel::Terminate();
+    SymbolVendorMacOSX::Terminate();
+#endif
+#ifndef LLDB_DISABLE_PYTHON
+    OperatingSystemPython::Terminate();
 #endif
 
-    Debugger::SettingsTerminate ();
+    Log::Terminate();
+}
+
+void
+lldb_private::Terminate ()
+{
+    Timer scoped_timer (__PRETTY_FUNCTION__, __PRETTY_FUNCTION__);
+    // Terminate and unload and loaded system or user LLDB plug-ins
+    PluginManager::Terminate();
+    ABIMacOSX_i386::Terminate();
+    ABIMacOSX_arm::Terminate();
+    ABIMacOSX_arm64::Terminate();
+    ABISysV_x86_64::Terminate();
+    ABISysV_ppc::Terminate();
+    ABISysV_ppc64::Terminate();
+    DisassemblerLLVMC::Terminate();
+
+    JITLoaderGDB::Terminate();
+    ProcessElfCore::Terminate();
+    MemoryHistoryASan::Terminate();
+    AddressSanitizerRuntime::Terminate();
 
+#if defined (__APPLE__)
+    ProcessMachCore::Terminate();
+    ProcessKDP::Terminate();
+#endif
 #if defined(_MSC_VER)
     DynamicLoaderWindows::Terminate();
 #endif
@@ -312,12 +345,12 @@ lldb_private::Terminate ()
 #if defined (__FreeBSD__)
     ProcessFreeBSD::Terminate();
 #endif
+    Debugger::SettingsTerminate ();
 
     PlatformRemoteGDBServer::Terminate();
     ProcessGDBRemote::Terminate();
     DynamicLoaderStatic::Terminate();
-
-    Log::Terminate();
+    TerminateLLGS();
 }
 
 #if defined (__APPLE__)

Modified: lldb/trunk/tools/lldb-server/lldb-gdbserver.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-server/lldb-gdbserver.cpp?rev=230963&r1=230962&r2=230963&view=diff
==============================================================================
--- lldb/trunk/tools/lldb-server/lldb-gdbserver.cpp (original)
+++ lldb/trunk/tools/lldb-server/lldb-gdbserver.cpp Mon Mar  2 09:14:50 2015
@@ -507,8 +507,6 @@ main_gdbserver (int argc, char *argv[])
     std::string named_pipe_path;
     bool reverse_connect = false;
 
-    Debugger::Initialize (NULL);
-
     lldb::DebuggerSP debugger_sp = Debugger::CreateInstance ();
 
     debugger_sp->SetInputFileHandle(stdin, false);
@@ -689,8 +687,6 @@ main_gdbserver (int argc, char *argv[])
 
     ConnectToRemote (gdb_server, reverse_connect, host_and_port, progname, subcommand, named_pipe_path.c_str ());
 
-    Debugger::Terminate ();
-
     fprintf(stderr, "lldb-gdbserver exiting...\n");
 
     return 0;

Modified: lldb/trunk/tools/lldb-server/lldb-platform.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-server/lldb-platform.cpp?rev=230963&r1=230962&r2=230963&view=diff
==============================================================================
--- lldb/trunk/tools/lldb-server/lldb-platform.cpp (original)
+++ lldb/trunk/tools/lldb-server/lldb-platform.cpp Mon Mar  2 09:14:50 2015
@@ -111,7 +111,6 @@ main_platform (int argc, char *argv[])
     Error error;
     std::string listen_host_port;
     int ch;
-    Debugger::Initialize(NULL);
 
     lldb::DebuggerSP debugger_sp = Debugger::CreateInstance ();
 
@@ -306,8 +305,6 @@ main_platform (int argc, char *argv[])
         }
     } while (g_stay_alive);
 
-    Debugger::Terminate();
-
     fprintf(stderr, "lldb-platform exiting...\n");
 
     return 0;

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=230963&r1=230962&r2=230963&view=diff
==============================================================================
--- lldb/trunk/tools/lldb-server/lldb-server.cpp (original)
+++ lldb/trunk/tools/lldb-server/lldb-server.cpp Mon Mar  2 09:14:50 2015
@@ -7,6 +7,8 @@
 //
 //===----------------------------------------------------------------------===//
 
+#include "lldb/lldb-private.h"
+
 #include <stdio.h>
 #include <stdlib.h>
 
@@ -24,6 +26,19 @@ display_usage (const char *progname)
 int main_gdbserver (int argc, char *argv[]);
 int main_platform (int argc, char *argv[]);
 
+static void
+initialize ()
+{
+    lldb_private::InitializeForLLGS();
+}
+
+static void
+terminate ()
+{
+    lldb_private::WillTerminate();
+    lldb_private::TerminateLLGS();
+}
+
 //----------------------------------------------------------------------
 // main
 //----------------------------------------------------------------------
@@ -39,11 +54,15 @@ main (int argc, char *argv[])
     }
     else if (argv[1][0] == 'g')
     {
+        initialize();
         main_gdbserver(argc, argv);
+        terminate();
     }
     else if (argv[1][0] == 'p')
     {
+        initialize();
         main_platform(argc, argv);
+        terminate();
     }
     else {
         display_usage(progname);





More information about the lldb-commits mailing list