[Lldb-commits] [lldb] r232768 - Move LLDB initialization/shutdown to Initialization.

Zachary Turner zturner at google.com
Thu Mar 19 15:00:22 PDT 2015


Author: zturner
Date: Thu Mar 19 17:00:21 2015
New Revision: 232768

URL: http://llvm.org/viewvc/llvm-project?rev=232768&view=rev
Log:
Move LLDB initialization/shutdown to Initialization.

This creates a new top-level folder called Initialization which
is intended to hold code specific to LLDB system initialization.
Currently this holds the Initialize() and Terminate() functions,
as well as the fatal error handler.

This provides a means to break the massive dependency cycle which
is caused by the fact that Debugger depends on Initialize and
Terminate which then depends on the entire LLDB project.  With
this structure, it will be possible for applications to invoke
lldb_private::Initialize() directly, and have that invoke
Debugger::Initialize.

Added:
    lldb/trunk/include/lldb/Initialization/
    lldb/trunk/include/lldb/Initialization/InitializeLLDB.h
      - copied, changed from r232741, lldb/trunk/include/lldb/lldb-private.h
    lldb/trunk/source/Initialization/
    lldb/trunk/source/Initialization/CMakeLists.txt
    lldb/trunk/source/Initialization/InitializeLLDB.cpp
    lldb/trunk/source/Initialization/Makefile
Modified:
    lldb/trunk/cmake/LLDBDependencies.cmake
    lldb/trunk/include/lldb/Core/Debugger.h
    lldb/trunk/include/lldb/Host/Host.h
    lldb/trunk/include/lldb/lldb-forward.h
    lldb/trunk/include/lldb/lldb-private-types.h
    lldb/trunk/include/lldb/lldb-private.h
    lldb/trunk/lldb.xcodeproj/project.pbxproj
    lldb/trunk/source/API/SBDebugger.cpp
    lldb/trunk/source/CMakeLists.txt
    lldb/trunk/source/Core/Debugger.cpp
    lldb/trunk/source/Host/common/Host.cpp
    lldb/trunk/source/Makefile
    lldb/trunk/source/lldb.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=232768&r1=232767&r2=232768&view=diff
