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

2015-12-23 Thread Tamas Berghammer via lldb-commits
tberghammer added a subscriber: tberghammer.
tberghammer requested changes to this revision.
tberghammer added a reviewer: tberghammer.
This revision now requires changes to proceed.


Comment at: source/Plugins/Process/Linux/NativeProcessLinux.cpp:2549-2550
@@ -2548,6 +2548,4 @@
 
 // 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() &&

This will be a buffer overrun if "size % sizeof(long) != 0" (and also violating 
strict aliasing). I suggest to use memcpy instead what fixes both of these 
issue.


Comment at: source/Plugins/Process/Linux/NativeProcessLinux.cpp:2601
@@ -2602,4 +2600,3 @@
 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);
 

Same here


Repository:
  rL LLVM

http://reviews.llvm.org/D15738



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


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

2015-12-23 Thread Mohit Bhakkad via lldb-commits
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) ||


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) ||
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


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

2015-12-23 Thread Tamas Berghammer via lldb-commits
tberghammer added a comment.

LGTM

I can't accept it on the UI because of some bug, but you can commit it without 
waiting for Greg.


Repository:
  rL LLVM

http://reviews.llvm.org/D15738



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] r256331 - [LLDB] Fix Read/Write memory to be compatible with both endians

2015-12-23 Thread Mohit K. Bhakkad via lldb-commits
Author: mohit.bhakkad
Date: Wed Dec 23 06:34:58 2015
New Revision: 256331

URL: http://llvm.org/viewvc/llvm-project?rev=256331&view=rev
Log:
[LLDB] Fix Read/Write memory to be compatible with both endians

Reviewers: tberghammer.
Subscribers:  jaydeep, bhushan, sagar, nitesh.jain,lldb-commits.
Differential Revision: http://reviews.llvm.org/D15738

Modified:
lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.cpp

Modified: lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.cpp?rev=256331&r1=256330&r2=256331&view=diff
==
--- lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.cpp (original)
+++ lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.cpp Wed Dec 23 
06:34:58 2015
@@ -2547,8 +2547,7 @@ NativeProcessLinux::ReadMemory (lldb::ad
 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 @@ NativeProcessLinux::WriteMemory(lldb::ad
 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) ||


___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


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

2015-12-23 Thread Mohit Bhakkad via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL256331: [LLDB] Fix Read/Write memory to be compatible with 
both endians (authored by mohit.bhakkad).

Changed prior to commit:
  http://reviews.llvm.org/D15738?vs=43520&id=43522#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D15738

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

Index: lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.cpp
===
--- lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.cpp
+++ lldb/trunk/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) ||


Index: lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.cpp
===
--- lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.cpp
+++ lldb/trunk/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) ||
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


Re: [Lldb-commits] [PATCH] D15715: Don't pack the structs of the jit debug interface

2015-12-23 Thread Todd Fiala via lldb-commits
tfiala added a comment.

Sorry, late to the party.  All the same, LGTM.


Repository:
  rL LLVM

http://reviews.llvm.org/D15715



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


Re: [Lldb-commits] [PATCH] D13282: [MIPS] Emulate microMIPS instructions

2015-12-23 Thread Bhushan Attarde via lldb-commits
bhushan closed this revision.
bhushan added a comment.

This was committed on 6th Oct 15 by http://reviews.llvm.org/rL249381 ,closing 
it now.


Repository:
  rL LLVM

http://reviews.llvm.org/D13282



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits