[Lldb-commits] [lldb] r121739 - in /lldb/trunk: include/lldb/Expression/ClangExpressionDeclMap.h include/lldb/Expression/ClangUserExpression.h source/Expression/ClangExpressionDeclMap.cpp source/Expression/ClangUserExpression.cpp source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp

Sean Callanan scallanan at apple.com
Mon Dec 13 16:42:36 PST 2010


Author: spyffe
Date: Mon Dec 13 18:42:36 2010
New Revision: 121739

URL: http://llvm.org/viewvc/llvm-project?rev=121739&view=rev
Log:
Bugfixes for the new "self" pointer handling.  Specifically,
the code to pass the _cmd pointer has been improved, and _cmd
is now set to the value of _cmd for the current context, as
opposed to being simply NULL.

Modified:
    lldb/trunk/include/lldb/Expression/ClangExpressionDeclMap.h
    lldb/trunk/include/lldb/Expression/ClangUserExpression.h
    lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp
    lldb/trunk/source/Expression/ClangUserExpression.cpp
    lldb/trunk/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp
    lldb/trunk/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp

Modified: lldb/trunk/include/lldb/Expression/ClangExpressionDeclMap.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Expression/ClangExpressionDeclMap.h?rev=121739&r1=121738&r2=121739&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Expression/ClangExpressionDeclMap.h (original)
+++ lldb/trunk/include/lldb/Expression/ClangExpressionDeclMap.h Mon Dec 13 18:42:36 2010
@@ -302,13 +302,17 @@
     ///     An Error to populate with any messages related to
     ///     finding the "this" pointer.
     ///
+    /// @param[in] suppress_type_check
+    ///     True if the type is not needed.
+    ///
     /// @return
     ///     True on success; false otherwise.
     //------------------------------------------------------------------
     bool GetObjectPointer(lldb::addr_t &object_ptr,
                           ConstString &object_name,
                           ExecutionContext &exe_ctx,
-                          Error &error);
+                          Error &error,
+                          bool suppress_type_check = false);
     
     //------------------------------------------------------------------
     /// [Used by CommandObjectExpression] Pretty-print a materialized

Modified: lldb/trunk/include/lldb/Expression/ClangUserExpression.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Expression/ClangUserExpression.h?rev=121739&r1=121738&r2=121739&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Expression/ClangUserExpression.h (original)
+++ lldb/trunk/include/lldb/Expression/ClangUserExpression.h Mon Dec 13 18:42:36 2010
@@ -257,7 +257,8 @@
     PrepareToExecuteJITExpression (Stream &error_stream,
                                    ExecutionContext &exe_ctx,
                                    lldb::addr_t &struct_address,
-                                   lldb::addr_t &object_ptr);
+                                   lldb::addr_t &object_ptr,
+                                   lldb::addr_t &cmd_ptr);
     
     std::string                                 m_expr_text;            ///< The text of the expression, as typed by the user
     std::string                                 m_expr_prefix;          ///< The text of the translation-level definitions, as provided by the user

Modified: lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp?rev=121739&r1=121738&r2=121739&view=diff
==============================================================================
--- lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp (original)
+++ lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp Mon Dec 13 18:42:36 2010
@@ -373,7 +373,8 @@
     lldb::addr_t &object_ptr,
     ConstString &object_name,
     ExecutionContext &exe_ctx,
-    Error &err
+    Error &err,
+    bool suppress_type_check
 )
 {
     assert (m_struct_vars.get());
@@ -390,7 +391,9 @@
         return false;
     }
     
