summaryrefslogtreecommitdiffstats
path: root/lldb/source/Interpreter/ScriptInterpreterPython.cpp
diff options
context:
space:
mode:
authorTodd Fiala <tfiala@google.com>2014-01-30 20:19:22 +0000
committerTodd Fiala <tfiala@google.com>2014-01-30 20:19:22 +0000
commit3452df6723a5f8334ab0af0e0bcf33ec24a7d919 (patch)
tree27f56dc18cad29b9b966837d2992ddc22d1d0569 /lldb/source/Interpreter/ScriptInterpreterPython.cpp
parent00aa75b774bc1808aa7522dd527f55ec045f9139 (diff)
downloadbcm5719-llvm-3452df6723a5f8334ab0af0e0bcf33ec24a7d919.tar.gz
bcm5719-llvm-3452df6723a5f8334ab0af0e0bcf33ec24a7d919.zip
Fixed b18655: cleaned up script interpreter file reference handling.
This change addresses shutdown crashes in the python lldb module when the script interpreter was hanging on to saved file references after leaving a session. It also gets rid of extra references to the stdin/stdout/stderr python file objects that are created when entering the session. This change also moves the bundled pyexpect 2.4 library to the front of the python library path so that a python distribution default pyexpect (2.3 in Ubuntu 12.04) is not picked up first. llvm-svn: 200486
Diffstat (limited to 'lldb/source/Interpreter/ScriptInterpreterPython.cpp')
-rw-r--r--lldb/source/Interpreter/ScriptInterpreterPython.cpp27
1 files changed, 22 insertions, 5 deletions
diff --git a/lldb/source/Interpreter/ScriptInterpreterPython.cpp b/lldb/source/Interpreter/ScriptInterpreterPython.cpp
index fe81e67c73c..a926fce90c2 100644
--- a/lldb/source/Interpreter/ScriptInterpreterPython.cpp
+++ b/lldb/source/Interpreter/ScriptInterpreterPython.cpp
@@ -352,11 +352,20 @@ ScriptInterpreterPython::LeaveSession ()
if (sys_module_dict)
{
if (m_saved_stdin)
+ {
sys_module_dict.SetItemForKey("stdin", m_saved_stdin);
+ m_saved_stdin.Reset ();
+ }
if (m_saved_stdout)
+ {
sys_module_dict.SetItemForKey("stdout", m_saved_stdout);
+ m_saved_stdout.Reset ();
+ }
if (m_saved_stderr)
+ {
sys_module_dict.SetItemForKey("stderr", m_saved_stderr);
+ m_saved_stderr.Reset ();
+ }
}
}
@@ -422,8 +431,10 @@ ScriptInterpreterPython::EnterSession (bool init_lldb_globals,
if (in)
{
m_saved_stdin.Reset(sys_module_dict.GetItemForKey("stdin"));
-
- sys_module_dict.SetItemForKey ("stdin", PyFile_FromFile (in, (char *) "", (char *) "r", 0));
+
+ PyObject *new_file = PyFile_FromFile (in, (char *) "", (char *) "r", 0);
+ sys_module_dict.SetItemForKey ("stdin", new_file);
+ Py_DECREF (new_file);
}
else
m_saved_stdin.Reset();
@@ -433,7 +444,10 @@ ScriptInterpreterPython::EnterSession (bool init_lldb_globals,
if (out)
{
m_saved_stdout.Reset(sys_module_dict.GetItemForKey("stdout"));
- sys_module_dict.SetItemForKey ("stdout", PyFile_FromFile (out, (char *) "", (char *) "w", 0));
+
+ PyObject *new_file = PyFile_FromFile (out, (char *) "", (char *) "w", 0);
+ sys_module_dict.SetItemForKey ("stdout", new_file);
+ Py_DECREF (new_file);
}
else
m_saved_stdout.Reset();
@@ -443,10 +457,13 @@ ScriptInterpreterPython::EnterSession (bool init_lldb_globals,
if (err)
{
m_saved_stderr.Reset(sys_module_dict.GetItemForKey("stderr"));
- sys_module_dict.SetItemForKey ("stderr", PyFile_FromFile (err, (char *) "", (char *) "w", 0));
+
+ PyObject *new_file = PyFile_FromFile (err, (char *) "", (char *) "w", 0);
+ sys_module_dict.SetItemForKey ("stderr", new_file);
+ Py_DECREF (new_file);
}
else
- m_saved_stdout.Reset();
+ m_saved_stderr.Reset();
}
if (PyErr_Occurred())
OpenPOWER on IntegriCloud