[llvm] r357754 - Fix r357749 for big-endian architectures

Pavel Labath via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 5 01:43:54 PDT 2019


Author: labath
Date: Fri Apr  5 01:43:54 2019
New Revision: 357754

URL: http://llvm.org/viewvc/llvm-project?rev=357754&view=rev
Log:
Fix r357749 for big-endian architectures

We need to read the strings from the minidump files as little-endian,
regardless of the host byte order.

I definitely remember thinking about this case while writing the patch
(and in fact, I have implemented that for the "write" case), but somehow
I have ended up not implementing the byte swapping when reading the
data. This adds the necessary byte-swapping and should hopefully fix
test failures on big-endian bots.

Modified:
    llvm/trunk/lib/Object/Minidump.cpp

Modified: llvm/trunk/lib/Object/Minidump.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/Minidump.cpp?rev=357754&r1=357753&r2=357754&view=diff
==============================================================================
--- llvm/trunk/lib/Object/Minidump.cpp (original)
+++ llvm/trunk/lib/Object/Minidump.cpp Fri Apr  5 01:43:54 2019
@@ -38,12 +38,16 @@ Expected<std::string> MinidumpFile::getS
     return "";
 
   Offset += sizeof(support::ulittle32_t);
-  auto ExpectedData = getDataSliceAs<UTF16>(getData(), Offset, Size);
+  auto ExpectedData =
+      getDataSliceAs<support::ulittle16_t>(getData(), Offset, Size);
   if (!ExpectedData)
     return ExpectedData.takeError();
 
+  SmallVector<UTF16, 32> WStr(Size);
+  copy(*ExpectedData, WStr.begin());
+
   std::string Result;
-  if (!convertUTF16ToUTF8String(*ExpectedData, Result))
+  if (!convertUTF16ToUTF8String(WStr, Result))
     return createError("String decoding failed");
 
   return Result;




More information about the llvm-commits mailing list