[Lldb-commits] [lldb] r140285 - in /lldb/trunk: include/lldb/Expression/ClangExpressionDeclMap.h source/API/SBValue.cpp source/Expression/ClangExpressionDeclMap.cpp source/Expression/IRInterpreter.cpp test/expression_command/formatters/TestFormatters.py test/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjC.py

Sean Callanan scallanan at apple.com
Wed Sep 21 17:41:12 PDT 2011


Author: spyffe
Date: Wed Sep 21 19:41:11 2011
New Revision: 140285

URL: http://llvm.org/viewvc/llvm-project?rev=140285&view=rev
Log:
Fixed a problem with the IR interpreter that caused
it to generate result variables that were not bound
to their underlying data.  This allowed the SBValue
class to use the interpreter (if possible).

Also made sure that any result variables that point
to stack allocations in the stack frame of the
interpreted expressions do not get live data.

Modified:
    lldb/trunk/include/lldb/Expression/ClangExpressionDeclMap.h
    lldb/trunk/source/API/SBValue.cpp
    lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp
    lldb/trunk/source/Expression/IRInterpreter.cpp
    lldb/trunk/test/expression_command/formatters/TestFormatters.py
    lldb/trunk/test/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjC.py

Modified: lldb/trunk/include/lldb/Expression/ClangExpressionDeclMap.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Expression/ClangExpressionDeclMap.h?rev=140285&r1=140284&r2=140285&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Expression/ClangExpressionDeclMap.h (original)
+++ lldb/trunk/include/lldb/Expression/ClangExpressionDeclMap.h Wed Sep 21 19:41:11 2011
@@ -463,6 +463,10 @@
     /// @param[in] type
     ///     The type of the data.
     ///
+    /// @param[in] transient
+    ///     True if the data should be treated as disappearing after the
+    ///     expression completes.  In that case, it gets no live data.
+    ///
     /// @return
     ///     True on success; false otherwise.
     //------------------------------------------------------------------
@@ -470,7 +474,8 @@
     CompleteResultVariable (lldb::ClangExpressionVariableSP &valobj, 
                             lldb_private::Value &value,
                             const ConstString &name,
-                            lldb_private::TypeFromParser type);
+                            lldb_private::TypeFromParser type,
+                            bool transient);
     
     //------------------------------------------------------------------
     /// [Used by CommandObjectExpression] Materialize the entire struct

