diff options
author | Tamas Berghammer <tberghammer@google.com> | 2015-02-12 18:18:27 +0000 |
---|---|---|
committer | Tamas Berghammer <tberghammer@google.com> | 2015-02-12 18:18:27 +0000 |
commit | 3c4f89d7029ad73ce25c798ab2109d3eea7d7151 (patch) | |
tree | 5e50a26030f9716cecc97028253e6bf4662a299a /lldb/source/Target | |
parent | 00e305d281502a9b4d90dc02aa4c7dad819a9083 (diff) | |
download | bcm5719-llvm-3c4f89d7029ad73ce25c798ab2109d3eea7d7151.tar.gz bcm5719-llvm-3c4f89d7029ad73ce25c798ab2109d3eea7d7151.zip |
Add Initialize/Terminate method to Platform base plugin
Platform holds a smart pointer to each platform object created in a
static variable what cause the platform destructors called only on
program exit when other static variables are not availables. With this
change the destructors are called on lldb_private::Terminate()
+ Fix DebuggerRefCount handling in ScriptInterpreterPython
Differential Revision: http://reviews.llvm.org/D7590
llvm-svn: 228944
Diffstat (limited to 'lldb/source/Target')
-rw-r--r-- | lldb/source/Target/Platform.cpp | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/lldb/source/Target/Platform.cpp b/lldb/source/Target/Platform.cpp index f4c387ad691..97be08490e4 100644 --- a/lldb/source/Target/Platform.cpp +++ b/lldb/source/Target/Platform.cpp @@ -29,7 +29,9 @@ using namespace lldb; using namespace lldb_private; - + +static uint32_t g_initialize_count = 0; + // Use a singleton function for g_local_platform_sp to avoid init // constructors since LLDB is often part of a shared library static PlatformSP& @@ -76,6 +78,25 @@ GetPlatformListMutex () } void +Platform::Initialize () +{ + g_initialize_count++; +} + +void +Platform::Terminate () +{ + if (g_initialize_count > 0) + { + if (--g_initialize_count == 0) + { + Mutex::Locker locker(GetPlatformListMutex ()); + GetPlatformList().clear(); + } + } +} + +void Platform::SetHostPlatform (const lldb::PlatformSP &platform_sp) { // The native platform should use its static void Platform::Initialize() |