https://github.com/sedymrak updated https://github.com/llvm/llvm-project/pull/163646
From b2fb3922d6857815fb757db73036675194bcaced Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ko=C5=A1=C3=ADk?= <[email protected]> Date: Wed, 15 Oct 2025 23:52:48 +0200 Subject: [PATCH 1/2] [lldb] fix the "RegisterValue::SetValueFromData" method Fix the "RegisterValue::SetValueFromData" so that it works also for 128-bit registers that contain integers. --- lldb/source/Utility/RegisterValue.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lldb/source/Utility/RegisterValue.cpp b/lldb/source/Utility/RegisterValue.cpp index 0e99451c3b700..12c349a143c0f 100644 --- a/lldb/source/Utility/RegisterValue.cpp +++ b/lldb/source/Utility/RegisterValue.cpp @@ -199,7 +199,7 @@ Status RegisterValue::SetValueFromData(const RegisterInfo ®_info, else if (reg_info.byte_size <= 16) { uint64_t data1 = src.GetU64(&src_offset); uint64_t data2 = src.GetU64(&src_offset); - if (src.GetByteOrder() == eByteOrderBig) { + if (src.GetByteOrder() == eByteOrderLittle) { int128.x[0] = data1; int128.x[1] = data2; } else { From cc54084674d4a64d803194b39765bb76589028ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ko=C5=A1=C3=ADk?= <[email protected]> Date: Fri, 17 Oct 2025 11:28:12 +0200 Subject: [PATCH 2/2] [lldb] add tests for the "RegisterValue::SetValueFromData" method --- lldb/unittests/Utility/RegisterValueTest.cpp | 53 ++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/lldb/unittests/Utility/RegisterValueTest.cpp b/lldb/unittests/Utility/RegisterValueTest.cpp index e0863a41605e6..e34a8c2b8bdf8 100644 --- a/lldb/unittests/Utility/RegisterValueTest.cpp +++ b/lldb/unittests/Utility/RegisterValueTest.cpp @@ -7,6 +7,8 @@ //===----------------------------------------------------------------------===// #include "lldb/Utility/RegisterValue.h" +#include "lldb/lldb-private-types.h" +#include "lldb/Utility/DataExtractor.h" #include "gtest/gtest.h" #include <optional> @@ -54,3 +56,54 @@ TEST(RegisterValueTest, GetScalarValue) { Scalar((APInt(128, 0xffeeddccbbaa9988ull) << 64) | APInt(128, 0x7766554433221100))); } + +static const Scalar etalon128(APInt(128, 0xffeeddccbbaa9988ull) << 64 | + APInt(128, 0x7766554433221100ull)); + +// Test that the "RegisterValue::SetValueFromData" method works correctly +// with 128-bit little-endian data that represents an integer. +TEST(RegisterValueTest, SetValueFromData_128_le) { + 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}; + + uint8_t src[] = {0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, + 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff}; + DataExtractor src_extractor(src, 16, lldb::ByteOrder::eByteOrderLittle, 8); + EXPECT_TRUE(rv.SetValueFromData(ri, src_extractor, 0, false).Success()); + Scalar s; + EXPECT_TRUE(rv.GetScalarValue(s)); + EXPECT_EQ(s, etalon128); +} + +// Test that the "RegisterValue::SetValueFromData" method works correctly +// with 128-bit big-endian data that represents an integer. +TEST(RegisterValueTest, SetValueFromData_128_be) { + 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}; + + uint8_t src[] = {0xff, 0xee, 0xdd, 0xcc, 0xbb, 0xaa, 0x99, 0x88, + 0x77, 0x66, 0x55, 0x44, 0x33, 0x22, 0x11, 0x00}; + DataExtractor src_extractor(src, 16, lldb::ByteOrder::eByteOrderBig, 8); + EXPECT_TRUE(rv.SetValueFromData(ri, src_extractor, 0, false).Success()); + Scalar s; + EXPECT_TRUE(rv.GetScalarValue(s)); + EXPECT_EQ(s, etalon128); +} _______________________________________________ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
