[Lldb-commits] [lldb] r201623 - <rdar://problem/15906684>

Enrico Granata egranata at apple.com
Tue Feb 18 17:45:23 PST 2014


Author: enrico
Date: Tue Feb 18 19:45:22 2014
New Revision: 201623

URL: http://llvm.org/viewvc/llvm-project?rev=201623&view=rev
Log:
<rdar://problem/15906684>

The way in which we were determining whether a python module had already been imported in the current session stopped working due to the IOHandler changes
As a result, importing in a new debug session a module which had been imported in a previous session did not work
This commit restores that functionality by checking for the module's presence in the session dictionary (which should be more correct anyway)


Modified:
    lldb/trunk/include/lldb/Interpreter/PythonDataObjects.h
    lldb/trunk/source/Interpreter/PythonDataObjects.cpp
    lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp

Modified: lldb/trunk/include/lldb/Interpreter/PythonDataObjects.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/PythonDataObjects.h?rev=201623&r1=201622&r2=201623&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Interpreter/PythonDataObjects.h (original)
+++ lldb/trunk/include/lldb/Interpreter/PythonDataObjects.h Tue Feb 18 19:45:22 2014
@@ -98,6 +98,9 @@ namespace lldb_private {
             return m_py_obj != NULL;
         }
         
+        bool
+        IsNULLOrNone () const;
+        
     protected:
         PyObject* m_py_obj;
     };

Modified: lldb/trunk/source/Interpreter/PythonDataObjects.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/PythonDataObjects.cpp?rev=201623&r1=201622&r2=201623&view=diff
==============================================================================
--- lldb/trunk/source/Interpreter/PythonDataObjects.cpp (original)
+++ lldb/trunk/source/Interpreter/PythonDataObjects.cpp Tue Feb 18 19:45:22 2014
@@ -84,6 +84,12 @@ PythonObject::Str ()
     return PythonString(str);
 }
 
+bool
+PythonObject::IsNULLOrNone () const
+{
+    return ((m_py_obj == nullptr) || (m_py_obj == Py_None));
+}
+
 //----------------------------------------------------------------------
 // PythonString
 //----------------------------------------------------------------------

Modified: lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp?rev=201623&r1=201622&r2=201623&view=diff
==============================================================================
--- lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp (original)
+++ lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp Tue Feb 18 19:45:22 2014
@@ -2278,7 +2278,6 @@ ScriptInterpreterPython::LoadScriptingMo
         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::LoadScriptingMo
         // 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);
         





More information about the lldb-commits mailing list