summaryrefslogtreecommitdiffstats
path: root/lldb/source/Core/Debugger.cpp
diff options
context:
space:
mode:
authorRobert Flack <flackr@gmail.com>2015-03-10 18:07:47 +0000
committerRobert Flack <flackr@gmail.com>2015-03-10 18:07:47 +0000
commitf196c93172b6f7f3c34e707d46c14caec86a610e (patch)
treea531fd966fb3a7fb9aa5db3d6e20ad935f4e51ff /lldb/source/Core/Debugger.cpp
parent58913d65ad1661482009f33ba0afcb76e133fc56 (diff)
downloadbcm5719-llvm-f196c93172b6f7f3c34e707d46c14caec86a610e.tar.gz
bcm5719-llvm-f196c93172b6f7f3c34e707d46c14caec86a610e.zip
Add Debugger::InitializeForLLGS to allow ref counted LLGS initialization.
After http://reviews.llvm.org/D8133 landed as r231550 process launch on remote platform stopped working. This adds Debugger::InitializeForLLGS and tracks whether one or both of Initialize and InitializeForLLGS have been called, calling only the corresponding lldb_private::Terminate* methods as necessary. Since lldb_private::Terminate calls lldb_private::TerminateForLLGS, the latter method may be called twice if Initialize was called for both however the terminate methods ensure they are only called once after being initialized. This still maintains the reduced binary size, though it does now technically link in lldb_private::Terminate on lldb-server even though this should never be called. This should resolve the issue raised in http://reviews.llvm.org/D8133 where Debugger::Terminate assumed that there were 0 references to debugger and terminated early. Differential Revision: http://reviews.llvm.org/D8183 llvm-svn: 231808
Diffstat (limited to 'lldb/source/Core/Debugger.cpp')
-rw-r--r--lldb/source/Core/Debugger.cpp25
1 files changed, 22 insertions, 3 deletions
diff --git a/lldb/source/Core/Debugger.cpp b/lldb/source/Core/Debugger.cpp
index fb60f1f5d63..17eb92469ab 100644
--- a/lldb/source/Core/Debugger.cpp
+++ b/lldb/source/Core/Debugger.cpp
@@ -412,12 +412,24 @@ 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)
{
+ 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 @@ Debugger::Terminate ()
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 ());
OpenPOWER on IntegriCloud