mohit.bhakkad created this revision.
mohit.bhakkad added a reviewer: clayborg.
mohit.bhakkad added subscribers: jaydeep, bhushan, sagar, nitesh.jain, 
lldb-commits.
mohit.bhakkad set the repository for this revision to rL LLVM.

While copying a byte, copy a whole byte chunk instead of each bit, to make it 
compatible with both endians.

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,9 +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);
-
+        *((long*)(dst)) = data;
         if (log && ProcessPOSIXLog::AtTopNestLevel() &&
                 (log->GetMask().Test(POSIX_LOG_MEMORY_DATA_LONG) ||
                         (log->GetMask().Test(POSIX_LOG_MEMORY_DATA_SHORT) &&
@@ -2600,8 +2598,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;
+            data = *((unsigned long*)src);
 
             if (log && ProcessPOSIXLog::AtTopNestLevel() &&
                     (log->GetMask().Test(POSIX_LOG_MEMORY_DATA_LONG) ||


Index: source/Plugins/Process/Linux/NativeProcessLinux.cpp
===================================================================
--- source/Plugins/Process/Linux/NativeProcessLinux.cpp
+++ source/Plugins/Process/Linux/NativeProcessLinux.cpp
@@ -2547,9 +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);
-
+        *((long*)(dst)) = data;
         if (log && ProcessPOSIXLog::AtTopNestLevel() &&
                 (log->GetMask().Test(POSIX_LOG_MEMORY_DATA_LONG) ||
                         (log->GetMask().Test(POSIX_LOG_MEMORY_DATA_SHORT) &&
@@ -2600,8 +2598,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;
+            data = *((unsigned long*)src);
 
             if (log && ProcessPOSIXLog::AtTopNestLevel() &&
                     (log->GetMask().Test(POSIX_LOG_MEMORY_DATA_LONG) ||
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to