DavidSpickett wrote:

My idea with the fake target is going to be way too much work, the unittests is 
a better idea.

I got this to fail:
```
diff --git a/lldb/unittests/Utility/RegisterValueTest.cpp 
b/lldb/unittests/Utility/RegisterValueTest.cpp
index e0863a41605e..55fb3a2b05ad 100644
--- a/lldb/unittests/Utility/RegisterValueTest.cpp
+++ b/lldb/unittests/Utility/RegisterValueTest.cpp
@@ -7,6 +7,9 @@
 
//===----------------------------------------------------------------------===//
 
 #include "lldb/Utility/RegisterValue.h"
+#include "lldb/Utility/DataExtractor.h"
+#include "lldb/lldb-enumerations.h"
+#include "lldb/lldb-private-types.h"
 #include "gtest/gtest.h"
 #include <optional>
 
@@ -54,3 +57,28 @@ TEST(RegisterValueTest, GetScalarValue) {
             Scalar((APInt(128, 0xffeeddccbbaa9988ull) << 64) |
                    APInt(128, 0x7766554433221100)));
 }
+
+TEST(RegisterValueTest, SetValueFromData) {
+  RegisterValue rv;
+  RegisterInfo ri {
+    "uint128_register", nullptr, 16, 0, lldb::Encoding::eEncodingUint,
+    lldb::Format::eFormatDefault, {0, 0, 0, LLDB_INVALID_REGNUM, 0},
+    nullptr, nullptr, nullptr
+  };
+
+  uint64_t src[] = {0x7766554433221100, 0xffeeddccbbaa9988};
+  DataExtractor src_extractor(src, 16, lldb::ByteOrder::eByteOrderLittle, 8);
+  rv.SetValueFromData(ri, src_extractor, /*src_offset=*/0, 
/*partial_data_ok=*/false);
+
+  // Copied from above.
+  const auto &Get = [](const RegisterValue &V) -> std::optional<Scalar> {
+    Scalar S;
+    if (V.GetScalarValue(S))
+      return S;
+    return std::nullopt;
+  };
+
+  EXPECT_EQ(Get(rv),
+    Scalar((APInt(128, 0xffeeddccbbaa9988ull) << 64) |
+                   APInt(128, 0x7766554433221100ull)));
+}
```
You can use that if you can confirm that your change fixes it. May need 
repeating for little and big endian extractors, though that may also swap the 
order within the uint64s so watch out for that.

https://github.com/llvm/llvm-project/pull/163646
_______________________________________________
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to