Fix bug with register values byte order in expression evaluation.
authorAidan Dodds <aidan@codeplay.com>
Fri, 26 Feb 2016 17:40:50 +0000 (17:40 +0000)
committerAidan Dodds <aidan@codeplay.com>
Fri, 26 Feb 2016 17:40:50 +0000 (17:40 +0000)
The evaluation of expressions containing register values was broken for targets for which endianness differs from host.

Committed on behalf of: mamai <marianne.mailhot.sarrasin@gmail.com>

Differential revision: http://reviews.llvm.org/D17167

llvm-svn: 262041

lldb/source/Expression/Materializer.cpp

index 8d68b4f..53ea7f4 100644 (file)
@@ -26,6 +26,7 @@
 #include "lldb/Target/StackFrame.h"
 #include "lldb/Target/Target.h"
 #include "lldb/Target/Thread.h"
+#include "lldb/Utility/LLDBAssert.h"
 
 using namespace lldb_private;
 
@@ -1275,9 +1276,14 @@ public:
         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);
-        
+
+        Scalar scalar;
+        reg_value.GetScalarValue(scalar);
+
+        lldbassert(scalar.GetByteSize() == register_data.GetByteSize());
+
+        map.WriteScalarToMemory(load_addr, scalar, scalar.GetByteSize(), write_error);
+
         if (!write_error.Success())
         {
             err.SetErrorStringWithFormat("couldn't write the contents of register %s: %s", m_register_info.name, write_error.AsCString());