==============================================================================
--- lldb/trunk/cmake/LLDBDependencies.cmake (original)
+++ lldb/trunk/cmake/LLDBDependencies.cmake Thu Mar 19 17:00:21 2015
@@ -6,6 +6,7 @@ set( LLDB_USED_LIBS
   lldbHost
   lldbCore
   lldbExpression
+  lldbInitialization
   lldbInterpreter
   lldbSymbol
   lldbTarget

Modified: lldb/trunk/include/lldb/Core/Debugger.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Debugger.h?rev=232768&r1=232767&r2=232768&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/Debugger.h (original)
+++ lldb/trunk/include/lldb/Core/Debugger.h Thu Mar 19 17:00:21 2015
@@ -55,10 +55,6 @@ friend class SourceManager;  // For GetS
 
 public:
 
-    typedef llvm::sys::DynamicLibrary (*LoadPluginCallbackType) (const lldb::DebuggerSP &debugger_sp,
-                                                                 const FileSpec& spec,
-                                                                 Error& error);
-
     static lldb::DebuggerSP
     CreateInstance (lldb::LogOutputCallback log_callback = NULL, void *baton = NULL);
 
@@ -69,12 +65,9 @@ public:
     FindTargetWithProcess (Process *process);
 
     static void
-    InitializeForLLGS (LoadPluginCallbackType load_plugin_callback);
-
-    static void
     Initialize (LoadPluginCallbackType load_plugin_callback);
     
-    static void 
+    static int
     Terminate ();
     
     static void

Modified: lldb/trunk/include/lldb/Host/Host.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/Host.h?rev=232768&r1=232767&r2=232768&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Host/Host.h (original)
+++ lldb/trunk/include/lldb/Host/Host.h Thu Mar 19 17:00:21 2015
@@ -133,9 +133,6 @@ public:
     static const char *
     GetSignalAsCString (int signo);
 
-    static void
-    WillTerminate ();
-
     typedef void (*ThreadLocalStorageCleanupCallback) (void *p);
 
     static lldb::thread_key_t

Copied: lldb/trunk/include/lldb/Initialization/InitializeLLDB.h (from r232741, lldb/trunk/include/lldb/lldb-private.h)
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Initialization/InitializeLLDB.h?p2=lldb/trunk/include/lldb/Initialization/InitializeLLDB.h&p1=lldb/trunk/include/lldb/lldb-private.h&r1=232741&r2=232768&rev=232768&view=diff
==============================================================================
--- lldb/trunk/include/lldb/lldb-private.h (original)
+++ lldb/trunk/include/lldb/Initialization/InitializeLLDB.h Thu Mar 19 17:00:21 2015
@@ -1,4 +1,4 @@
-//===-- lldb-private.h ------------------------------------------*- C++ -*-===//
+//===-- InitializeLLDB.h ----------------------------------------*- C++ -*-===//
 //
 //                     The LLVM Compiler Infrastructure
 //
@@ -7,25 +7,13 @@
 //
 //===----------------------------------------------------------------------===//
 
-#ifndef lldb_lldb_private_h_
-#define lldb_lldb_private_h_
+#ifndef LLDB_INITIALIZATION_INITIALIZE_LLDB_H
+#define LLDB_INITIALIZATION_INITIALIZE_LLDB_H
 
-#if defined(__cplusplus)
-
-#ifdef _WIN32
-#include "lldb/Host/windows/win32.h"
-#endif
-
-#ifdef __ANDROID_NDK__
-#include "lldb/Host/android/Android.h"
-#endif
-
-#include "lldb/lldb-public.h"
-#include "lldb/lldb-private-enumerations.h"
-#include "lldb/lldb-private-interfaces.h"
 #include "lldb/lldb-private-types.h"
 
-namespace lldb_private {
+namespace lldb_private
+{
 
 //------------------------------------------------------------------
 /// Initializes lldb.
@@ -34,8 +22,7 @@ namespace lldb_private {
 /// classes to ensure they have a chance to do any static
 /// initialization that they need to do.
 //------------------------------------------------------------------
-void
-Initialize();
+void Initialize(LoadPluginCallbackType load_plugin_callback);
 
 //------------------------------------------------------------------
 /// Initializes subset of lldb for LLGS.
@@ -44,26 +31,7 @@ Initialize();
 /// 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.
-///
-/// This function will be called when the Debugger shared instance
-/// is being destructed and will give classes the ability to clean
-/// up any threads or other resources they have that they might not
-/// be able to clean up in their own destructors.
-///
-/// Internal classes that need this ability will need to add their
-/// void T::WillTerminate() method in the body of this function in
-/// lldb.cpp to ensure it will get called.
-///
-/// TODO: when we start having external plug-ins, we will need a way
-/// for plug-ins to register a WillTerminate callback.
-//------------------------------------------------------------------
-void
-WillTerminate();
+void InitializeForLLGS(LoadPluginCallbackType load_plugin_callback);
 
 //------------------------------------------------------------------
 /// Terminates lldb
@@ -75,8 +43,7 @@ WillTerminate();
 /// calling this function without again calling DCInitialize()
 /// again.
 //------------------------------------------------------------------
-void
-Terminate();
+void Terminate();
 
 //------------------------------------------------------------------
 /// Terminates subset of lldb initialized by InitializeForLLGS
@@ -88,16 +55,7 @@ Terminate();
 /// calling this function without again calling DCInitialize()
 /// again.
 //------------------------------------------------------------------
-void
-TerminateLLGS();
-
-const char *
-GetVersion ();
-
-} // namespace lldb_private
+void TerminateLLGS();
+}
 
-
-#endif  // defined(__cplusplus)
-
-
-#endif  // lldb_lldb_private_h_
+#endif

Modified: lldb/trunk/include/lldb/lldb-forward.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/lldb-forward.h?rev=232768&r1=232767&r2=232768&view=diff
==============================================================================
--- lldb/trunk/include/lldb/lldb-forward.h (original)
+++ lldb/trunk/include/lldb/lldb-forward.h Thu Mar 19 17:00:21 2015
@@ -433,7 +433,7 @@ namespace lldb {
     typedef std::shared_ptr<lldb_private::VariableList> VariableListSP;
     typedef std::shared_ptr<lldb_private::ValueObjectList> ValueObjectListSP;
     typedef std::shared_ptr<lldb_private::Watchpoint> WatchpointSP;
-    
+
 } // namespace lldb
 
 

Modified: lldb/trunk/include/lldb/lldb-private-types.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/lldb-private-types.h?rev=232768&r1=232767&r2=232768&view=diff
==============================================================================
--- lldb/trunk/include/lldb/lldb-private-types.h (original)
+++ lldb/trunk/include/lldb/lldb-private-types.h Thu Mar 19 17:00:21 2015
@@ -14,11 +14,22 @@
 
 #include "lldb/lldb-private.h"
 
+namespace llvm
+{
+namespace sys
+{
+class DynamicLibrary;
+}
+}
+
 namespace lldb_private
 {
     class Platform;
     class ExecutionContext;
 
+    typedef llvm::sys::DynamicLibrary (*LoadPluginCallbackType)(const lldb::DebuggerSP &debugger_sp,
+                                                                const FileSpec &spec, Error &error);
+
     //----------------------------------------------------------------------
     // Every register is described in detail including its name, alternate
     // name (optional), encoding, size in bytes and the default display

Modified: lldb/trunk/include/lldb/lldb-private.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/lldb-private.h?rev=232768&r1=232767&r2=232768&view=diff
==============================================================================
--- lldb/trunk/include/lldb/lldb-private.h (original)
+++ lldb/trunk/include/lldb/lldb-private.h Thu Mar 19 17:00:21 2015
@@ -27,70 +27,6 @@
 
 namespace lldb_private {
 
-//------------------------------------------------------------------
-/// Initializes lldb.
-///
-/// This function should be called prior to using any lldb
-/// classes to ensure they have a chance to do any static
-/// initialization that they need to do.
-//------------------------------------------------------------------
-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.
-///
-/// This function will be called when the Debugger shared instance
-/// is being destructed and will give classes the ability to clean
-/// up any threads or other resources they have that they might not
-/// be able to clean up in their own destructors.
-///
-/// Internal classes that need this ability will need to add their
-/// void T::WillTerminate() method in the body of this function in
-/// lldb.cpp to ensure it will get called.
-///
-/// TODO: when we start having external plug-ins, we will need a way
-/// for plug-ins to register a WillTerminate callback.
-//------------------------------------------------------------------
-void
-WillTerminate();
-
-//------------------------------------------------------------------
-/// Terminates lldb
-///
-/// 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
-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/lldb.xcodeproj/project.pbxproj
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=232768&r1=232767&r2=232768&view=diff
==============================================================================
--- lldb/trunk/lldb.xcodeproj/project.pbxproj (original)
+++ lldb/trunk/lldb.xcodeproj/project.pbxproj Thu Mar 19 17:00:21 2015
@@ -686,6 +686,7 @@
 		3F8160A61AB9F7DD001DA9DF /* Logging.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3F8160A51AB9F7DD001DA9DF /* Logging.cpp */; };
 		3F8169191ABA2419001DA9DF /* ConvertEnum.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3F8169171ABA2419001DA9DF /* ConvertEnum.cpp */; };
 		3F81691A1ABA2419001DA9DF /* NameMatches.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3F8169181ABA2419001DA9DF /* NameMatches.cpp */; };
+		3F8169281ABB73D9001DA9DF /* InitializeLLDB.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3F8169271ABB73D9001DA9DF /* InitializeLLDB.cpp */; };
 		3FDFDDBD199C3A06009756A7 /* FileAction.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3FDFDDBC199C3A06009756A7 /* FileAction.cpp */; };
 		3FDFDDBF199D345E009756A7 /* FileCache.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3FDFDDBE199D345E009756A7 /* FileCache.cpp */; };
 		3FDFDDC6199D37ED009756A7 /* FileSystem.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3FDFDDC5199D37ED009756A7 /* FileSystem.cpp */; };
