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
This commit is contained in:
Tamas Berghammer
2015-02-12 18:18:27 +00:00
parent 00e305d281
commit 3c4f89d702
14 changed files with 82 additions and 2 deletions

View File

@@ -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" : "");