[Lldb-commits] [PATCH] Add assertion that byte-swapping is only performed on register-sized copies

Ed Maste emaste at freebsd.org
Tue Sep 17 11:51:55 PDT 2013


We can use DataExtractor::CopyByteOrderedData to copy a large block of memory - for example, the "memory read" first makes a temporary copy of the entire range and then extracts individual elements.  If the target and host byte orders do not match the entire block will be byte-reversed.  I believe that we should only ever reverse a block that corresponds to (some) register size.

Current target and host support is little-endian so this will have no effect today, but will identify problem areas as big-endian target support is added.

http://llvm-reviews.chandlerc.com/D1701

Files:
  source/Core/DataExtractor.cpp

Index: source/Core/DataExtractor.cpp
===================================================================
--- source/Core/DataExtractor.cpp
+++ source/Core/DataExtractor.cpp
@@ -964,6 +964,11 @@
     assert (dst_len > 0);
     assert (dst_byte_order == eByteOrderBig || dst_byte_order == eByteOrderLittle);
 
+    // Validate that if byte swapping the destination is register-sized
+    assert (dst_byte_order == m_byte_order || dst_len == 1 || dst_len == 2 ||
+            dst_len == 4 || dst_len == 8 || dst_len == 10 || dst_len == 16 ||
+            dst_len == 32);
+
     // Must have valid byte orders set in this object and for destination
     if (!(dst_byte_order == eByteOrderBig || dst_byte_order == eByteOrderLittle) ||
         !(m_byte_order == eByteOrderBig || m_byte_order == eByteOrderLittle))
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D1701.1.patch
Type: text/x-patch
Size: 809 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20130917/72dc2ae5/attachment.bin>


More information about the lldb-commits mailing list