diff options
-rw-r--r-- | lldb/include/lldb/Interpreter/PythonDataObjects.h | 3 | ||||
-rw-r--r-- | lldb/source/Interpreter/PythonDataObjects.cpp | 6 | ||||
-rw-r--r-- | lldb/source/Interpreter/ScriptInterpreterPython.cpp | 6 |
3 files changed, 10 insertions, 5 deletions
diff --git a/lldb/include/lldb/Interpreter/PythonDataObjects.h b/lldb/include/lldb/Interpreter/PythonDataObjects.h index 55df4fd1b0a..63f1ad5f67b 100644 --- a/lldb/include/lldb/Interpreter/PythonDataObjects.h +++ b/lldb/include/lldb/Interpreter/PythonDataObjects.h @@ -98,6 +98,9 @@ namespace lldb_private { return m_py_obj != NULL; } + bool + IsNULLOrNone () const; + protected: PyObject* m_py_obj; }; diff --git a/lldb/source/Interpreter/PythonDataObjects.cpp b/lldb/source/Interpreter/PythonDataObjects.cpp index 01f2754a2cc..053ff34b9d7 100644 --- a/lldb/source/Interpreter/PythonDataObjects.cpp +++ b/lldb/source/Interpreter/PythonDataObjects.cpp @@ -84,6 +84,12 @@ PythonObject::Str () return PythonString(str); } +bool +PythonObject::IsNULLOrNone () const +{ + return ((m_py_obj == nullptr) || (m_py_obj == Py_None)); +} + //---------------------------------------------------------------------- // PythonString //---------------------------------------------------------------------- diff --git a/lldb/source/Interpreter/ScriptInterpreterPython.cpp b/lldb/source/Interpreter/ScriptInterpreterPython.cpp index 624a662e26b..f0c32b45b49 100644 --- a/lldb/source/Interpreter/ScriptInterpreterPython.cpp +++ b/lldb/source/Interpreter/ScriptInterpreterPython.cpp @@ -2278,7 +2278,6 @@ ScriptInterpreterPython::LoadScriptingModule (const char* pathname, command_stream.Clear(); command_stream.Printf("sys.modules.__contains__('%s')",basename.c_str()); bool does_contain = false; - int refcount = 0; // this call will succeed if the module was ever imported in any Debugger in the lifetime of the process // in which this LLDB framework is living bool was_imported_globally = (ExecuteOneLineWithReturn(command_stream.GetData(), @@ -2288,10 +2287,7 @@ ScriptInterpreterPython::LoadScriptingModule (const char* pathname, // this call will fail if the module was not imported in this Debugger before command_stream.Clear(); command_stream.Printf("sys.getrefcount(%s)",basename.c_str()); - bool was_imported_locally = (ExecuteOneLineWithReturn(command_stream.GetData(), - ScriptInterpreterPython::eScriptReturnTypeInt, - &refcount, - ScriptInterpreter::ExecuteScriptOptions().SetEnableIO(false).SetSetLLDBGlobals(false)) && refcount > 0); + bool was_imported_locally = !(GetSessionDictionary().GetItemForKey(basename.c_str()).IsNULLOrNone()); bool was_imported = (was_imported_globally || was_imported_locally); |