[Lldb-commits] [lldb] r186228 - Modified the expression parser to only try to

Sean Callanan scallanan at apple.com
Fri Jul 12 16:35:21 PDT 2013


Author: spyffe
Date: Fri Jul 12 18:35:21 2013
New Revision: 186228

URL: http://llvm.org/viewvc/llvm-project?rev=186228&view=rev
Log:
Modified the expression parser to only try to
write to registers if they were modified in the
expression.  This eliminates spurious errors if
the register can't be written to but the
expression didn't write to it anyway.

Also improved error handling for the materializer
to make "couldn't materialize struct" errors more
informative.

<rdar://problem/14322579>

Modified:
    lldb/trunk/source/Expression/ClangUserExpression.cpp
    lldb/trunk/source/Expression/Materializer.cpp

Modified: lldb/trunk/source/Expression/ClangUserExpression.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangUserExpression.cpp?rev=186228&r1=186227&r2=186228&view=diff
==============================================================================
--- lldb/trunk/source/Expression/ClangUserExpression.cpp (original)
+++ lldb/trunk/source/Expression/ClangUserExpression.cpp Fri Jul 12 18:35:21 2013
@@ -753,8 +753,6 @@ ClangUserExpression::FinalizeJITExecutio
                                            lldb::addr_t function_stack_bottom,
                                            lldb::addr_t function_stack_top)
 {
-    Error expr_error;
-    
     Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
     
     if (log)
@@ -762,7 +760,7 @@ ClangUserExpression::FinalizeJITExecutio
         
     if (!m_dematerializer_sp)
     {
-        error_stream.Printf ("Couldn't dematerialize struct : no dematerializer is present");
+        error_stream.Printf ("Couldn't apply expression side effects : no dematerializer is present");
         return false;
     }
     
@@ -772,7 +770,7 @@ ClangUserExpression::FinalizeJITExecutio
 
     if (!dematerialize_error.Success())
     {
-        error_stream.Printf ("Couldn't dematerialize struct : %s\n", expr_error.AsCString("unknown error"));
+        error_stream.Printf ("Couldn't apply expression side effects : %s\n", dematerialize_error.AsCString("unknown error"));
         return false;
     }
         
@@ -937,7 +935,6 @@ ClangUserExpression::Execute (Stream &er
         }
         else
         {
-            error_stream.Printf("Errored out in %s: Couldn't FinalizeJITExpression", __FUNCTION__);
             return eExecutionSetupError;
         }
     }

Modified: lldb/trunk/source/Expression/Materializer.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/Materializer.cpp?rev=186228&r1=186227&r2=186228&view=diff
==============================================================================
--- lldb/trunk/source/Expression/Materializer.cpp (original)
+++ lldb/trunk/source/Expression/Materializer.cpp Fri Jul 12 18:35:21 2013
@@ -1164,6 +1164,8 @@ public:
             return;
         }
         
+        m_register_contents.reset(new DataBufferHeap(register_data.GetDataStart(), register_data.GetByteSize()));
+        
         Error write_error;
         
         map.WriteMemory(load_addr, register_data.GetDataStart(), register_data.GetByteSize(), write_error);
@@ -1213,6 +1215,16 @@ public:
             return;
         }
         
+        if (!memcmp(register_data.GetDataStart(), m_register_contents->GetBytes(), register_data.GetByteSize()))
+        {
+            // No write required, and in particular we avoid errors if the register wasn't writable
+            
+            m_register_contents.reset();
+            return;
+        }
+        
+        m_register_contents.reset();
+        
         RegisterValue register_value (const_cast<uint8_t*>(register_data.GetDataStart()), register_data.GetByteSize(), register_data.GetByteOrder());
         
         if (!reg_context_sp->WriteRegister(&m_register_info, register_value))
@@ -1262,6 +1274,7 @@ public:
     }
 private:
     RegisterInfo m_register_info;
+    lldb::DataBufferSP m_register_contents;
 };
 
 uint32_t





More information about the lldb-commits mailing list