[Lldb-commits] [lldb] r190877 - Use a StreamString to fix the endianness in

Sean Callanan scallanan at apple.com
Tue Sep 17 11:26:42 PDT 2013


Author: spyffe
Date: Tue Sep 17 13:26:42 2013
New Revision: 190877

URL: http://llvm.org/viewvc/llvm-project?rev=190877&view=rev
Log:
Use a StreamString to fix the endianness in
constants before using them in the IR interpreter.

Patch by FĂ©lix Cloutier.

Modified:
    lldb/trunk/source/Expression/IRInterpreter.cpp

Modified: lldb/trunk/source/Expression/IRInterpreter.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/IRInterpreter.cpp?rev=190877&r1=190876&r2=190877&view=diff
==============================================================================
--- lldb/trunk/source/Expression/IRInterpreter.cpp (original)
+++ lldb/trunk/source/Expression/IRInterpreter.cpp Tue Sep 17 13:26:42 2013
@@ -14,6 +14,7 @@
 #include "lldb/Core/StreamString.h"
 #include "lldb/Expression/IRMemoryMap.h"
 #include "lldb/Expression/IRInterpreter.h"
+#include "lldb/Host/Endian.h"
 
 #include "llvm/IR/Constants.h"
 #include "llvm/IR/DataLayout.h"
@@ -321,13 +322,19 @@ public:
         if (!ResolveConstantValue(resolved_value, constant))
             return false;
         
-        const uint64_t *raw_data = resolved_value.getRawData();
-            
+        lldb_private::StreamString buffer (lldb_private::Stream::eBinary,
+                                           m_memory_map.GetAddressByteSize(),
+                                           m_memory_map.GetByteOrder());
+        
         size_t constant_size = m_target_data.getTypeStoreSize(constant->getType());
         
+        const uint64_t *raw_data = resolved_value.getRawData();
+        
+        buffer.PutRawBytes(raw_data, constant_size, lldb::endian::InlHostByteOrder());
+        
         lldb_private::Error write_error;
         
-        m_memory_map.WriteMemory(process_address, (uint8_t*)raw_data, constant_size, write_error);
+        m_memory_map.WriteMemory(process_address, (const uint8_t*)buffer.GetData(), constant_size, write_error);
         
         return write_error.Success();
     }





More information about the lldb-commits mailing list