@@ -2165,6 +2166,8 @@
 		3F8169181ABA2419001DA9DF /* NameMatches.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = NameMatches.cpp; path = source/Utility/NameMatches.cpp; sourceTree = "<group>"; };
 		3F81691B1ABA242B001DA9DF /* ConvertEnum.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = ConvertEnum.h; path = include/lldb/Utility/ConvertEnum.h; sourceTree = "<group>"; };
 		3F81691C1ABA242B001DA9DF /* NameMatches.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = NameMatches.h; path = include/lldb/Utility/NameMatches.h; sourceTree = "<group>"; };
+		3F8169271ABB73D9001DA9DF /* InitializeLLDB.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = InitializeLLDB.cpp; path = source/Initialization/InitializeLLDB.cpp; sourceTree = "<group>"; };
+		3F8169291ABB73E6001DA9DF /* InitializeLLDB.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = InitializeLLDB.h; path = include/lldb/Initialization/InitializeLLDB.h; sourceTree = "<group>"; };
 		3FDFD6C3199C396E009756A7 /* FileAction.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = FileAction.h; path = include/lldb/Target/FileAction.h; sourceTree = "<group>"; };
 		3FDFDDBC199C3A06009756A7 /* FileAction.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = FileAction.cpp; path = source/Target/FileAction.cpp; sourceTree = "<group>"; };
 		3FDFDDBE199D345E009756A7 /* FileCache.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = FileCache.cpp; path = source/Host/common/FileCache.cpp; sourceTree = "<group>"; };
@@ -2809,6 +2812,7 @@
 				94CB255616B0683B0059775D /* DataFormatters */,
 				26BC7DBE10F1B78200F91463 /* Expression */,
 				26BC7DD010F1B7C100F91463 /* Host */,
+				3F8169261ABB73C1001DA9DF /* Initialization */,
 				26BC7DDF10F1B7E200F91463 /* Interpreter */,
 				260C897110F57C5600BB2B04 /* Plugins */,
 				26BC7C4B10F1B6C100F91463 /* Symbol */,
@@ -4765,6 +4769,15 @@
 			path = "POSIX-DYLD";
 			sourceTree = "<group>";
 		};
