REPOSITORY
rL LLVM
http://reviews.llvm.org/D8183
Files:
lldb/trunk/include/lldb/Core/Debugger.h
lldb/trunk/source/Core/Debugger.cpp
lldb/trunk/source/lldb.cpp
lldb/trunk/tools/lldb-server/lldb-server.cpp
EMAIL PREFERENCES
http://reviews.llvm.org/settings/panel/emailpreferences/
Index: lldb/trunk/include/lldb/Core/Debugger.h
===================================================================
--- lldb/trunk/include/lldb/Core/Debugger.h
+++ lldb/trunk/include/lldb/Core/Debugger.h
@@ -69,6 +69,9 @@
FindTargetWithProcess (Process *process);
static void
+ InitializeForLLGS (LoadPluginCallbackType load_plugin_callback);
+
+ static void
Initialize (LoadPluginCallbackType load_plugin_callback);
static void
Index: lldb/trunk/source/Core/Debugger.cpp
===================================================================
--- lldb/trunk/source/Core/Debugger.cpp
+++ lldb/trunk/source/Core/Debugger.cpp
@@ -412,12 +412,24 @@
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)
{
+ lldb_initialized = true;
+ g_shared_debugger_refcount++;
g_load_plugin_callback = load_plugin_callback;
- if (g_shared_debugger_refcount++ == 0)
- lldb_private::Initialize();
+ lldb_private::Initialize();
}
void
@@ -429,7 +441,14 @@
if (g_shared_debugger_refcount == 0)
{
lldb_private::WillTerminate();
- lldb_private::Terminate();
+ 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 ());
Index: lldb/trunk/source/lldb.cpp
===================================================================
--- lldb/trunk/source/lldb.cpp
+++ lldb/trunk/source/lldb.cpp
@@ -109,17 +109,17 @@
::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);
- static bool g_inited = false;
Mutex::Locker locker(g_inited_mutex);
- if (!g_inited)
+ if (!g_inited_for_llgs)
{
- g_inited = true;
+ g_inited_for_llgs = true;
#if defined(_MSC_VER)
const char *disable_crash_dialog_var = getenv("LLDB_DISABLE_CRASH_DIALOG");
@@ -186,27 +186,26 @@
PlatformDarwinKernel::Initialize();
ObjectFileMachO::Initialize();
#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);
- static bool g_inited = false;
InitializeForLLGS();
Mutex::Locker locker(g_inited_mutex);
if (!g_inited)
{
g_inited = true;
-#ifndef LLDB_DISABLE_PYTHON
- ScriptInterpreterPython::InitializePrivate();
- OperatingSystemPython::Initialize();
-#endif
-
// Initialize LLVM and Clang
llvm::InitializeAllTargets();
llvm::InitializeAllAsmPrinters();
@@ -271,89 +270,99 @@
void
lldb_private::TerminateLLGS ()
{
- Timer scoped_timer (__PRETTY_FUNCTION__, __PRETTY_FUNCTION__);
- ObjectContainerBSDArchive::Terminate();
- ObjectFileELF::Terminate();
- SymbolVendorELF::Terminate();
- SymbolFileDWARF::Terminate();
- SymbolFileSymtab::Terminate();
- UnwindAssembly_x86::Terminate();
- UnwindAssemblyInstEmulation::Terminate();
- EmulateInstructionARM::Terminate ();
- EmulateInstructionARM64::Terminate ();
- ObjectFilePECOFF::Terminate ();
- DynamicLoaderPOSIXDYLD::Terminate ();
- PlatformFreeBSD::Terminate();
- PlatformLinux::Terminate();
- PlatformWindows::Terminate();
- PlatformKalimba::Terminate();
- PlatformAndroid::Terminate();
- SymbolFileDWARFDebugMap::Terminate();
- ItaniumABILanguageRuntime::Terminate();
- DynamicLoaderMacOSXDYLD::Terminate();
- AppleObjCRuntimeV2::Terminate();
- AppleObjCRuntimeV1::Terminate();
- ObjectContainerUniversalMachO::Terminate();
- PlatformMacOSX::Terminate();
- PlatformRemoteiOS::Terminate();
- PlatformiOSSimulator::Terminate();
- SystemRuntimeMacOSX::Terminate();
+ if (g_inited_for_llgs)
+ {
+ g_inited_for_llgs = false;
+
+ Timer scoped_timer (__PRETTY_FUNCTION__, __PRETTY_FUNCTION__);
+ ObjectContainerBSDArchive::Terminate();
+ ObjectFileELF::Terminate();
+ SymbolVendorELF::Terminate();
+ SymbolFileDWARF::Terminate();
+ SymbolFileSymtab::Terminate();
+ UnwindAssembly_x86::Terminate();
+ UnwindAssemblyInstEmulation::Terminate();
+ EmulateInstructionARM::Terminate ();
+ EmulateInstructionARM64::Terminate ();
+ ObjectFilePECOFF::Terminate ();
+ DynamicLoaderPOSIXDYLD::Terminate ();
+ PlatformFreeBSD::Terminate();
+ PlatformLinux::Terminate();
+ PlatformWindows::Terminate();
+ PlatformKalimba::Terminate();
+ PlatformAndroid::Terminate();
+ SymbolFileDWARFDebugMap::Terminate();
+ ItaniumABILanguageRuntime::Terminate();
+ DynamicLoaderMacOSXDYLD::Terminate();
+ AppleObjCRuntimeV2::Terminate();
+ AppleObjCRuntimeV1::Terminate();
+ ObjectContainerUniversalMachO::Terminate();
+ PlatformMacOSX::Terminate();
+ PlatformRemoteiOS::Terminate();
+ PlatformiOSSimulator::Terminate();
+ SystemRuntimeMacOSX::Terminate();
#if defined (__APPLE__)
- DynamicLoaderDarwinKernel::Terminate();
- ObjectFileMachO::Terminate();
- PlatformDarwinKernel::Terminate();
- SymbolVendorMacOSX::Terminate();
+ DynamicLoaderDarwinKernel::Terminate();
+ ObjectFileMachO::Terminate();
+ PlatformDarwinKernel::Terminate();
+ SymbolVendorMacOSX::Terminate();
+#endif
+
+#ifndef LLDB_DISABLE_PYTHON
+ OperatingSystemPython::Terminate();
#endif
- Log::Terminate();
+ Log::Terminate();
+ }
}
void
lldb_private::Terminate ()
{
- Timer scoped_timer (__PRETTY_FUNCTION__, __PRETTY_FUNCTION__);
- // Terminate and unload and loaded system or user LLDB plug-ins
- PluginManager::Terminate();
- ABIMacOSX_i386::Terminate();
- ABIMacOSX_arm::Terminate();
- ABIMacOSX_arm64::Terminate();
- ABISysV_x86_64::Terminate();
- ABISysV_ppc::Terminate();
- ABISysV_ppc64::Terminate();
- DisassemblerLLVMC::Terminate();
-
- JITLoaderGDB::Terminate();
- ProcessElfCore::Terminate();
- MemoryHistoryASan::Terminate();
- AddressSanitizerRuntime::Terminate();
+ if (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();
#if defined (__APPLE__)
- ProcessMachCore::Terminate();
- ProcessKDP::Terminate();
+ ProcessMachCore::Terminate();
+ ProcessKDP::Terminate();
#endif
#if defined(_MSC_VER)
- DynamicLoaderWindows::Terminate();
+ DynamicLoaderWindows::Terminate();
#endif
#if defined (__linux__)
- ProcessLinux::Terminate();
+ ProcessLinux::Terminate();
#endif
#if defined (__FreeBSD__)
- ProcessFreeBSD::Terminate();
+ ProcessFreeBSD::Terminate();
#endif
- Debugger::SettingsTerminate ();
+ Debugger::SettingsTerminate ();
- PlatformRemoteGDBServer::Terminate();
- ProcessGDBRemote::Terminate();
- DynamicLoaderStatic::Terminate();
+ PlatformRemoteGDBServer::Terminate();
+ ProcessGDBRemote::Terminate();
+ DynamicLoaderStatic::Terminate();
-#ifndef LLDB_DISABLE_PYTHON
- OperatingSystemPython::Terminate();
-#endif
-
- TerminateLLGS();
+ TerminateLLGS();
+ }
}
#if defined (__APPLE__)
Index: lldb/trunk/tools/lldb-server/lldb-server.cpp
===================================================================
--- lldb/trunk/tools/lldb-server/lldb-server.cpp
+++ lldb/trunk/tools/lldb-server/lldb-server.cpp
@@ -7,7 +7,7 @@
//
//===----------------------------------------------------------------------===//
-#include "lldb/lldb-private.h"
+#include "lldb/Core/Debugger.h"
#include <stdio.h>
#include <stdlib.h>
@@ -29,14 +29,13 @@
static void
initialize ()
{
- lldb_private::InitializeForLLGS();
+ lldb_private::Debugger::InitializeForLLGS(NULL);
}
static void
terminate ()
{
- lldb_private::WillTerminate();
- lldb_private::TerminateLLGS();
+ lldb_private::Debugger::Terminate();
}
//----------------------------------------------------------------------
_______________________________________________
lldb-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits