From 3a00691f3d6d281b5bf13564b81aef1d3e408c51 Mon Sep 17 00:00:00 2001 From: Zachary Turner Date: Thu, 19 Mar 2015 22:00:21 +0000 Subject: [PATCH] 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. llvm-svn: 232768 --- lldb/cmake/LLDBDependencies.cmake | 1 + lldb/include/lldb/Core/Debugger.h | 9 +- lldb/include/lldb/Host/Host.h | 3 - lldb/include/lldb/Initialization/InitializeLLDB.h | 61 ++++ lldb/include/lldb/lldb-forward.h | 2 +- lldb/include/lldb/lldb-private-types.h | 11 + lldb/include/lldb/lldb-private.h | 64 ---- lldb/lldb.xcodeproj/project.pbxproj | 14 + lldb/source/API/SBDebugger.cpp | 6 +- lldb/source/CMakeLists.txt | 4 +- lldb/source/Core/Debugger.cpp | 29 +- lldb/source/Host/common/Host.cpp | 5 - lldb/source/Initialization/CMakeLists.txt | 3 + lldb/source/Initialization/InitializeLLDB.cpp | 400 ++++++++++++++++++++++ lldb/source/Initialization/Makefile | 14 + lldb/source/Makefile | 2 +- lldb/source/lldb.cpp | 361 ------------------- lldb/tools/lldb-server/lldb-server.cpp | 5 +- 18 files changed, 521 insertions(+), 473 deletions(-) create mode 100644 lldb/include/lldb/Initialization/InitializeLLDB.h create mode 100644 lldb/source/Initialization/CMakeLists.txt create mode 100644 lldb/source/Initialization/InitializeLLDB.cpp create mode 100644 lldb/source/Initialization/Makefile diff --git a/lldb/cmake/LLDBDependencies.cmake b/lldb/cmake/LLDBDependencies.cmake index 5aff968..ac554eb 100644 --- a/lldb/cmake/LLDBDependencies.cmake +++ b/lldb/cmake/LLDBDependencies.cmake @@ -6,6 +6,7 @@ set( LLDB_USED_LIBS lldbHost lldbCore lldbExpression + lldbInitialization lldbInterpreter lldbSymbol lldbTarget diff --git a/lldb/include/lldb/Core/Debugger.h b/lldb/include/lldb/Core/Debugger.h index 972c636..b73d168 100644 --- a/lldb/include/lldb/Core/Debugger.h +++ b/lldb/include/lldb/Core/Debugger.h @@ -55,10 +55,6 @@ friend class SourceManager; // For GetSourceFileCache. 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 diff --git a/lldb/include/lldb/Host/Host.h b/lldb/include/lldb/Host/Host.h index 9ce83e2..860747f 100644 --- a/lldb/include/lldb/Host/Host.h +++ b/lldb/include/lldb/Host/Host.h @@ -133,9 +133,6 @@ public: static const char * GetSignalAsCString (int signo); - static void - WillTerminate (); - typedef void (*ThreadLocalStorageCleanupCallback) (void *p); static lldb::thread_key_t diff --git a/lldb/include/lldb/Initialization/InitializeLLDB.h b/lldb/include/lldb/Initialization/InitializeLLDB.h new file mode 100644 index 0000000..74268cc --- /dev/null +++ b/lldb/include/lldb/Initialization/InitializeLLDB.h @@ -0,0 +1,61 @@ +//===-- InitializeLLDB.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_INITIALIZATION_INITIALIZE_LLDB_H +#define LLDB_INITIALIZATION_INITIALIZE_LLDB_H + +#include "lldb/lldb-private-types.h" + +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(LoadPluginCallbackType load_plugin_callback); + +//------------------------------------------------------------------ +/// 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(LoadPluginCallbackType load_plugin_callback); + +//------------------------------------------------------------------ +/// 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(); +} + +#endif diff --git a/lldb/include/lldb/lldb-forward.h b/lldb/include/lldb/lldb-forward.h index 6806f84..04ffa59 100644 --- a/lldb/include/lldb/lldb-forward.h +++ b/lldb/include/lldb/lldb-forward.h @@ -433,7 +433,7 @@ namespace lldb { typedef std::shared_ptr VariableListSP; typedef std::shared_ptr ValueObjectListSP; typedef std::shared_ptr WatchpointSP; - + } // namespace lldb diff --git a/lldb/include/lldb/lldb-private-types.h b/lldb/include/lldb/lldb-private-types.h index cd48672..cce637f 100644 --- a/lldb/include/lldb/lldb-private-types.h +++ b/lldb/include/lldb/lldb-private-types.h @@ -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 diff --git a/lldb/include/lldb/lldb-private.h b/lldb/include/lldb/lldb-private.h index a65c6ce..951b22f 100644 --- a/lldb/include/lldb/lldb-private.h +++ b/lldb/include/lldb/lldb-private.h @@ -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 (); diff --git a/lldb/lldb.xcodeproj/project.pbxproj b/lldb/lldb.xcodeproj/project.pbxproj index 5a872d2..c843e58 100644 --- a/lldb/lldb.xcodeproj/project.pbxproj +++ b/lldb/lldb.xcodeproj/project.pbxproj @@ -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 = ""; }; 3F81691B1ABA242B001DA9DF /* ConvertEnum.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = ConvertEnum.h; path = include/lldb/Utility/ConvertEnum.h; sourceTree = ""; }; 3F81691C1ABA242B001DA9DF /* NameMatches.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = NameMatches.h; path = include/lldb/Utility/NameMatches.h; sourceTree = ""; }; + 3F8169271ABB73D9001DA9DF /* InitializeLLDB.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = InitializeLLDB.cpp; path = source/Initialization/InitializeLLDB.cpp; sourceTree = ""; }; + 3F8169291ABB73E6001DA9DF /* InitializeLLDB.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = InitializeLLDB.h; path = include/lldb/Initialization/InitializeLLDB.h; sourceTree = ""; }; 3FDFD6C3199C396E009756A7 /* FileAction.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = FileAction.h; path = include/lldb/Target/FileAction.h; sourceTree = ""; }; 3FDFDDBC199C3A06009756A7 /* FileAction.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = FileAction.cpp; path = source/Target/FileAction.cpp; sourceTree = ""; }; 3FDFDDBE199D345E009756A7 /* FileCache.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = FileCache.cpp; path = source/Host/common/FileCache.cpp; sourceTree = ""; }; @@ -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 = ""; }; + 3F8169261ABB73C1001DA9DF /* Initialization */ = { + isa = PBXGroup; + children = ( + 3F8169291ABB73E6001DA9DF /* InitializeLLDB.h */, + 3F8169271ABB73D9001DA9DF /* InitializeLLDB.cpp */, + ); + name = Initialization; + sourceTree = ""; + }; 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; }; diff --git a/lldb/source/API/SBDebugger.cpp b/lldb/source/API/SBDebugger.cpp index a95f2ff..17fa065 100644 --- a/lldb/source/API/SBDebugger.cpp +++ b/lldb/source/API/SBDebugger.cpp @@ -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 diff --git a/lldb/source/CMakeLists.txt b/lldb/source/CMakeLists.txt index ca57718..0470e51 100644 --- a/lldb/source/CMakeLists.txt +++ b/lldb/source/CMakeLists.txt @@ -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 diff --git a/lldb/source/Core/Debugger.cpp b/lldb/source/Core/Debugger.cpp index 17eb924..f93da0eb 100644 --- a/lldb/source/Core/Debugger.cpp +++ b/lldb/source/Core/Debugger.cpp @@ -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 diff --git a/lldb/source/Host/common/Host.cpp b/lldb/source/Host/common/Host.cpp index 32b002f..4584f70 100644 --- a/lldb/source/Host/common/Host.cpp +++ b/lldb/source/Host/common/Host.cpp @@ -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 diff --git a/lldb/source/Initialization/CMakeLists.txt b/lldb/source/Initialization/CMakeLists.txt new file mode 100644 index 0000000..38898e3 --- /dev/null +++ b/lldb/source/Initialization/CMakeLists.txt @@ -0,0 +1,3 @@ +add_lldb_library(lldbInitialization + InitializeLLDB.cpp + ) diff --git a/lldb/source/Initialization/InitializeLLDB.cpp b/lldb/source/Initialization/InitializeLLDB.cpp new file mode 100644 index 0000000..dcaafb0 --- /dev/null +++ b/lldb/source/Initialization/InitializeLLDB.cpp @@ -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 + +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(); +} diff --git a/lldb/source/Initialization/Makefile b/lldb/source/Initialization/Makefile new file mode 100644 index 0000000..34354d1 --- /dev/null +++ b/lldb/source/Initialization/Makefile @@ -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 diff --git a/lldb/source/Makefile b/lldb/source/Makefile index 413cef6..69d6c0f 100644 --- a/lldb/source/Makefile +++ b/lldb/source/Makefile @@ -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 diff --git a/lldb/source/lldb.cpp b/lldb/source/lldb.cpp index 75b270f..89bb485 100644 --- a/lldb/source/lldb.cpp +++ b/lldb/source/lldb.cpp @@ -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 diff --git a/lldb/tools/lldb-server/lldb-server.cpp b/lldb/tools/lldb-server/lldb-server.cpp index 83e88a8..2a07219 100644 --- a/lldb/tools/lldb-server/lldb-server.cpp +++ b/lldb/tools/lldb-server/lldb-server.cpp @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// #include "lldb/Core/Debugger.h" +#include "lldb/Initialization/InitializeLLDB.h" #include #include @@ -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(); } //---------------------------------------------------------------------- -- 2.7.4