+		3F8169261ABB73C1001DA9DF /* Initialization */ = {
+			isa = PBXGroup;
+			children = (
+				3F8169291ABB73E6001DA9DF /* InitializeLLDB.h */,
+				3F8169271ABB73D9001DA9DF /* InitializeLLDB.cpp */,
+			);
+			name = Initialization;
+			sourceTree = "<group>";
+		};
 		3FDFDDC4199D37BE009756A7 /* posix */ = {
 			isa = PBXGroup;
 			children = (
@@ -6345,6 +6358,7 @@
 				94CB257216B0A4270059775D /* TypeSynthetic.cpp in Sources */,
 				94CB257416B1D3880059775D /* FormatCache.cpp in Sources */,
 				A36FF33C17D8E94600244D40 /* OptionParser.cpp in Sources */,
+				3F8169281ABB73D9001DA9DF /* InitializeLLDB.cpp in Sources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};

Modified: lldb/trunk/source/API/SBDebugger.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBDebugger.cpp?rev=232768&r1=232767&r2=232768&view=diff
==============================================================================
--- lldb/trunk/source/API/SBDebugger.cpp (original)
+++ lldb/trunk/source/API/SBDebugger.cpp Thu Mar 19 17:00:21 2015
@@ -33,11 +33,11 @@
 #include "lldb/API/SBTypeSummary.h"
 #include "lldb/API/SBTypeSynthetic.h"
 
-
 #include "lldb/Core/Debugger.h"
 #include "lldb/Core/State.h"
 #include "lldb/Core/StreamFile.h"
 #include "lldb/DataFormatters/DataVisualization.h"
+#include "lldb/Initialization/InitializeLLDB.h"
 #include "lldb/Interpreter/Args.h"
 #include "lldb/Interpreter/CommandInterpreter.h"
 #include "lldb/Interpreter/OptionGroupPlatform.h"
@@ -117,13 +117,13 @@ SBDebugger::Initialize ()
 
     SBCommandInterpreter::InitializeSWIG ();
 
-    Debugger::Initialize(LoadPlugin);
+    lldb_private::Initialize(LoadPlugin);
 }
 
 void
 SBDebugger::Terminate ()
 {
-    Debugger::Terminate();
+    lldb_private::Terminate();
 }
 
 void

Modified: lldb/trunk/source/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/CMakeLists.txt?rev=232768&r1=232767&r2=232768&view=diff
==============================================================================
--- lldb/trunk/source/CMakeLists.txt (original)
+++ lldb/trunk/source/CMakeLists.txt Thu Mar 19 17:00:21 2015
@@ -35,13 +35,15 @@ add_subdirectory(Core)
 add_subdirectory(DataFormatters)
 add_subdirectory(Expression)
 add_subdirectory(Host)
+add_subdirectory(Initialization)
 add_subdirectory(Interpreter)
 add_subdirectory(Plugins)
 add_subdirectory(Symbol)
 add_subdirectory(Target)
 add_subdirectory(Utility)
 
-# Build API last, since liblldb needs to link against every other target
+# Build API last.  Since liblldb needs to link against every other target, it needs
+# those targets to have already been created.
 add_subdirectory(API)
 
 # Determine LLDB revision and repository. GetSourceVersion and GetRepositoryPath are shell-scripts, and as

Modified: lldb/trunk/source/Core/Debugger.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Debugger.cpp?rev=232768&r1=232767&r2=232768&view=diff
==============================================================================
--- lldb/trunk/source/Core/Debugger.cpp (original)
+++ lldb/trunk/source/Core/Debugger.cpp Thu Mar 19 17:00:21 2015
@@ -38,6 +38,7 @@
 #include "lldb/Host/HostInfo.h"
 #include "lldb/Host/Terminal.h"
 #include "lldb/Host/ThreadLauncher.h"
+#include "lldb/Initialization/InitializeLLDB.h"
 #include "lldb/Interpreter/CommandInterpreter.h"
 #include "lldb/Interpreter/OptionValueProperties.h"
 #include "lldb/Interpreter/OptionValueSInt64.h"
@@ -185,7 +186,7 @@ enum
     ePropertyEscapeNonPrintables
 };
 
-Debugger::LoadPluginCallbackType Debugger::g_load_plugin_callback = NULL;
+LoadPluginCallbackType Debugger::g_load_plugin_callback = NULL;
 
 Error
 Debugger::SetPropertyValue (const ExecutionContext *exe_ctx,
@@ -412,27 +413,16 @@ Debugger::TestDebuggerRefCount ()
     return g_shared_debugger_refcount;
 }
 
-static bool lldb_initialized_for_llgs = false;
-void
-Debugger::InitializeForLLGS (LoadPluginCallbackType load_plugin_callback)
-{
-    lldb_initialized_for_llgs = true;
-    g_shared_debugger_refcount++;
-    g_load_plugin_callback = load_plugin_callback;
-    lldb_private::InitializeForLLGS();
-}
-
 static bool lldb_initialized = true;
 void
-Debugger::Initialize (LoadPluginCallbackType load_plugin_callback)
+Debugger::Initialize(LoadPluginCallbackType load_plugin_callback)
 {
     lldb_initialized = true;
     g_shared_debugger_refcount++;
     g_load_plugin_callback = load_plugin_callback;
-    lldb_private::Initialize();
 }
 
-void
+int
 Debugger::Terminate ()
 {
     if (g_shared_debugger_refcount > 0)
@@ -440,21 +430,12 @@ Debugger::Terminate ()
         g_shared_debugger_refcount--;
         if (g_shared_debugger_refcount == 0)
         {
-            lldb_private::WillTerminate();
-            if (lldb_initialized_for_llgs) {
-                lldb_initialized_for_llgs = false;
-                lldb_private::TerminateLLGS();
-            }
-            if (lldb_initialized) {
-                lldb_initialized = false;
-                lldb_private::Terminate();
-            }
-
             // Clear our master list of debugger objects
             Mutex::Locker locker (GetDebuggerListMutex ());
             GetDebuggerList().clear();
         }
     }
+    return g_shared_debugger_refcount;
 }
 
 void

Modified: lldb/trunk/source/Host/common/Host.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/Host.cpp?rev=232768&r1=232767&r2=232768&view=diff
==============================================================================
--- lldb/trunk/source/Host/common/Host.cpp (original)
+++ lldb/trunk/source/Host/common/Host.cpp Thu Mar 19 17:00:21 2015
@@ -423,11 +423,6 @@ Host::GetSignalAsCString (int signo)
 
 #endif
 
-void
-Host::WillTerminate ()
-{
-}
-
 #if !defined (__APPLE__) && !defined (__FreeBSD__) && !defined (__FreeBSD_kernel__) && !defined (__linux__) // see macosx/Host.mm
 
 size_t

Added: lldb/trunk/source/Initialization/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Initialization/CMakeLists.txt?rev=232768&view=auto
==============================================================================
--- lldb/trunk/source/Initialization/CMakeLists.txt (added)
+++ lldb/trunk/source/Initialization/CMakeLists.txt Thu Mar 19 17:00:21 2015
@@ -0,0 +1,3 @@
+add_lldb_library(lldbInitialization
+  InitializeLLDB.cpp
+  )

Added: lldb/trunk/source/Initialization/InitializeLLDB.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Initialization/InitializeLLDB.cpp?rev=232768&view=auto
==============================================================================
--- lldb/trunk/source/Initialization/InitializeLLDB.cpp (added)
+++ lldb/trunk/source/Initialization/InitializeLLDB.cpp Thu Mar 19 17:00:21 2015
@@ -0,0 +1,400 @@
+//===-- InitializeLLDB.cpp --------------------------------------*- C++ -*-===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "lldb/Core/Debugger.h"
+#include "lldb/Core/Log.h"
+#include "lldb/Core/Timer.h"
+#include "lldb/Host/Host.h"
+#include "lldb/Host/HostInfo.h"
+#include "lldb/Host/Mutex.h"
+#include "lldb/Initialization/InitializeLLDB.h"
+#include "lldb/Interpreter/ScriptInterpreterPython.h"
+
+#include "Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.h"
+#include "Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.h"
+#include "Plugins/ABI/MacOSX-arm64/ABIMacOSX_arm64.h"
+#include "Plugins/ABI/SysV-x86_64/ABISysV_x86_64.h"
+#include "Plugins/ABI/SysV-ppc/ABISysV_ppc.h"
+#include "Plugins/ABI/SysV-ppc64/ABISysV_ppc64.h"
+#include "Plugins/Disassembler/llvm/DisassemblerLLVMC.h"
+#include "Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.h"
+#include "Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.h"
+#include "Plugins/DynamicLoader/Static/DynamicLoaderStatic.h"
+#include "Plugins/Instruction/ARM/EmulateInstructionARM.h"
+#include "Plugins/Instruction/ARM64/EmulateInstructionARM64.h"
+#include "Plugins/Instruction/MIPS64/EmulateInstructionMIPS64.h"
+#include "Plugins/InstrumentationRuntime/AddressSanitizer/AddressSanitizerRuntime.h"
+#include "Plugins/JITLoader/GDB/JITLoaderGDB.h"
+#include "Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.h"
+#include "Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.h"
+#include "Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h"
+#include "Plugins/MemoryHistory/asan/MemoryHistoryASan.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/OperatingSystem/Python/OperatingSystemPython.h"
+#include "Plugins/Platform/Android/PlatformAndroid.h"
+#include "Plugins/Platform/FreeBSD/PlatformFreeBSD.h"
+#include "Plugins/Platform/gdb-server/PlatformRemoteGDBServer.h"
+#include "Plugins/Platform/Kalimba/PlatformKalimba.h"
+#include "Plugins/Platform/Linux/PlatformLinux.h"
+#include "Plugins/Platform/MacOSX/PlatformiOSSimulator.h"
+#include "Plugins/Platform/MacOSX/PlatformMacOSX.h"
+#include "Plugins/Platform/MacOSX/PlatformRemoteiOS.h"
+#include "Plugins/Platform/Windows/PlatformWindows.h"
+#include "Plugins/Process/elf-core/ProcessElfCore.h"
+#include "Plugins/Process/gdb-remote/ProcessGDBRemote.h"
+#include "Plugins/Process/gdb-remote/ProcessGDBRemoteLog.h"
+#include "Plugins/SymbolFile/DWARF/SymbolFileDWARF.h"
+#include "Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h"
+#include "Plugins/SymbolFile/Symtab/SymbolFileSymtab.h"
+#include "Plugins/SymbolVendor/ELF/SymbolVendorELF.h"
+#include "Plugins/SystemRuntime/MacOSX/SystemRuntimeMacOSX.h"
+#include "Plugins/UnwindAssembly/x86/UnwindAssembly-x86.h"
+#include "Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.h"
+
+#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(__FreeBSD__)
+#include "Plugins/Process/FreeBSD/ProcessFreeBSD.h"
+#endif
+
+#if defined(__linux__)
+#include "Plugins/Process/Linux/ProcessLinux.h"
+#include "Plugins/Process/POSIX/ProcessPOSIXLog.h"
+#endif
+
+#if defined(_MSC_VER)
+#include "lldb/Host/windows/windows.h"
+#include "Plugins/Process/Windows/DynamicLoaderWindows.h"
+#include "Plugins/Process/Windows/ProcessWindows.h"
+#endif
+
+#include "llvm/Support/TargetSelect.h"
+
+#include <string>
+
+using namespace lldb_private;
+
+static void
+fatal_error_handler(void *user_data, const std::string &reason, bool gen_crash_diag)
+{
+    Host::SetCrashDescription(reason.c_str());
+    ::abort();
+}
+
+static bool g_inited_for_llgs = false;
+static void
+InitializeForLLGSPrivate()
+{
+    if (g_inited_for_llgs)
+        return;
+    g_inited_for_llgs = true;
+
+#if defined(_MSC_VER)
+    const char *disable_crash_dialog_var = getenv("LLDB_DISABLE_CRASH_DIALOG");
+    if (disable_crash_dialog_var && llvm::StringRef(disable_crash_dialog_var).equals_lower("true"))
+    {
+        // This will prevent Windows from displaying a dialog box requiring user interaction when
+        // LLDB crashes.  This is mostly useful when automating LLDB, for example via the test
+        // suite, so that a crash in LLDB does not prevent completion of the test suite.
+        ::SetErrorMode(GetErrorMode() | SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX);
+
+        _CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_FILE | _CRTDBG_MODE_DEBUG);
+        _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE | _CRTDBG_MODE_DEBUG);
+        _CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_FILE | _CRTDBG_MODE_DEBUG);
+        _CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR);
+        _CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDERR);
+        _CrtSetReportFile(_CRT_ERROR, _CRTDBG_FILE_STDERR);
+    }
+#endif
+
+    Log::Initialize();
+    HostInfo::Initialize();
+    Timer::Initialize();
+    Timer scoped_timer(__PRETTY_FUNCTION__, __PRETTY_FUNCTION__);
+
+    llvm::install_fatal_error_handler(fatal_error_handler, 0);
+
+    ProcessGDBRemoteLog::Initialize();
+
+    // Initialize plug-ins
+    ObjectContainerBSDArchive::Initialize();
+    ObjectFileELF::Initialize();
+    ObjectFilePECOFF::Initialize();
+    DynamicLoaderPOSIXDYLD::Initialize();
+    PlatformFreeBSD::Initialize();
+    PlatformLinux::Initialize();
+    PlatformWindows::Initialize();
+    PlatformKalimba::Initialize();
+    PlatformAndroid::Initialize();
+
+    //----------------------------------------------------------------------
+    // Apple/Darwin hosted plugins
+    //----------------------------------------------------------------------
+    DynamicLoaderMacOSXDYLD::Initialize();
+    ObjectContainerUniversalMachO::Initialize();
+
+    PlatformRemoteiOS::Initialize();
+    PlatformMacOSX::Initialize();
+    PlatformiOSSimulator::Initialize();
+
+#if defined(__APPLE__)
+    DynamicLoaderDarwinKernel::Initialize();
+    PlatformDarwinKernel::Initialize();
+    ObjectFileMachO::Initialize();
+#endif
+#if defined(__linux__)
+    static ConstString g_linux_log_name("linux");
+    ProcessPOSIXLog::Initialize(g_linux_log_name);
+#endif
+#ifndef LLDB_DISABLE_PYTHON
+    ScriptInterpreterPython::InitializePrivate();
+    OperatingSystemPython::Initialize();
+#endif
+}
+
+static bool g_inited = false;
+static void
+InitializePrivate()
+{
+    if (g_inited)
+        return;
+    g_inited = true;
+
+    InitializeForLLGSPrivate();
+
+    // 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();
+
+    SymbolVendorELF::Initialize();
+    SymbolFileDWARF::Initialize();
+    SymbolFileSymtab::Initialize();
+    UnwindAssemblyInstEmulation::Initialize();
+    UnwindAssembly_x86::Initialize();
+    EmulateInstructionARM::Initialize();
+    EmulateInstructionARM64::Initialize();
+    EmulateInstructionMIPS64::Initialize();
+    SymbolFileDWARFDebugMap::Initialize();
+    ItaniumABILanguageRuntime::Initialize();
+    AppleObjCRuntimeV2::Initialize();
+    AppleObjCRuntimeV1::Initialize();
+    SystemRuntimeMacOSX::Initialize();
+
+#if defined(__linux__)
+    //----------------------------------------------------------------------
+    // Linux hosted plugins
+    //----------------------------------------------------------------------
+    ProcessLinux::Initialize();
+#endif
+#if defined(_MSC_VER)
+    DynamicLoaderWindows::Initialize();
+    ProcessWindows::Initialize();
+#endif
+#if defined(__FreeBSD__)
+    ProcessFreeBSD::Initialize();
+#endif
+#if defined(__APPLE__)
+    SymbolVendorMacOSX::Initialize();
+    ProcessKDP::Initialize();
+    ProcessMachCore::Initialize();
+#endif
+    //----------------------------------------------------------------------
+    // Platform agnostic plugins
+    //----------------------------------------------------------------------
+    PlatformRemoteGDBServer::Initialize();
+
+    ProcessGDBRemote::Initialize();
+    DynamicLoaderStatic::Initialize();
+
+    // Scan for any system or user LLDB plug-ins
+    PluginManager::Initialize();
+
+    // The process settings need to know about installed plug-ins, so the Settings must be initialized
+    // AFTER PluginManager::Initialize is called.
+
+    Debugger::SettingsInitialize();
+}
+
+static void
+TerminateForLLGSPrivate()
+{
+    if (!g_inited_for_llgs)
+        return;
+    g_inited_for_llgs = false;
+
+    Timer scoped_timer(__PRETTY_FUNCTION__, __PRETTY_FUNCTION__);
+    ObjectContainerBSDArchive::Terminate();
+    ObjectFileELF::Terminate();
+    ObjectFilePECOFF::Terminate();
+    DynamicLoaderPOSIXDYLD::Terminate();
+    PlatformFreeBSD::Terminate();
+    PlatformLinux::Terminate();
+    PlatformWindows::Terminate();
+    PlatformKalimba::Terminate();
+    PlatformAndroid::Terminate();
+    DynamicLoaderMacOSXDYLD::Terminate();
+    ObjectContainerUniversalMachO::Terminate();
+    PlatformMacOSX::Terminate();
+    PlatformRemoteiOS::Terminate();
+    PlatformiOSSimulator::Terminate();
+
+#if defined(__APPLE__)
+    DynamicLoaderDarwinKernel::Terminate();
+    ObjectFileMachO::Terminate();
+    PlatformDarwinKernel::Terminate();
+#endif
+
+#ifndef LLDB_DISABLE_PYTHON
+    OperatingSystemPython::Terminate();
+#endif
+
+    Log::Terminate();
+}
+
+static void
+TerminatePrivate()
+{
+
+    if (!g_inited)
+        return;
+    g_inited = false;
+
+    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();
+    SymbolVendorELF::Terminate();
+    SymbolFileDWARF::Terminate();
+    SymbolFileSymtab::Terminate();
+    UnwindAssembly_x86::Terminate();
+    UnwindAssemblyInstEmulation::Terminate();
+    EmulateInstructionARM::Terminate();
+    EmulateInstructionARM64::Terminate();
+    EmulateInstructionMIPS64::Terminate();
+    SymbolFileDWARFDebugMap::Terminate();
+    ItaniumABILanguageRuntime::Terminate();
+    AppleObjCRuntimeV2::Terminate();
+    AppleObjCRuntimeV1::Terminate();
+    SystemRuntimeMacOSX::Terminate();
+
+#if defined(__APPLE__)
+    ProcessMachCore::Terminate();
+    ProcessKDP::Terminate();
+    SymbolVendorMacOSX::Terminate();
+#endif
+#if defined(_MSC_VER)
+    DynamicLoaderWindows::Terminate();
+#endif
+
+#if defined(__linux__)
+    ProcessLinux::Terminate();
+#endif
+
+#if defined(__FreeBSD__)
+    ProcessFreeBSD::Terminate();
+#endif
+    Debugger::SettingsTerminate();
+
+    PlatformRemoteGDBServer::Terminate();
+    ProcessGDBRemote::Terminate();
+    DynamicLoaderStatic::Terminate();
+
+    TerminateForLLGSPrivate();
+}
+
+void
+lldb_private::InitializeForLLGS(LoadPluginCallbackType load_plugin_callback)
+{
+    // Make sure we initialize only once
+    static Mutex g_inited_mutex(Mutex::eMutexTypeRecursive);
+    Mutex::Locker locker(g_inited_mutex);
+
+    // Call the actual initializers.  If we've already been initialized this
+    // will do nothing.
+    InitializeForLLGSPrivate();
+
+    // We want to call Debuger::Initialize every time, even if we've already
+    // been initialized, so that the debugger ref count increases.
+    Debugger::Initialize(load_plugin_callback);
+}
+
+void
+lldb_private::Initialize(LoadPluginCallbackType load_plugin_callback)
+{
+    // Make sure we initialize only once
+    static Mutex g_inited_mutex(Mutex::eMutexTypeRecursive);
+    Mutex::Locker locker(g_inited_mutex);
+
+    // Call the actual initializers.  If we've already been initialized this
+    // will do nothing.
+    InitializeForLLGSPrivate();
+    InitializePrivate();
+
+    // We want to call Debuger::Initialize every time, even if we've already
+    // been initialized, so that the debugger ref count increases.
+    Debugger::Initialize(load_plugin_callback);
+}
+
+void
+lldb_private::TerminateLLGS()
+{
+    // Terminate the debugger.  If the ref count is still greater than 0, we
+    // shouldn't shutdown yet.
+    if (Debugger::Terminate() > 0)
+        return;
+
+    TerminateForLLGSPrivate();
+}
+
+void
+lldb_private::Terminate()
+{
+    // Terminate the debugger.  If the ref count is still greater than 0, we
+    // shouldn't shutdown yet.
+    if (Debugger::Terminate() > 0)
+        return;
+
+    TerminatePrivate();
+}

Added: lldb/trunk/source/Initialization/Makefile
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Initialization/Makefile?rev=232768&view=auto
==============================================================================
--- lldb/trunk/source/Initialization/Makefile (added)
+++ lldb/trunk/source/Initialization/Makefile Thu Mar 19 17:00:21 2015
@@ -0,0 +1,14 @@
+##===- source/Initialize/Makefile -------------------------*- Makefile -*-===##
+#
+#                     The LLVM Compiler Infrastructure
+#
+# This file is distributed under the University of Illinois Open Source
+# License. See LICENSE.TXT for details.
+#
+##===----------------------------------------------------------------------===##
+
+LLDB_LEVEL := ../..
+LIBRARYNAME := lldbInitialize
+BUILD_ARCHIVE = 1
+
+include $(LLDB_LEVEL)/Makefile

Modified: lldb/trunk/source/Makefile
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Makefile?rev=232768&r1=232767&r2=232768&view=diff
==============================================================================
--- lldb/trunk/source/Makefile (original)
+++ lldb/trunk/source/Makefile Thu Mar 19 17:00:21 2015
@@ -8,7 +8,7 @@
 ##===----------------------------------------------------------------------===##
 
 LLDB_LEVEL := ..
-PARALLEL_DIRS := API Breakpoint Commands Core DataFormatters Expression Host Interpreter Plugins Symbol Target Utility
+PARALLEL_DIRS := API Initialization Breakpoint Commands Core DataFormatters Expression Host Interpreter Plugins Symbol Target Utility
 LIBRARYNAME := lldbInitAndLog
 BUILD_ARCHIVE = 1
 

Modified: lldb/trunk/source/lldb.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/lldb.cpp?rev=232768&r1=232767&r2=232768&view=diff
==============================================================================
--- lldb/trunk/source/lldb.cpp (original)
+++ lldb/trunk/source/lldb.cpp Thu Mar 19 17:00:21 2015
@@ -7,372 +7,11 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "lldb/lldb-python.h"
-
 #include "lldb/lldb-private.h"
-#include "lldb/Core/ArchSpec.h"
-#include "lldb/Core/Debugger.h"
-#include "lldb/Core/Log.h"
-#include "lldb/Core/PluginManager.h"
-#include "lldb/Core/RegularExpression.h"
-#include "lldb/Core/Timer.h"
-#include "lldb/Host/Host.h"
-#include "lldb/Host/HostInfo.h"
-#include "lldb/Host/Mutex.h"
-#include "lldb/Interpreter/ScriptInterpreterPython.h"
-#include "lldb/Target/Target.h"
-#include "lldb/Target/Thread.h"
-
-#include "llvm/ADT/StringRef.h"
-#include "llvm/Support/TargetSelect.h"
-
-#include "Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.h"
-#include "Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.h"
-#include "Plugins/ABI/MacOSX-arm64/ABIMacOSX_arm64.h"
-#include "Plugins/ABI/SysV-x86_64/ABISysV_x86_64.h"
-#include "Plugins/ABI/SysV-ppc/ABISysV_ppc.h"
-#include "Plugins/ABI/SysV-ppc64/ABISysV_ppc64.h"
-#include "Plugins/Disassembler/llvm/DisassemblerLLVMC.h"
-#include "Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.h"
-#include "Plugins/Instruction/ARM/EmulateInstructionARM.h"
-#include "Plugins/Instruction/ARM64/EmulateInstructionARM64.h"
-#include "Plugins/Instruction/MIPS64/EmulateInstructionMIPS64.h"
-#include "Plugins/JITLoader/GDB/JITLoaderGDB.h"
-#include "Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.h"
-#include "Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.h"
-#include "Plugins/ObjectFile/ELF/ObjectFileELF.h"
-#include "Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h"
-#include "Plugins/Platform/Android/PlatformAndroid.h"
-#include "Plugins/Platform/FreeBSD/PlatformFreeBSD.h"
-#include "Plugins/Platform/Linux/PlatformLinux.h"
-#include "Plugins/Platform/Windows/PlatformWindows.h"
-#include "Plugins/Platform/Kalimba/PlatformKalimba.h"
-#include "Plugins/Process/elf-core/ProcessElfCore.h"
-#include "Plugins/SymbolVendor/ELF/SymbolVendorELF.h"
-#include "Plugins/SymbolFile/DWARF/SymbolFileDWARF.h"
-#include "Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h"
-#include "Plugins/SymbolFile/Symtab/SymbolFileSymtab.h"
-#include "Plugins/UnwindAssembly/x86/UnwindAssembly-x86.h"
-#include "Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.h"
-
-#ifndef LLDB_DISABLE_PYTHON
-#include "Plugins/OperatingSystem/Python/OperatingSystemPython.h"
-#endif
-
-#include "Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.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/Platform/MacOSX/PlatformMacOSX.h"
-#include "Plugins/Platform/MacOSX/PlatformRemoteiOS.h"
-#include "Plugins/Platform/MacOSX/PlatformiOSSimulator.h"
-#include "Plugins/SystemRuntime/MacOSX/SystemRuntimeMacOSX.h"
-
-#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"
-#include "Plugins/Process/POSIX/ProcessPOSIXLog.h"
-#endif
-
-#if defined (_WIN32)
-#include "lldb/Host/windows/windows.h"
-#include "Plugins/Process/Windows/DynamicLoaderWindows.h"
-#include "Plugins/Process/Windows/ProcessWindows.h"
-#endif
-
-#if defined (__FreeBSD__)
-#include "Plugins/Process/POSIX/ProcessPOSIX.h"
-#include "Plugins/Process/FreeBSD/ProcessFreeBSD.h"
-#endif
-
-#include "Plugins/Platform/gdb-server/PlatformRemoteGDBServer.h"
-#include "Plugins/Process/gdb-remote/ProcessGDBRemoteLog.h"
-#include "Plugins/Process/gdb-remote/ProcessGDBRemote.h"
-#include "Plugins/DynamicLoader/Static/DynamicLoaderStatic.h"
-#include "Plugins/MemoryHistory/asan/MemoryHistoryASan.h"
-#include "Plugins/InstrumentationRuntime/AddressSanitizer/AddressSanitizerRuntime.h"
 
 using namespace lldb;
 using namespace lldb_private;
 
-static void fatal_error_handler(void *user_data, const std::string& reason,
-                                bool gen_crash_diag) {
-    Host::SetCrashDescription(reason.c_str());
-    ::abort();
-}
-
-static bool g_inited_for_llgs = false;
-void
-lldb_private::InitializeForLLGS ()
-{
-    // Make sure we initialize only once
-    static Mutex g_inited_mutex(Mutex::eMutexTypeRecursive);
-
-    Mutex::Locker locker(g_inited_mutex);
-    if (!g_inited_for_llgs)
-    {
-        g_inited_for_llgs = true;
-
-#if defined(_MSC_VER)
-        const char *disable_crash_dialog_var = getenv("LLDB_DISABLE_CRASH_DIALOG");
-        if (disable_crash_dialog_var && llvm::StringRef(disable_crash_dialog_var).equals_lower("true"))
-        {
-            // This will prevent Windows from displaying a dialog box requiring user interaction when
-            // LLDB crashes.  This is mostly useful when automating LLDB, for example via the test
-            // suite, so that a crash in LLDB does not prevent completion of the test suite.
-            ::SetErrorMode(GetErrorMode() | SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX);
-
-            _CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_FILE | _CRTDBG_MODE_DEBUG);
-            _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE | _CRTDBG_MODE_DEBUG);
-            _CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_FILE | _CRTDBG_MODE_DEBUG);
-            _CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR);
-            _CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDERR);
-            _CrtSetReportFile(_CRT_ERROR, _CRTDBG_FILE_STDERR);
-        }
-#endif
-
-        Log::Initialize();
-        HostInfo::Initialize();
-        Timer::Initialize();
-        Timer scoped_timer(__PRETTY_FUNCTION__, __PRETTY_FUNCTION__);
-
-        llvm::install_fatal_error_handler(fatal_error_handler, 0);
-
-        ProcessGDBRemoteLog::Initialize();
-
-        // Initialize plug-ins
-        ObjectContainerBSDArchive::Initialize();
-        ObjectFileELF::Initialize();
-        ObjectFilePECOFF::Initialize();
-        DynamicLoaderPOSIXDYLD::Initialize();
-        PlatformFreeBSD::Initialize();
-        PlatformLinux::Initialize();
-        PlatformWindows::Initialize();
-        PlatformKalimba::Initialize();
-        PlatformAndroid::Initialize();
-
-        //----------------------------------------------------------------------
-        // Apple/Darwin hosted plugins
-        //----------------------------------------------------------------------
-        DynamicLoaderMacOSXDYLD::Initialize();
-        ObjectContainerUniversalMachO::Initialize();
-
-        PlatformRemoteiOS::Initialize();
-        PlatformMacOSX::Initialize();
-        PlatformiOSSimulator::Initialize();
-
-#if defined (__APPLE__)
-        DynamicLoaderDarwinKernel::Initialize();
-        PlatformDarwinKernel::Initialize();
-        ObjectFileMachO::Initialize();
-#endif
-#if defined (__linux__)
-        static ConstString g_linux_log_name("linux");
-        ProcessPOSIXLog::Initialize(g_linux_log_name);
-#endif
-#ifndef LLDB_DISABLE_PYTHON
-        ScriptInterpreterPython::InitializePrivate();
-        OperatingSystemPython::Initialize();
-#endif
-    }
-}
-
-static bool g_inited = false;
-void
-lldb_private::Initialize ()
-{
-    // Make sure we initialize only once
-    static Mutex g_inited_mutex(Mutex::eMutexTypeRecursive);
-
-    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();
-
-        SymbolVendorELF::Initialize();
-        SymbolFileDWARF::Initialize();
-        SymbolFileSymtab::Initialize();
-        UnwindAssemblyInstEmulation::Initialize();
-        UnwindAssembly_x86::Initialize();
-        EmulateInstructionARM::Initialize();
-        EmulateInstructionARM64::Initialize();
-        EmulateInstructionMIPS64::Initialize();
-        SymbolFileDWARFDebugMap::Initialize();
-        ItaniumABILanguageRuntime::Initialize();
-        AppleObjCRuntimeV2::Initialize();
-        AppleObjCRuntimeV1::Initialize();
-        SystemRuntimeMacOSX::Initialize();
-
-#if defined (__linux__)
-        //----------------------------------------------------------------------
-        // Linux hosted plugins
-        //----------------------------------------------------------------------
-        ProcessLinux::Initialize();
-#endif
-#if defined(_MSC_VER)
-        DynamicLoaderWindows::Initialize();
-        ProcessWindows::Initialize();
-#endif
-#if defined (__FreeBSD__)
-        ProcessFreeBSD::Initialize();
-#endif
-#if defined (__APPLE__)
-        SymbolVendorMacOSX::Initialize();
-        ProcessKDP::Initialize();
-        ProcessMachCore::Initialize();
-#endif
-        //----------------------------------------------------------------------
-        // Platform agnostic plugins
-        //----------------------------------------------------------------------
-        PlatformRemoteGDBServer::Initialize();
-
-        ProcessGDBRemote::Initialize();
-        DynamicLoaderStatic::Initialize();
-
-        // Scan for any system or user LLDB plug-ins
-        PluginManager::Initialize();
-
-        // The process settings need to know about installed plug-ins, so the Settings must be initialized
-        // AFTER PluginManager::Initialize is called.
-
-        Debugger::SettingsInitialize();
-
-    }
-}
-
-void
-lldb_private::WillTerminate()
-{
-    Host::WillTerminate();
-}
-
-void
-lldb_private::TerminateLLGS ()
-{
-    if (g_inited_for_llgs)
-    {
-        g_inited_for_llgs = false;
-
-        Timer scoped_timer (__PRETTY_FUNCTION__, __PRETTY_FUNCTION__);
-        ObjectContainerBSDArchive::Terminate();
-        ObjectFileELF::Terminate();
-        ObjectFilePECOFF::Terminate ();
-        DynamicLoaderPOSIXDYLD::Terminate ();
-        PlatformFreeBSD::Terminate();
-        PlatformLinux::Terminate();
-        PlatformWindows::Terminate();
-        PlatformKalimba::Terminate();
-        PlatformAndroid::Terminate();
-        DynamicLoaderMacOSXDYLD::Terminate();
-        ObjectContainerUniversalMachO::Terminate();
-        PlatformMacOSX::Terminate();
-        PlatformRemoteiOS::Terminate();
-        PlatformiOSSimulator::Terminate();
-
-#if defined (__APPLE__)
-        DynamicLoaderDarwinKernel::Terminate();
-        ObjectFileMachO::Terminate();
-        PlatformDarwinKernel::Terminate();
-#endif
-
-#ifndef LLDB_DISABLE_PYTHON
-        OperatingSystemPython::Terminate();
-#endif
-
-        Log::Terminate();
-    }
-}
-
-void
-lldb_private::Terminate ()
-{
-    if (g_inited)
-    {
-        g_inited = false;
-
-        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();
-        SymbolVendorELF::Terminate();
-        SymbolFileDWARF::Terminate();
-        SymbolFileSymtab::Terminate();
-        UnwindAssembly_x86::Terminate();
-        UnwindAssemblyInstEmulation::Terminate();
-        EmulateInstructionARM::Terminate();
-        EmulateInstructionARM64::Terminate();
-        EmulateInstructionMIPS64::Terminate();
-        SymbolFileDWARFDebugMap::Terminate();
-        ItaniumABILanguageRuntime::Terminate();
-        AppleObjCRuntimeV2::Terminate();
-        AppleObjCRuntimeV1::Terminate();
-        SystemRuntimeMacOSX::Terminate();
-
-#if defined (__APPLE__)
-        ProcessMachCore::Terminate();
-        ProcessKDP::Terminate();
-        SymbolVendorMacOSX::Terminate();
-#endif
-#if defined(_MSC_VER)
-        DynamicLoaderWindows::Terminate();
-#endif
-
-#if defined (__linux__)
-        ProcessLinux::Terminate();
-#endif
-
-#if defined (__FreeBSD__)
-        ProcessFreeBSD::Terminate();
-#endif
-        Debugger::SettingsTerminate ();
-
-        PlatformRemoteGDBServer::Terminate();
-        ProcessGDBRemote::Terminate();
-        DynamicLoaderStatic::Terminate();
-
-        TerminateLLGS();
-    }
-}
-
 #if defined (__APPLE__)
 extern "C" const unsigned char liblldb_coreVersionString[];
 #else

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=232768&r1=232767&r2=232768&view=diff
==============================================================================
--- lldb/trunk/tools/lldb-server/lldb-server.cpp (original)
+++ lldb/trunk/tools/lldb-server/lldb-server.cpp Thu Mar 19 17:00:21 2015
@@ -8,6 +8,7 @@
 //===----------------------------------------------------------------------===//
 
 #include "lldb/Core/Debugger.h"
+#include "lldb/Initialization/InitializeLLDB.h"
 
 #include <stdio.h>
 #include <stdlib.h>
@@ -29,13 +30,13 @@ int main_platform (int argc, char *argv[
 static void
 initialize ()
 {
-    lldb_private::Debugger::InitializeForLLGS(NULL);
+    lldb_private::InitializeForLLGS(nullptr);
 }
 
 static void
 terminate ()
 {
-    lldb_private::Debugger::Terminate();
+    lldb_private::TerminateLLGS();
 }
 
 //----------------------------------------------------------------------





More information about the lldb-commits mailing list