[Lldb-commits] [PATCH] D15738: [LLDB] Fix Read/Write memory to be compatible with both endians

Mohit Bhakkad via lldb-commits lldb-commits at lists.llvm.org
Wed Dec 23 03:44:23 PST 2015


mohit.bhakkad updated this revision to Diff 43520.
mohit.bhakkad added a comment.

Addressed comment.


Repository:
  rL LLVM

http://reviews.llvm.org/D15738

Files:
  source/Plugins/Process/Linux/NativeProcessLinux.cpp

Index: source/Plugins/Process/Linux/NativeProcessLinux.cpp
===================================================================
--- source/Plugins/Process/Linux/NativeProcessLinux.cpp
+++ source/Plugins/Process/Linux/NativeProcessLinux.cpp
@@ -2547,8 +2547,7 @@
         remainder = remainder > k_ptrace_word_size ? k_ptrace_word_size : remainder;
 
         // Copy the data into our buffer
-        for (unsigned i = 0; i < remainder; ++i)
-            dst[i] = ((data >> i*8) & 0xFF);
+        memcpy(dst, &data, remainder); 
 
         if (log && ProcessPOSIXLog::AtTopNestLevel() &&
                 (log->GetMask().Test(POSIX_LOG_MEMORY_DATA_LONG) ||
@@ -2600,8 +2599,7 @@
         if (remainder == k_ptrace_word_size)
         {
             unsigned long data = 0;
-            for (unsigned i = 0; i < k_ptrace_word_size; ++i)
-                data |= (unsigned long)src[i] << i*8;
+            memcpy(&data, src, k_ptrace_word_size);
 
             if (log && ProcessPOSIXLog::AtTopNestLevel() &&
                     (log->GetMask().Test(POSIX_LOG_MEMORY_DATA_LONG) ||


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D15738.43520.patch
Type: text/x-patch
Size: 1079 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20151223/188683ec/attachment.bin>


More information about the lldb-commits mailing list