[Lldb-commits] [PATCH] D83256: [lldb] Fix unaligned load in DataExtractor

Greg Clayton via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Mon Jul 6 16:53:56 PDT 2020


clayborg added a comment.

Just need some DataExtractorTest.cpp additions to test the unaligned loads for float and doubles?



================
Comment at: lldb/source/Utility/DataExtractor.cpp:626
 float DataExtractor::GetFloat(offset_t *offset_ptr) const {
-  typedef float float_type;
-  float_type val = 0.0;
-  const size_t src_size = sizeof(float_type);
-  const float_type *src =
-      static_cast<const float_type *>(GetData(offset_ptr, src_size));
-  if (src) {
-    if (m_byte_order != endian::InlHostByteOrder()) {
-      const uint8_t *src_data = reinterpret_cast<const uint8_t *>(src);
-      uint8_t *dst_data = reinterpret_cast<uint8_t *>(&val);
-      for (size_t i = 0; i < sizeof(float_type); ++i)
-        dst_data[sizeof(float_type) - 1 - i] = src_data[i];
-    } else {
-      val = *src;
-    }
-  }
-  return val;
+  return Get<float>(offset_ptr, 0.0);
 }
----------------
nit: "0.0f" instead of "0.0"


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83256/new/

https://reviews.llvm.org/D83256





More information about the lldb-commits mailing list