Modified: lldb/trunk/source/API/SBValue.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBValue.cpp?rev=140285&r1=140284&r2=140285&view=diff
==============================================================================
--- lldb/trunk/source/API/SBValue.cpp (original)
+++ lldb/trunk/source/API/SBValue.cpp Wed Sep 21 19:41:11 2011
@@ -379,7 +379,7 @@
         ValueObjectSP result_valobj_sp;
         m_opaque_sp->GetUpdatePoint().GetTargetSP()->EvaluateExpression (expression,
                                                                          m_opaque_sp->GetUpdatePoint().GetExecutionContextScope()->CalculateStackFrame(),
-                                                                         eExecutionPolicyAlways,
+                                                                         eExecutionPolicyOnlyWhenNeeded,
                                                                          true, // unwind on error
                                                                          true, // keep in memory
                                                                          eNoDynamicValues,

Modified: lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp?rev=140285&r1=140284&r2=140285&view=diff
==============================================================================
--- lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp (original)
+++ lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp Wed Sep 21 19:41:11 2011
@@ -320,7 +320,8 @@
 ClangExpressionDeclMap::CompleteResultVariable (lldb::ClangExpressionVariableSP &valobj, 
                                                 lldb_private::Value &value,
                                                 const ConstString &name,
-                                                lldb_private::TypeFromParser type)
+                                                lldb_private::TypeFromParser type,
+                                                bool transient)
 {
     assert (m_parser_vars.get());
         
@@ -330,7 +331,8 @@
         return false;
     
     if (pvar_sp->m_flags & ClangExpressionVariable::EVIsProgramReference &&
-        !pvar_sp->m_live_sp)
+        !pvar_sp->m_live_sp &&
+        !transient)
     {
         // The reference comes from the program.  We need to set up a live SP for it.
         
@@ -927,11 +929,20 @@
     }
     else if (persistent_var_sp)
     {
-        lldb_private::Value ret;
-        ret.SetValueType(Value::eValueTypeHostAddress);
-        ret.SetContext(Value::eContextTypeInvalid, NULL);
-        ret.GetScalar() = (lldb::addr_t)persistent_var_sp->GetValueBytes();
-        return ret;
+        if ((persistent_var_sp->m_flags & ClangExpressionVariable::EVIsProgramReference ||
+             persistent_var_sp->m_flags & ClangExpressionVariable::EVIsLLDBAllocated) &&
+            persistent_var_sp->m_live_sp)
+        {
+            return persistent_var_sp->m_live_sp->GetValue();
+        }
+        else
+        {
+            lldb_private::Value ret;
+            ret.SetValueType(Value::eValueTypeHostAddress);
+            ret.SetContext(Value::eContextTypeInvalid, NULL);
+            ret.GetScalar() = (lldb::addr_t)persistent_var_sp->GetValueBytes();
+            return ret;
+        }
     }
     else
     {

Modified: lldb/trunk/source/Expression/IRInterpreter.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/IRInterpreter.cpp?rev=140285&r1=140284&r2=140285&view=diff
==============================================================================
--- lldb/trunk/source/Expression/IRInterpreter.cpp (original)
+++ lldb/trunk/source/Expression/IRInterpreter.cpp Wed Sep 21 19:41:11 2011
@@ -717,6 +717,8 @@
         
         lldb_private::Value base;
         
+        bool transient = false;
+        
         if (m_decl_map.ResultIsReference(result_name))
         {
             PointerType *R_ptr_ty = dyn_cast<PointerType>(R_ty);           
@@ -737,6 +739,9 @@
             if (!R_final.m_allocation)
                 return false;
             
+            if (R_final.m_allocation->m_data)
+                transient = true; // this is a stack allocation
+            
             base = R_final.m_allocation->m_origin;
             base.GetScalar() += (R_final.m_base - R_final.m_allocation->m_virtual_address);
         }
@@ -747,7 +752,7 @@
             base.GetScalar() = (unsigned long long)R.m_allocation->m_data->GetBytes() + (R.m_base - R.m_allocation->m_virtual_address);
         }                     
                         
-        return m_decl_map.CompleteResultVariable (result, base, result_name, result_type);
+        return m_decl_map.CompleteResultVariable (result, base, result_name, result_type, transient);
     }
 };
 

Modified: lldb/trunk/test/expression_command/formatters/TestFormatters.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/expression_command/formatters/TestFormatters.py?rev=140285&r1=140284&r2=140285&view=diff
==============================================================================
--- lldb/trunk/test/expression_command/formatters/TestFormatters.py (original)
+++ lldb/trunk/test/expression_command/formatters/TestFormatters.py Wed Sep 21 19:41:11 2011
@@ -18,16 +18,12 @@
         self.line = line_number('main.cpp',
                                 '// Stop here')
 
-    # rdar://problem/10153585 lldb ToT regression of test suite with r139772 check-in
-    @unittest2.expectedFailure
     @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin")
     def test_with_dsym(self):
         """Test expr + formatters for good interoperability."""
         self.buildDsym()
         self.do_my_test()
 
-    # rdar://problem/10153585 lldb ToT regression of test suite with r139772 check-in
-    @unittest2.expectedFailure
     def test_with_dwarf_(self):
         """Test expr + formatters for good interoperability."""
         self.buildDsym()

Modified: lldb/trunk/test/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjC.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjC.py?rev=140285&r1=140284&r2=140285&view=diff
==============================================================================
--- lldb/trunk/test/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjC.py (original)
+++ lldb/trunk/test/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjC.py Wed Sep 21 19:41:11 2011
@@ -12,7 +12,6 @@
     mydir = os.path.join("functionalities", "data-formatter", "data-formatter-objc")
 
     # rdar://problem/10153585 lldb ToT regression of test suite with r139772 check-in
-    @unittest2.expectedFailure
     @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin")
     def test_with_dsym_and_run_command(self):
         """Test data formatter commands."""
@@ -20,7 +19,6 @@
         self.data_formatter_commands()
 
     # rdar://problem/10153585 lldb ToT regression of test suite with r139772 check-in
-    @unittest2.expectedFailure
     def test_with_dwarf_and_run_command(self):
         """Test data formatter commands."""
         self.buildDwarf()





More information about the lldb-commits mailing list