-    Variable *object_ptr_var = FindVariableInScope (*exe_ctx.frame, object_name, &m_struct_vars->m_object_pointer_type);
+    Variable *object_ptr_var = FindVariableInScope (*exe_ctx.frame,
+                                                    object_name, 
+                                                    (suppress_type_check ? NULL : &m_struct_vars->m_object_pointer_type));
     
     if (!object_ptr_var)
     {

Modified: lldb/trunk/source/Expression/ClangUserExpression.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangUserExpression.cpp?rev=121739&r1=121738&r2=121739&view=diff
==============================================================================
--- lldb/trunk/source/Expression/ClangUserExpression.cpp (original)
+++ lldb/trunk/source/Expression/ClangUserExpression.cpp Mon Dec 13 18:42:36 2010
@@ -312,7 +312,8 @@
 ClangUserExpression::PrepareToExecuteJITExpression (Stream &error_stream,
                                                     ExecutionContext &exe_ctx,
                                                     lldb::addr_t &struct_address,
-                                                    lldb::addr_t &object_ptr)
+                                                    lldb::addr_t &object_ptr,
+                                                    lldb::addr_t &cmd_ptr)
 {
     lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
 
@@ -343,6 +344,17 @@
                 error_stream.Printf("Couldn't get required object pointer: %s\n", materialize_error.AsCString());
                 return false;
             }
+            
+            if (m_objectivec)
+            {
+                ConstString cmd_name("_cmd");
+                
+                if (!(m_expr_decl_map->GetObjectPointer(cmd_ptr, cmd_name, exe_ctx, materialize_error, true)))
+                {
+                    error_stream.Printf("Couldn't get required object pointer: %s\n", materialize_error.AsCString());
+                    return false;
+                }
+            }
         }
                 
         if (!m_expr_decl_map->Materialize(exe_ctx, struct_address, materialize_error))
@@ -391,7 +403,7 @@
     lldb::addr_t object_ptr = NULL;
     lldb::addr_t cmd_ptr = NULL;
     
-    PrepareToExecuteJITExpression (error_stream, exe_ctx, struct_address, object_ptr);
+    PrepareToExecuteJITExpression (error_stream, exe_ctx, struct_address, object_ptr, cmd_ptr);
     
     // FIXME: This should really return a ThreadPlanCallUserExpression, in order to make sure that we don't release the
     // ClangUserExpression resources before the thread plan finishes execution in the target.  But because we are 
@@ -466,7 +478,7 @@
         lldb::addr_t object_ptr = NULL;
         lldb::addr_t cmd_ptr = NULL;
         
-        if (!PrepareToExecuteJITExpression (error_stream, exe_ctx, struct_address, object_ptr))
+        if (!PrepareToExecuteJITExpression (error_stream, exe_ctx, struct_address, object_ptr, cmd_ptr))
             return Process::eExecutionSetupError;
         
         const bool stop_others = true;

Modified: lldb/trunk/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp?rev=121739&r1=121738&r2=121739&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp (original)
+++ lldb/trunk/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp Mon Dec 13 18:42:36 2010
@@ -102,7 +102,7 @@
         if (thread.GetProcess().WriteMemory(sp + 4, &argU32, sizeof(argU32), error) != sizeof(argU32))
             return false;
     }
-    if (this_arg)
+    else if (this_arg)
     {
         uint32_t this_argU32 = *this_arg & 0xffffffffull;
         uint32_t argU32 = arg & 0xffffffffull;

Modified: lldb/trunk/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp?rev=121739&r1=121738&r2=121739&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp (original)
+++ lldb/trunk/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp Mon Dec 13 18:42:36 2010
@@ -109,15 +109,16 @@
         if (log)
             log->Printf("About to write '_cmd' (0x%llx) into RSI", (uint64_t)*cmd_arg);
         
-        if (!reg_ctx->WriteRegisterFromUnsigned(rsiID, *this_arg))
+        if (!reg_ctx->WriteRegisterFromUnsigned(rsiID, *cmd_arg))
             return false;
         
         if (log)
             log->Printf("About to write the argument (0x%llx) into RDX", (uint64_t)arg);
         
         if (!reg_ctx->WriteRegisterFromUnsigned(rdxID, arg))
-            return false;    }
-    if (this_arg)
+            return false;    
+    }
+    else if (this_arg)
     {
         if (log)
             log->PutCString("The trivial call has a this pointer");





More information about the lldb-commits mailing list