summaryrefslogtreecommitdiffstats
path: root/lldb/source/Interpreter/ScriptInterpreterPython.cpp
diff options
context:
space:
mode:
authorTamas Berghammer <tberghammer@google.com>2015-02-12 18:18:27 +0000
committerTamas Berghammer <tberghammer@google.com>2015-02-12 18:18:27 +0000
commit3c4f89d7029ad73ce25c798ab2109d3eea7d7151 (patch)
tree5e50a26030f9716cecc97028253e6bf4662a299a /lldb/source/Interpreter/ScriptInterpreterPython.cpp
parent00e305d281502a9b4d90dc02aa4c7dad819a9083 (diff)
downloadbcm5719-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/Interpreter/ScriptInterpreterPython.cpp')
-rw-r--r--lldb/source/Interpreter/ScriptInterpreterPython.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/lldb/source/Interpreter/ScriptInterpreterPython.cpp b/lldb/source/Interpreter/ScriptInterpreterPython.cpp
index 8155cbb189f..84472411e0f 100644
--- a/lldb/source/Interpreter/ScriptInterpreterPython.cpp
+++ b/lldb/source/Interpreter/ScriptInterpreterPython.cpp
@@ -2825,8 +2825,20 @@ ScriptInterpreterPython::InitializePrivate ()
}
}
+ // Importing 'lldb' module calls SBDebugger::Initialize, which calls Debugger::Initialize, which increments a
+ // global debugger ref-count; therefore we need to check the ref-count before and after importing lldb, and if the
+ // ref-count increased we need to call Debugger::Terminate here to decrement the ref-count so that when the final
+ // call to Debugger::Terminate is made, the ref-count has the correct value.
+
+ int old_count = Debugger::TestDebuggerRefCount ();
+
PyRun_SimpleString ("sys.dont_write_bytecode = 1; import lldb.embedded_interpreter; from lldb.embedded_interpreter import run_python_interpreter; from lldb.embedded_interpreter import run_one_line");
+ int new_count = Debugger::TestDebuggerRefCount ();
+
+ if (new_count > old_count)
+ Debugger::Terminate ();
+
if (threads_already_initialized) {
if (log)
log->Printf("Releasing PyGILState. Returning to state = %slocked\n", gstate == PyGILState_UNLOCKED ? "un" : "");
OpenPOWER on IntegriCloud