[Lldb-commits] [lldb] 1fb8e3d - [lldb] Support integer registers with more than 64 bits. (#166363)
via lldb-commits
lldb-commits at lists.llvm.org
Tue Nov 18 08:40:36 PST 2025
Author: Matej Košík
Date: 2025-11-18T08:40:31-08:00
New Revision: 1fb8e3d76e87a6c6f0d8fc7aa4e7ed75e3641fee
URL: https://github.com/llvm/llvm-project/commit/1fb8e3d76e87a6c6f0d8fc7aa4e7ed75e3641fee
DIFF: https://github.com/llvm/llvm-project/commit/1fb8e3d76e87a6c6f0d8fc7aa4e7ed75e3641fee.diff
LOG: [lldb] Support integer registers with more than 64 bits. (#166363)
In this PR we are proposing to change LLDB codebase so that LLDB is able
to print values of integer registers that have more than 64-bits (even
if the number of bits is not equal to 128).
---------
Co-authored-by: Matej Košík <matej.kosik at codasip.com>
Co-authored-by: Jonas Devlieghere <jonas at devlieghere.com>
Added:
Modified:
lldb/include/lldb/Utility/RegisterValue.h
lldb/source/Utility/DataExtractor.cpp
lldb/source/Utility/RegisterValue.cpp
lldb/unittests/Utility/RegisterValueTest.cpp
Removed:
################################################################################
diff --git a/lldb/include/lldb/Utility/RegisterValue.h b/lldb/include/lldb/Utility/RegisterValue.h
index 49aaf68be17fc..baf984cbcb052 100644
--- a/lldb/include/lldb/Utility/RegisterValue.h
+++ b/lldb/include/lldb/Utility/RegisterValue.h
@@ -46,7 +46,8 @@ class RegisterValue {
eTypeUInt16,
eTypeUInt32,
eTypeUInt64,
- eTypeUInt128,
+ eTypeUIntN, /// < This value is used when the (integer) register is larger
+ /// than 64-bits.
eTypeFloat,
eTypeDouble,
eTypeLongDouble,
@@ -69,7 +70,7 @@ class RegisterValue {
m_scalar = inst;
}
- explicit RegisterValue(llvm::APInt inst) : m_type(eTypeUInt128) {
+ explicit RegisterValue(llvm::APInt inst) : m_type(eTypeUIntN) {
m_scalar = llvm::APInt(std::move(inst));
}
@@ -178,7 +179,7 @@ class RegisterValue {
}
void operator=(llvm::APInt uint) {
- m_type = eTypeUInt128;
+ m_type = eTypeUIntN;
m_scalar = llvm::APInt(std::move(uint));
}
@@ -217,8 +218,8 @@ class RegisterValue {
m_scalar = uint;
}
- void SetUInt128(llvm::APInt uint) {
- m_type = eTypeUInt128;
+ void SetUIntN(llvm::APInt uint) {
+ m_type = eTypeUIntN;
m_scalar = std::move(uint);
}
diff --git a/lldb/source/Utility/DataExtractor.cpp b/lldb/source/Utility/DataExtractor.cpp
index e9be0cba81f0c..a9aea168acf41 100644
--- a/lldb/source/Utility/DataExtractor.cpp
+++ b/lldb/source/Utility/DataExtractor.cpp
@@ -662,10 +662,6 @@ size_t DataExtractor::ExtractBytes(offset_t offset, offset_t length,
const uint8_t *src = PeekData(offset, length);
if (src) {
if (dst_byte_order != GetByteOrder()) {
- // Validate that only a word- or register-sized dst is byte swapped
- assert(length == 1 || length == 2 || length == 4 || length == 8 ||
- length == 10 || length == 16 || length == 32);
-
for (uint32_t i = 0; i < length; ++i)
(static_cast<uint8_t *>(dst))[i] = src[length - i - 1];
} else
diff --git a/lldb/source/Utility/RegisterValue.cpp b/lldb/source/Utility/RegisterValue.cpp
index 8b2af4e3d4f0e..c28c9e2d4d106 100644
--- a/lldb/source/Utility/RegisterValue.cpp
+++ b/lldb/source/Utility/RegisterValue.cpp
@@ -127,7 +127,7 @@ bool RegisterValue::GetScalarValue(Scalar &scalar) const {
case eTypeUInt16:
case eTypeUInt32:
case eTypeUInt64:
- case eTypeUInt128:
+ case eTypeUIntN:
case eTypeFloat:
case eTypeDouble:
case eTypeLongDouble:
@@ -180,8 +180,6 @@ Status RegisterValue::SetValueFromData(const RegisterInfo ®_info,
if (src_len > reg_info.byte_size)
src_len = reg_info.byte_size;
- type128 int128;
-
m_type = eTypeInvalid;
switch (reg_info.encoding) {
case eEncodingInvalid:
@@ -196,17 +194,15 @@ Status RegisterValue::SetValueFromData(const RegisterInfo ®_info,
SetUInt32(src.GetMaxU32(&src_offset, src_len));
else if (reg_info.byte_size <= 8)
SetUInt64(src.GetMaxU64(&src_offset, src_len));
- else if (reg_info.byte_size <= 16) {
- uint64_t data1 = src.GetU64(&src_offset);
- uint64_t data2 = src.GetU64(&src_offset);
- if (src.GetByteOrder() == eByteOrderLittle) {
- int128.x[0] = data1;
- int128.x[1] = data2;
- } else {
- int128.x[0] = data2;
- int128.x[1] = data1;
- }
- SetUInt128(llvm::APInt(128, int128.x));
+ else {
+ std::vector<uint8_t> native_endian_src(src_len, 0);
+ src.ExtractBytes(src_offset, src_len,
+ llvm::sys::IsLittleEndianHost ? eByteOrderLittle
+ : eByteOrderBig,
+ native_endian_src.data());
+ llvm::APInt uint = llvm::APInt::getZero(src_len * 8);
+ llvm::LoadIntFromMemory(uint, native_endian_src.data(), src_len);
+ SetUIntN(uint);
}
break;
case eEncodingIEEE754:
@@ -442,7 +438,7 @@ bool RegisterValue::SignExtend(uint32_t sign_bitpos) {
case eTypeUInt16:
case eTypeUInt32:
case eTypeUInt64:
- case eTypeUInt128:
+ case eTypeUIntN:
return m_scalar.SignExtend(sign_bitpos);
case eTypeFloat:
case eTypeDouble:
@@ -465,7 +461,7 @@ bool RegisterValue::CopyValue(const RegisterValue &rhs) {
case eTypeUInt16:
case eTypeUInt32:
case eTypeUInt64:
- case eTypeUInt128:
+ case eTypeUIntN:
case eTypeFloat:
case eTypeDouble:
case eTypeLongDouble:
@@ -581,7 +577,7 @@ llvm::APInt RegisterValue::GetAsUInt128(const llvm::APInt &fail_value,
case eTypeUInt16:
case eTypeUInt32:
case eTypeUInt64:
- case eTypeUInt128:
+ case eTypeUIntN:
case eTypeFloat:
case eTypeDouble:
case eTypeLongDouble:
@@ -616,7 +612,7 @@ float RegisterValue::GetAsFloat(float fail_value, bool *success_ptr) const {
break;
case eTypeUInt32:
case eTypeUInt64:
- case eTypeUInt128:
+ case eTypeUIntN:
case eTypeFloat:
case eTypeDouble:
case eTypeLongDouble:
@@ -636,7 +632,7 @@ double RegisterValue::GetAsDouble(double fail_value, bool *success_ptr) const {
case eTypeUInt32:
case eTypeUInt64:
- case eTypeUInt128:
+ case eTypeUIntN:
case eTypeFloat:
case eTypeDouble:
case eTypeLongDouble:
@@ -657,7 +653,7 @@ long double RegisterValue::GetAsLongDouble(long double fail_value,
case eTypeUInt32:
case eTypeUInt64:
- case eTypeUInt128:
+ case eTypeUIntN:
case eTypeFloat:
case eTypeDouble:
case eTypeLongDouble:
@@ -676,7 +672,7 @@ const void *RegisterValue::GetBytes() const {
case eTypeUInt16:
case eTypeUInt32:
case eTypeUInt64:
- case eTypeUInt128:
+ case eTypeUIntN:
case eTypeFloat:
case eTypeDouble:
case eTypeLongDouble:
@@ -698,7 +694,7 @@ uint32_t RegisterValue::GetByteSize() const {
return 2;
case eTypeUInt32:
case eTypeUInt64:
- case eTypeUInt128:
+ case eTypeUIntN:
case eTypeFloat:
case eTypeDouble:
case eTypeLongDouble:
@@ -721,7 +717,7 @@ bool RegisterValue::SetUInt(uint64_t uint, uint32_t byte_size) {
} else if (byte_size <= 8) {
SetUInt64(uint);
} else if (byte_size <= 16) {
- SetUInt128(llvm::APInt(128, uint));
+ SetUIntN(llvm::APInt(128, uint));
} else
return false;
return true;
@@ -749,7 +745,7 @@ bool RegisterValue::operator==(const RegisterValue &rhs) const {
case eTypeUInt16:
case eTypeUInt32:
case eTypeUInt64:
- case eTypeUInt128:
+ case eTypeUIntN:
case eTypeFloat:
case eTypeDouble:
case eTypeLongDouble:
@@ -774,7 +770,7 @@ bool RegisterValue::ClearBit(uint32_t bit) {
case eTypeUInt16:
case eTypeUInt32:
case eTypeUInt64:
- case eTypeUInt128:
+ case eTypeUIntN:
if (bit < (GetByteSize() * 8)) {
return m_scalar.ClearBit(bit);
}
@@ -814,7 +810,7 @@ bool RegisterValue::SetBit(uint32_t bit) {
case eTypeUInt16:
case eTypeUInt32:
case eTypeUInt64:
- case eTypeUInt128:
+ case eTypeUIntN:
if (bit < (GetByteSize() * 8)) {
return m_scalar.SetBit(bit);
}
diff --git a/lldb/unittests/Utility/RegisterValueTest.cpp b/lldb/unittests/Utility/RegisterValueTest.cpp
index 6239dbe21634a..7b27e841cbec5 100644
--- a/lldb/unittests/Utility/RegisterValueTest.cpp
+++ b/lldb/unittests/Utility/RegisterValueTest.cpp
@@ -57,13 +57,12 @@ TEST(RegisterValueTest, GetScalarValue) {
APInt(128, 0x7766554433221100)));
}
-static const Scalar etalon128(APInt(128, 0xffeeddccbbaa9988ull) << 64 |
- APInt(128, 0x7766554433221100ull));
-
-void TestSetValueFromData128(void *src, const lldb::ByteOrder endianness) {
- RegisterInfo ri{"uint128_register",
+void TestSetValueFromData(const Scalar &etalon, void *src, size_t src_byte_size,
+ const lldb::ByteOrder endianness,
+ const RegisterValue::Type register_value_type) {
+ RegisterInfo ri{"test",
nullptr,
- 16,
+ static_cast<uint32_t>(src_byte_size),
0,
lldb::Encoding::eEncodingUint,
lldb::Format::eFormatDefault,
@@ -71,26 +70,289 @@ void TestSetValueFromData128(void *src, const lldb::ByteOrder endianness) {
nullptr,
nullptr,
nullptr};
- DataExtractor src_extractor(src, 16, endianness, 8);
+ DataExtractor src_extractor(src, src_byte_size, endianness, 8);
RegisterValue rv;
EXPECT_TRUE(rv.SetValueFromData(ri, src_extractor, 0, false).Success());
Scalar s;
EXPECT_TRUE(rv.GetScalarValue(s));
- EXPECT_EQ(s, etalon128);
+ EXPECT_EQ(rv.GetType(), register_value_type);
+ EXPECT_EQ(s, etalon);
+}
+
+static const Scalar etalon7(APInt(32, 0x0000007F));
+
+TEST(RegisterValueTest, SetValueFromData_7_le) {
+ uint8_t src[] = {0x7F};
+ TestSetValueFromData(etalon7, src, 1, lldb::ByteOrder::eByteOrderLittle,
+ RegisterValue::eTypeUInt8);
+}
+
+TEST(RegisterValueTest, SetValueFromData_7_be) {
+ uint8_t src[] = {0x7F};
+ TestSetValueFromData(etalon7, src, 1, lldb::ByteOrder::eByteOrderBig,
+ RegisterValue::eTypeUInt8);
+}
+
+static const Scalar etalon8(APInt(32, 0x000000FE));
+
+TEST(RegisterValueTest, SetValueFromData_8_le) {
+ uint8_t src[] = {0xFE};
+ TestSetValueFromData(etalon8, src, 1, lldb::ByteOrder::eByteOrderLittle,
+ RegisterValue::eTypeUInt8);
+}
+
+TEST(RegisterValueTest, SetValueFromData_8_be) {
+ uint8_t src[] = {0xFE};
+ TestSetValueFromData(etalon8, src, 1, lldb::ByteOrder::eByteOrderBig,
+ RegisterValue::eTypeUInt8);
+}
+
+static const Scalar etalon9(APInt(32, 0x000001FE));
+
+TEST(RegisterValueTest, SetValueFromData_9_le) {
+ uint8_t src[] = {0xFE, 0x01};
+ TestSetValueFromData(etalon9, src, 2, lldb::ByteOrder::eByteOrderLittle,
+ RegisterValue::eTypeUInt16);
+}
+
+TEST(RegisterValueTest, SetValueFromData_9_be) {
+ uint8_t src[] = {0x01, 0xFE};
+ TestSetValueFromData(etalon9, src, 2, lldb::ByteOrder::eByteOrderBig,
+ RegisterValue::eTypeUInt16);
+}
+
+static const Scalar etalon15(APInt(32, 0x00007FED));
+
+TEST(RegisterValueTest, SetValueFromData_15_le) {
+ uint8_t src[] = {0xED, 0x7F};
+ TestSetValueFromData(etalon15, src, 2, lldb::ByteOrder::eByteOrderLittle,
+ RegisterValue::eTypeUInt16);
+}
+
+TEST(RegisterValueTest, SetValueFromData_15_be) {
+ uint8_t src[] = {0x7F, 0xED};
+ TestSetValueFromData(etalon15, src, 2, lldb::ByteOrder::eByteOrderBig,
+ RegisterValue::eTypeUInt16);
+}
+
+static const Scalar etalon16(APInt(32, 0x0000FEDC));
+
+TEST(RegisterValueTest, SetValueFromData_16_le) {
+ uint8_t src[] = {0xDC, 0xFE};
+ TestSetValueFromData(etalon16, src, 2, lldb::ByteOrder::eByteOrderLittle,
+ RegisterValue::eTypeUInt16);
+}
+
+TEST(RegisterValueTest, SetValueFromData_16_be) {
+ uint8_t src[] = {0xFE, 0xDC};
+ TestSetValueFromData(etalon16, src, 2, lldb::ByteOrder::eByteOrderBig,
+ RegisterValue::eTypeUInt16);
+}
+
+static const Scalar etalon17(APInt(32, 0x0001FEDC));
+
+TEST(RegisterValueTest, SetValueFromData_17_le) {
+ uint8_t src[] = {0xDC, 0xFE, 0x01};
+ TestSetValueFromData(etalon17, src, 3, lldb::ByteOrder::eByteOrderLittle,
+ RegisterValue::eTypeUInt32);
+}
+
+TEST(RegisterValueTest, SetValueFromData_17_be) {
+ uint8_t src[] = {0x01, 0xFE, 0xDC};
+ TestSetValueFromData(etalon17, src, 3, lldb::ByteOrder::eByteOrderBig,
+ RegisterValue::eTypeUInt32);
+}
+
+static const Scalar etalon24(APInt(32, 0x00FEDCBA));
+
+TEST(RegisterValueTest, SetValueFromData_24_le) {
+ uint8_t src[] = {0xBA, 0xDC, 0xFE};
+ TestSetValueFromData(etalon24, src, 3, lldb::ByteOrder::eByteOrderLittle,
+ RegisterValue::eTypeUInt32);
+}
+
+TEST(RegisterValueTest, SetValueFromData_24_be) {
+ uint8_t src[] = {0xFE, 0xDC, 0xBA};
+ TestSetValueFromData(etalon24, src, 3, lldb::ByteOrder::eByteOrderBig,
+ RegisterValue::eTypeUInt32);
+}
+
+static const Scalar etalon31(APInt(32, 0x7EDCBA98));
+
+TEST(RegisterValueTest, SetValueFromData_31_le) {
+ uint8_t src[] = {0x98, 0xBA, 0xDC, 0x7E};
+ TestSetValueFromData(etalon31, src, 4, lldb::ByteOrder::eByteOrderLittle,
+ RegisterValue::eTypeUInt32);
+}
+
+TEST(RegisterValueTest, SetValueFromData_31_be) {
+ uint8_t src[] = {0x7E, 0xDC, 0xBA, 0x98};
+ TestSetValueFromData(etalon31, src, 4, lldb::ByteOrder::eByteOrderBig,
+ RegisterValue::eTypeUInt32);
+}
+
+static const Scalar etalon32(APInt(32, 0xFEDCBA98));
+
+TEST(RegisterValueTest, SetValueFromData_32_le) {
+ uint8_t src[] = {0x98, 0xBA, 0xDC, 0xFE};
+ TestSetValueFromData(etalon32, src, 4, lldb::ByteOrder::eByteOrderLittle,
+ RegisterValue::eTypeUInt32);
}
-// Test that the "RegisterValue::SetValueFromData" method works correctly
-// with 128-bit little-endian data that represents an integer.
+TEST(RegisterValueTest, SetValueFromData_32_be) {
+ uint8_t src[] = {0xFE, 0xDC, 0xBA, 0x98};
+ TestSetValueFromData(etalon32, src, 4, lldb::ByteOrder::eByteOrderBig,
+ RegisterValue::eTypeUInt32);
+}
+
+static const Scalar etalon33(APInt(64, 0x00000001FEDCBA98));
+
+TEST(RegisterValueTest, SetValueFromData_33_le) {
+ uint8_t src[] = {0x98, 0xBA, 0xDC, 0xFE, 0x01};
+ TestSetValueFromData(etalon33, src, 5, lldb::ByteOrder::eByteOrderLittle,
+ RegisterValue::eTypeUInt64);
+}
+
+TEST(RegisterValueTest, SetValueFromData_33_be) {
+ uint8_t src[] = {0x01, 0xFE, 0xDC, 0xBA, 0x98};
+ TestSetValueFromData(etalon33, src, 5, lldb::ByteOrder::eByteOrderBig,
+ RegisterValue::eTypeUInt64);
+}
+
+static const Scalar etalon40(APInt(64, 0x000000FEDCBA9876));
+
+TEST(RegisterValueTest, SetValueFromData_40_le) {
+ uint8_t src[] = {0x76, 0x98, 0xBA, 0xDC, 0xFE};
+ TestSetValueFromData(etalon40, src, 5, lldb::ByteOrder::eByteOrderLittle,
+ RegisterValue::eTypeUInt64);
+}
+
+TEST(RegisterValueTest, SetValueFromData_40_be) {
+ uint8_t src[] = {0xFE, 0xDC, 0xBA, 0x98, 0x76};
+ TestSetValueFromData(etalon40, src, 5, lldb::ByteOrder::eByteOrderBig,
+ RegisterValue::eTypeUInt64);
+}
+
+static const Scalar etalon63(APInt(64, 0x7EDCBA9876543210));
+
+TEST(RegisterValueTest, SetValueFromData_63_le) {
+ uint8_t src[] = {0x10, 0x32, 0x54, 0x76, 0x98, 0xBA, 0xDC, 0x7E};
+ TestSetValueFromData(etalon63, src, 8, lldb::ByteOrder::eByteOrderLittle,
+ RegisterValue::eTypeUInt64);
+}
+
+TEST(RegisterValueTest, SetValueFromData_63_be) {
+ uint8_t src[] = {0x7E, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10};
+ TestSetValueFromData(etalon63, src, 8, lldb::ByteOrder::eByteOrderBig,
+ RegisterValue::eTypeUInt64);
+}
+
+static const Scalar etalon64(APInt(64, 0xFEDCBA9876543210));
+
+TEST(RegisterValueTest, SetValueFromData_64_le) {
+ uint8_t src[] = {0x10, 0x32, 0x54, 0x76, 0x98, 0xBA, 0xDC, 0xFE};
+ TestSetValueFromData(etalon64, src, 8, lldb::ByteOrder::eByteOrderLittle,
+ RegisterValue::eTypeUInt64);
+}
+
+TEST(RegisterValueTest, SetValueFromData_64_be) {
+ uint8_t src[] = {0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10};
+ TestSetValueFromData(etalon64, src, 8, lldb::ByteOrder::eByteOrderBig,
+ RegisterValue::eTypeUInt64);
+}
+
+static const Scalar etalon65(APInt(72, 0x0000000000000001ull) << 1 * 64 |
+ APInt(72, 0x0706050403020100ull) << 0 * 64);
+
+TEST(RegisterValueTest, SetValueFromData_65_le) {
+ uint8_t src[] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01};
+ TestSetValueFromData(etalon65, src, 9, lldb::ByteOrder::eByteOrderLittle,
+ RegisterValue::eTypeUIntN);
+}
+
+TEST(RegisterValueTest, SetValueFromData_65_be) {
+ uint8_t src[] = {0x01, 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00};
+ TestSetValueFromData(etalon65, src, 9, lldb::ByteOrder::eByteOrderBig,
+ RegisterValue::eTypeUIntN);
+}
+
+static const Scalar etalon127(APInt(128, 0x7f0e0d0c0b0a0908ull) << 1 * 64 |
+ APInt(128, 0x0706050403020100ull) << 0 * 64);
+
+TEST(RegisterValueTest, SetValueFromData_127_le) {
+ uint8_t src[] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+ 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x7f};
+ TestSetValueFromData(etalon127, src, 16, lldb::ByteOrder::eByteOrderLittle,
+ RegisterValue::eTypeUIntN);
+}
+
+TEST(RegisterValueTest, SetValueFromData_127_be) {
+ uint8_t src[] = {0x7f, 0x0e, 0x0d, 0x0c, 0x0b, 0x0a, 0x09, 0x08,
+ 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00};
+ TestSetValueFromData(etalon127, src, 16, lldb::ByteOrder::eByteOrderBig,
+ RegisterValue::eTypeUIntN);
+}
+
+static const Scalar etalon128(APInt(128, 0x0f0e0d0c0b0a0908ull) << 1 * 64 |
+ APInt(128, 0x0706050403020100ull) << 0 * 64);
+
TEST(RegisterValueTest, SetValueFromData_128_le) {
- uint8_t src[] = {0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
- 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff};
- TestSetValueFromData128(src, lldb::ByteOrder::eByteOrderLittle);
+ uint8_t src[] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+ 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f};
+ TestSetValueFromData(etalon128, src, 16, lldb::ByteOrder::eByteOrderLittle,
+ RegisterValue::eTypeUIntN);
}
-// Test that the "RegisterValue::SetValueFromData" method works correctly
-// with 128-bit big-endian data that represents an integer.
TEST(RegisterValueTest, SetValueFromData_128_be) {
- uint8_t src[] = {0xff, 0xee, 0xdd, 0xcc, 0xbb, 0xaa, 0x99, 0x88,
- 0x77, 0x66, 0x55, 0x44, 0x33, 0x22, 0x11, 0x00};
- TestSetValueFromData128(src, lldb::ByteOrder::eByteOrderBig);
+ uint8_t src[] = {0x0f, 0x0e, 0x0d, 0x0c, 0x0b, 0x0a, 0x09, 0x08,
+ 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00};
+ TestSetValueFromData(etalon128, src, 16, lldb::ByteOrder::eByteOrderBig,
+ RegisterValue::eTypeUIntN);
+}
+
+static const Scalar etalon256(APInt(256, 0x1f1e1d1c1b1a1918ull) << 3 * 64 |
+ APInt(256, 0x1716151413121110ull) << 2 * 64 |
+ APInt(256, 0x0f0e0d0c0b0a0908ull) << 1 * 64 |
+ APInt(256, 0x0706050403020100ull) << 0 * 64);
+
+TEST(RegisterValueTest, SetValueFromData_256_le) {
+ uint8_t src[] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+ 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
+ 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
+ 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f};
+ TestSetValueFromData(etalon256, src, 32, lldb::ByteOrder::eByteOrderLittle,
+ RegisterValue::eTypeUIntN);
+}
+
+TEST(RegisterValueTest, SetValueFromData_256_be) {
+ uint8_t src[] = {0x1f, 0x1e, 0x1d, 0x1c, 0x1b, 0x1a, 0x19, 0x18,
+ 0x17, 0x16, 0x15, 0x14, 0x13, 0x12, 0x11, 0x10,
+ 0x0f, 0x0e, 0x0d, 0x0c, 0x0b, 0x0a, 0x09, 0x08,
+ 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00};
+ TestSetValueFromData(etalon256, src, 32, lldb::ByteOrder::eByteOrderBig,
+ RegisterValue::eTypeUIntN);
+}
+
+static const Scalar etalon257(APInt(512, 0x0000000000000001ull) << 4 * 64 |
+ APInt(512, 0x1f1e1d1c1b1a1918ull) << 3 * 64 |
+ APInt(512, 0x1716151413121110ull) << 2 * 64 |
+ APInt(512, 0x0f0e0d0c0b0a0908ull) << 1 * 64 |
+ APInt(512, 0x0706050403020100ull) << 0 * 64);
+
+TEST(RegisterValueTest, SetValueFromData_257_le) {
+ uint8_t src[] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
+ 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11,
+ 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a,
+ 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x01};
+ TestSetValueFromData(etalon257, src, 33, lldb::ByteOrder::eByteOrderLittle,
+ RegisterValue::eTypeUIntN);
+}
+
+TEST(RegisterValueTest, SetValueFromData_257_be) {
+ uint8_t src[] = {0x01, 0x1f, 0x1e, 0x1d, 0x1c, 0x1b, 0x1a, 0x19, 0x18,
+ 0x17, 0x16, 0x15, 0x14, 0x13, 0x12, 0x11, 0x10, 0x0f,
+ 0x0e, 0x0d, 0x0c, 0x0b, 0x0a, 0x09, 0x08, 0x07, 0x06,
+ 0x05, 0x04, 0x03, 0x02, 0x01, 0x00};
+ TestSetValueFromData(etalon257, src, 33, lldb::ByteOrder::eByteOrderBig,
+ RegisterValue::eTypeUIntN);
}
More information about the lldb-commits
mailing list