[Lldb-commits] [lldb] [lldb] Support integer registers with more than 64 bits. (PR #166363)
Matej Košík via lldb-commits
lldb-commits at lists.llvm.org
Sun Nov 9 23:20:21 PST 2025
https://github.com/sedymrak updated https://github.com/llvm/llvm-project/pull/166363
>From 2db982dc82d45647944e8d511fc074caab3127c9 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Matej=20Ko=C5=A1=C3=ADk?= <matej.kosik at codasip.com>
Date: Fri, 31 Oct 2025 18:12:18 +0100
Subject: [PATCH 01/28] [lldb] reorganize existing tests (in order to facility
sucessive additions)
---
lldb/unittests/Utility/RegisterValueTest.cpp | 27 ++++++++++----------
1 file changed, 14 insertions(+), 13 deletions(-)
diff --git a/lldb/unittests/Utility/RegisterValueTest.cpp b/lldb/unittests/Utility/RegisterValueTest.cpp
index 6239dbe21634a..92c0172e0c909 100644
--- a/lldb/unittests/Utility/RegisterValueTest.cpp
+++ b/lldb/unittests/Utility/RegisterValueTest.cpp
@@ -57,13 +57,11 @@ 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) {
+void TestSetValueFromData(const Scalar &etalon, void *src, size_t src_byte_size,
+ const lldb::ByteOrder endianness) {
RegisterInfo ri{"uint128_register",
nullptr,
- 16,
+ static_cast<uint32_t>(src_byte_size),
0,
lldb::Encoding::eEncodingUint,
lldb::Format::eFormatDefault,
@@ -71,26 +69,29 @@ 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(s, etalon);
}
+static const Scalar etalon128(APInt(128, 0x0f0e0d0c0b0a0908ull) << 1 * 64 |
+ APInt(128, 0x0706050403020100ull) << 0 * 64);
+
// Test that the "RegisterValue::SetValueFromData" method works correctly
// with 128-bit little-endian data that represents an integer.
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);
}
// 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);
}
>From eb234f996d8d32149501ac53eeb1a89a1b4bcc74 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Matej=20Ko=C5=A1=C3=ADk?= <matej.kosik at codasip.com>
Date: Fri, 31 Oct 2025 19:04:26 +0100
Subject: [PATCH 02/28] [lldb] add new tests that demonstrate the problem
---
lldb/unittests/Utility/RegisterValueTest.cpp | 25 ++++++++++++++++++++
1 file changed, 25 insertions(+)
diff --git a/lldb/unittests/Utility/RegisterValueTest.cpp b/lldb/unittests/Utility/RegisterValueTest.cpp
index 92c0172e0c909..d6b7b2e448d8b 100644
--- a/lldb/unittests/Utility/RegisterValueTest.cpp
+++ b/lldb/unittests/Utility/RegisterValueTest.cpp
@@ -95,3 +95,28 @@ TEST(RegisterValueTest, SetValueFromData_128_be) {
0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00};
TestSetValueFromData(etalon128, src, 16, lldb::ByteOrder::eByteOrderBig);
}
+
+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 that the "RegisterValue::SetValueFromData" method works correctly
+// with 256-bit little-endian data that represents an integer.
+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);
+}
+
+// Test that the "RegisterValue::SetValueFromData" method works correctly
+// with 256-bit big-endian data that represents an integer.
+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);
+}
>From 6b48d039647efd1e69e9a4a0b9db2c2ad4045358 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Matej=20Ko=C5=A1=C3=ADk?= <matej.kosik at codasip.com>
Date: Fri, 31 Oct 2025 21:33:35 +0100
Subject: [PATCH 03/28] [lldb] fix the "RegisterValue::SetValueFromData" method
---
lldb/source/Utility/RegisterValue.cpp | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/lldb/source/Utility/RegisterValue.cpp b/lldb/source/Utility/RegisterValue.cpp
index 8b2af4e3d4f0e..5190320e11fd0 100644
--- a/lldb/source/Utility/RegisterValue.cpp
+++ b/lldb/source/Utility/RegisterValue.cpp
@@ -207,6 +207,18 @@ Status RegisterValue::SetValueFromData(const RegisterInfo ®_info,
int128.x[1] = data1;
}
SetUInt128(llvm::APInt(128, int128.x));
+ } else {
+ std::vector<uint8_t> bytes(src_len, 0);
+ for (size_t i = 0; i < src_len; i++)
+ bytes[i] = src.GetU8(&src_offset);
+ if (src.GetByteOrder() == eByteOrderBig)
+ std::reverse(bytes.begin(), bytes.end());
+ // The number of 64-bit wide words that are stored in "src".
+ size_t size64 = (reg_info.byte_size - 1) / 8 + 1;
+ bytes.resize(size64 * sizeof(uint64_t), 0);
+ llvm::APInt uint = llvm::APInt::getZero(src_len * 8);
+ llvm::LoadIntFromMemory(uint, bytes.data(), src_len);
+ SetUInt128(uint);
}
break;
case eEncodingIEEE754:
>From ca5d68a2a355d695e582b1c4a16f2b080a6ebc8e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Matej=20Ko=C5=A1=C3=ADk?= <matej.kosik at codasip.com>
Date: Fri, 31 Oct 2025 22:04:03 +0100
Subject: [PATCH 04/28] [lldb] add new tests that demonstrate the problem
---
lldb/unittests/Utility/RegisterValueTest.cpp | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/lldb/unittests/Utility/RegisterValueTest.cpp b/lldb/unittests/Utility/RegisterValueTest.cpp
index d6b7b2e448d8b..48a920b11e4e0 100644
--- a/lldb/unittests/Utility/RegisterValueTest.cpp
+++ b/lldb/unittests/Utility/RegisterValueTest.cpp
@@ -77,6 +77,23 @@ void TestSetValueFromData(const Scalar &etalon, void *src, size_t src_byte_size,
EXPECT_EQ(s, etalon);
}
+static const Scalar etalon72(APInt(72, 0x0000000000000008ull) << 1 * 64 |
+ APInt(72, 0x0706050403020100ull) << 0 * 64);
+
+// Test that the "RegisterValue::SetValueFromData" method works correctly
+// with 72-bit little-endian data that represents an integer.
+TEST(RegisterValueTest, SetValueFromData_72_le) {
+ uint8_t src[] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08};
+ TestSetValueFromData(etalon72, src, 9, lldb::ByteOrder::eByteOrderLittle);
+}
+
+// Test that the "RegisterValue::SetValueFromData" method works correctly
+// with 72-bit big-endian data that represents an integer.
+TEST(RegisterValueTest, SetValueFromData_72_be) {
+ uint8_t src[] = {0x08, 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00};
+ TestSetValueFromData(etalon72, src, 9, lldb::ByteOrder::eByteOrderBig);
+}
+
static const Scalar etalon128(APInt(128, 0x0f0e0d0c0b0a0908ull) << 1 * 64 |
APInt(128, 0x0706050403020100ull) << 0 * 64);
>From ef8859f8785cd711353fb270f6fbb1d227bb83ef Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Matej=20Ko=C5=A1=C3=ADk?= <matej.kosik at codasip.com>
Date: Fri, 31 Oct 2025 23:38:39 +0100
Subject: [PATCH 05/28] [lldb] fix the "RegisterValue::SetValueFromData" method
---
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 5190320e11fd0..ce900f82f37df 100644
--- a/lldb/source/Utility/RegisterValue.cpp
+++ b/lldb/source/Utility/RegisterValue.cpp
@@ -196,7 +196,7 @@ 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) {
+ 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) {
>From 460b8fc9d97d6c3a162c77d0c0dc2982bd3cfd04 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Matej=20Ko=C5=A1=C3=ADk?= <matej.kosik at codasip.com>
Date: Mon, 3 Nov 2025 11:51:14 +0100
Subject: [PATCH 06/28] [lldb] rename an existing enum value so that it better
expresses its meaning
---
lldb/include/lldb/Utility/RegisterValue.h | 8 ++++----
lldb/source/Utility/RegisterValue.cpp | 24 +++++++++++------------
2 files changed, 16 insertions(+), 16 deletions(-)
diff --git a/lldb/include/lldb/Utility/RegisterValue.h b/lldb/include/lldb/Utility/RegisterValue.h
index 49aaf68be17fc..0226fe36a7990 100644
--- a/lldb/include/lldb/Utility/RegisterValue.h
+++ b/lldb/include/lldb/Utility/RegisterValue.h
@@ -46,7 +46,7 @@ class RegisterValue {
eTypeUInt16,
eTypeUInt32,
eTypeUInt64,
- eTypeUInt128,
+ eTypeUIntBig, // an integer that has more than 64 bits
eTypeFloat,
eTypeDouble,
eTypeLongDouble,
@@ -69,7 +69,7 @@ class RegisterValue {
m_scalar = inst;
}
- explicit RegisterValue(llvm::APInt inst) : m_type(eTypeUInt128) {
+ explicit RegisterValue(llvm::APInt inst) : m_type(eTypeUIntBig) {
m_scalar = llvm::APInt(std::move(inst));
}
@@ -178,7 +178,7 @@ class RegisterValue {
}
void operator=(llvm::APInt uint) {
- m_type = eTypeUInt128;
+ m_type = eTypeUIntBig;
m_scalar = llvm::APInt(std::move(uint));
}
@@ -218,7 +218,7 @@ class RegisterValue {
}
void SetUInt128(llvm::APInt uint) {
- m_type = eTypeUInt128;
+ m_type = eTypeUIntBig;
m_scalar = std::move(uint);
}
diff --git a/lldb/source/Utility/RegisterValue.cpp b/lldb/source/Utility/RegisterValue.cpp
index ce900f82f37df..fe84117c5e305 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 eTypeUIntBig:
case eTypeFloat:
case eTypeDouble:
case eTypeLongDouble:
@@ -454,7 +454,7 @@ bool RegisterValue::SignExtend(uint32_t sign_bitpos) {
case eTypeUInt16:
case eTypeUInt32:
case eTypeUInt64:
- case eTypeUInt128:
+ case eTypeUIntBig:
return m_scalar.SignExtend(sign_bitpos);
case eTypeFloat:
case eTypeDouble:
@@ -477,7 +477,7 @@ bool RegisterValue::CopyValue(const RegisterValue &rhs) {
case eTypeUInt16:
case eTypeUInt32:
case eTypeUInt64:
- case eTypeUInt128:
+ case eTypeUIntBig:
case eTypeFloat:
case eTypeDouble:
case eTypeLongDouble:
@@ -593,7 +593,7 @@ llvm::APInt RegisterValue::GetAsUInt128(const llvm::APInt &fail_value,
case eTypeUInt16:
case eTypeUInt32:
case eTypeUInt64:
- case eTypeUInt128:
+ case eTypeUIntBig:
case eTypeFloat:
case eTypeDouble:
case eTypeLongDouble:
@@ -628,7 +628,7 @@ float RegisterValue::GetAsFloat(float fail_value, bool *success_ptr) const {
break;
case eTypeUInt32:
case eTypeUInt64:
- case eTypeUInt128:
+ case eTypeUIntBig:
case eTypeFloat:
case eTypeDouble:
case eTypeLongDouble:
@@ -648,7 +648,7 @@ double RegisterValue::GetAsDouble(double fail_value, bool *success_ptr) const {
case eTypeUInt32:
case eTypeUInt64:
- case eTypeUInt128:
+ case eTypeUIntBig:
case eTypeFloat:
case eTypeDouble:
case eTypeLongDouble:
@@ -669,7 +669,7 @@ long double RegisterValue::GetAsLongDouble(long double fail_value,
case eTypeUInt32:
case eTypeUInt64:
- case eTypeUInt128:
+ case eTypeUIntBig:
case eTypeFloat:
case eTypeDouble:
case eTypeLongDouble:
@@ -688,7 +688,7 @@ const void *RegisterValue::GetBytes() const {
case eTypeUInt16:
case eTypeUInt32:
case eTypeUInt64:
- case eTypeUInt128:
+ case eTypeUIntBig:
case eTypeFloat:
case eTypeDouble:
case eTypeLongDouble:
@@ -710,7 +710,7 @@ uint32_t RegisterValue::GetByteSize() const {
return 2;
case eTypeUInt32:
case eTypeUInt64:
- case eTypeUInt128:
+ case eTypeUIntBig:
case eTypeFloat:
case eTypeDouble:
case eTypeLongDouble:
@@ -761,7 +761,7 @@ bool RegisterValue::operator==(const RegisterValue &rhs) const {
case eTypeUInt16:
case eTypeUInt32:
case eTypeUInt64:
- case eTypeUInt128:
+ case eTypeUIntBig:
case eTypeFloat:
case eTypeDouble:
case eTypeLongDouble:
@@ -786,7 +786,7 @@ bool RegisterValue::ClearBit(uint32_t bit) {
case eTypeUInt16:
case eTypeUInt32:
case eTypeUInt64:
- case eTypeUInt128:
+ case eTypeUIntBig:
if (bit < (GetByteSize() * 8)) {
return m_scalar.ClearBit(bit);
}
@@ -826,7 +826,7 @@ bool RegisterValue::SetBit(uint32_t bit) {
case eTypeUInt16:
case eTypeUInt32:
case eTypeUInt64:
- case eTypeUInt128:
+ case eTypeUIntBig:
if (bit < (GetByteSize() * 8)) {
return m_scalar.SetBit(bit);
}
>From 82b5385c3a34d9a6b1a9fd0a84c81f72418b20cd Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Matej=20Ko=C5=A1=C3=ADk?= <matej.kosik at codasip.com>
Date: Tue, 4 Nov 2025 13:19:09 +0100
Subject: [PATCH 07/28] formatting
---
lldb/include/lldb/Utility/RegisterValue.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lldb/include/lldb/Utility/RegisterValue.h b/lldb/include/lldb/Utility/RegisterValue.h
index 0226fe36a7990..83487cfd46fc1 100644
--- a/lldb/include/lldb/Utility/RegisterValue.h
+++ b/lldb/include/lldb/Utility/RegisterValue.h
@@ -46,7 +46,7 @@ class RegisterValue {
eTypeUInt16,
eTypeUInt32,
eTypeUInt64,
- eTypeUIntBig, // an integer that has more than 64 bits
+ eTypeUIntBig, // an integer that has more than 64 bits
eTypeFloat,
eTypeDouble,
eTypeLongDouble,
>From a0f52e4a7cd77b88a83d4fcd831335e1cda61df7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Matej=20Ko=C5=A1=C3=ADk?= <matej.kosik at codasip.com>
Date: Tue, 4 Nov 2025 22:50:14 +0100
Subject: [PATCH 08/28] [lldb] rename "eTypeUIntBig" enum value to "eTypeUInt"
---
lldb/include/lldb/Utility/RegisterValue.h | 8 ++++----
lldb/source/Utility/RegisterValue.cpp | 24 +++++++++++------------
2 files changed, 16 insertions(+), 16 deletions(-)
diff --git a/lldb/include/lldb/Utility/RegisterValue.h b/lldb/include/lldb/Utility/RegisterValue.h
index 83487cfd46fc1..249c60db3fb4d 100644
--- a/lldb/include/lldb/Utility/RegisterValue.h
+++ b/lldb/include/lldb/Utility/RegisterValue.h
@@ -46,7 +46,7 @@ class RegisterValue {
eTypeUInt16,
eTypeUInt32,
eTypeUInt64,
- eTypeUIntBig, // an integer that has more than 64 bits
+ eTypeUInt, // an integer that has more than 64 bits
eTypeFloat,
eTypeDouble,
eTypeLongDouble,
@@ -69,7 +69,7 @@ class RegisterValue {
m_scalar = inst;
}
- explicit RegisterValue(llvm::APInt inst) : m_type(eTypeUIntBig) {
+ explicit RegisterValue(llvm::APInt inst) : m_type(eTypeUInt) {
m_scalar = llvm::APInt(std::move(inst));
}
@@ -178,7 +178,7 @@ class RegisterValue {
}
void operator=(llvm::APInt uint) {
- m_type = eTypeUIntBig;
+ m_type = eTypeUInt;
m_scalar = llvm::APInt(std::move(uint));
}
@@ -218,7 +218,7 @@ class RegisterValue {
}
void SetUInt128(llvm::APInt uint) {
- m_type = eTypeUIntBig;
+ m_type = eTypeUInt;
m_scalar = std::move(uint);
}
diff --git a/lldb/source/Utility/RegisterValue.cpp b/lldb/source/Utility/RegisterValue.cpp
index fe84117c5e305..bc7ae5606bf64 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 eTypeUIntBig:
+ case eTypeUInt:
case eTypeFloat:
case eTypeDouble:
case eTypeLongDouble:
@@ -454,7 +454,7 @@ bool RegisterValue::SignExtend(uint32_t sign_bitpos) {
case eTypeUInt16:
case eTypeUInt32:
case eTypeUInt64:
- case eTypeUIntBig:
+ case eTypeUInt:
return m_scalar.SignExtend(sign_bitpos);
case eTypeFloat:
case eTypeDouble:
@@ -477,7 +477,7 @@ bool RegisterValue::CopyValue(const RegisterValue &rhs) {
case eTypeUInt16:
case eTypeUInt32:
case eTypeUInt64:
- case eTypeUIntBig:
+ case eTypeUInt:
case eTypeFloat:
case eTypeDouble:
case eTypeLongDouble:
@@ -593,7 +593,7 @@ llvm::APInt RegisterValue::GetAsUInt128(const llvm::APInt &fail_value,
case eTypeUInt16:
case eTypeUInt32:
case eTypeUInt64:
- case eTypeUIntBig:
+ case eTypeUInt:
case eTypeFloat:
case eTypeDouble:
case eTypeLongDouble:
@@ -628,7 +628,7 @@ float RegisterValue::GetAsFloat(float fail_value, bool *success_ptr) const {
break;
case eTypeUInt32:
case eTypeUInt64:
- case eTypeUIntBig:
+ case eTypeUInt:
case eTypeFloat:
case eTypeDouble:
case eTypeLongDouble:
@@ -648,7 +648,7 @@ double RegisterValue::GetAsDouble(double fail_value, bool *success_ptr) const {
case eTypeUInt32:
case eTypeUInt64:
- case eTypeUIntBig:
+ case eTypeUInt:
case eTypeFloat:
case eTypeDouble:
case eTypeLongDouble:
@@ -669,7 +669,7 @@ long double RegisterValue::GetAsLongDouble(long double fail_value,
case eTypeUInt32:
case eTypeUInt64:
- case eTypeUIntBig:
+ case eTypeUInt:
case eTypeFloat:
case eTypeDouble:
case eTypeLongDouble:
@@ -688,7 +688,7 @@ const void *RegisterValue::GetBytes() const {
case eTypeUInt16:
case eTypeUInt32:
case eTypeUInt64:
- case eTypeUIntBig:
+ case eTypeUInt:
case eTypeFloat:
case eTypeDouble:
case eTypeLongDouble:
@@ -710,7 +710,7 @@ uint32_t RegisterValue::GetByteSize() const {
return 2;
case eTypeUInt32:
case eTypeUInt64:
- case eTypeUIntBig:
+ case eTypeUInt:
case eTypeFloat:
case eTypeDouble:
case eTypeLongDouble:
@@ -761,7 +761,7 @@ bool RegisterValue::operator==(const RegisterValue &rhs) const {
case eTypeUInt16:
case eTypeUInt32:
case eTypeUInt64:
- case eTypeUIntBig:
+ case eTypeUInt:
case eTypeFloat:
case eTypeDouble:
case eTypeLongDouble:
@@ -786,7 +786,7 @@ bool RegisterValue::ClearBit(uint32_t bit) {
case eTypeUInt16:
case eTypeUInt32:
case eTypeUInt64:
- case eTypeUIntBig:
+ case eTypeUInt:
if (bit < (GetByteSize() * 8)) {
return m_scalar.ClearBit(bit);
}
@@ -826,7 +826,7 @@ bool RegisterValue::SetBit(uint32_t bit) {
case eTypeUInt16:
case eTypeUInt32:
case eTypeUInt64:
- case eTypeUIntBig:
+ case eTypeUInt:
if (bit < (GetByteSize() * 8)) {
return m_scalar.SetBit(bit);
}
>From eab73d217cdcf86e8de82c1e5876701cf2823580 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Matej=20Ko=C5=A1=C3=ADk?= <m4tej.kosik at gmail.com>
Date: Wed, 5 Nov 2025 08:01:05 +0100
Subject: [PATCH 09/28] [lldb] fix the comment
Co-authored-by: Jonas Devlieghere <jonas at devlieghere.com>
---
lldb/include/lldb/Utility/RegisterValue.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lldb/include/lldb/Utility/RegisterValue.h b/lldb/include/lldb/Utility/RegisterValue.h
index 249c60db3fb4d..6587cff786c01 100644
--- a/lldb/include/lldb/Utility/RegisterValue.h
+++ b/lldb/include/lldb/Utility/RegisterValue.h
@@ -46,7 +46,7 @@ class RegisterValue {
eTypeUInt16,
eTypeUInt32,
eTypeUInt64,
- eTypeUInt, // an integer that has more than 64 bits
+ eTypeUInt, /// < An integer that has more than 64 bits.
eTypeFloat,
eTypeDouble,
eTypeLongDouble,
>From 9c946214408a5f226b74272fcf2a2a0d20237015 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Matej=20Ko=C5=A1=C3=ADk?= <matej.kosik at codasip.com>
Date: Wed, 5 Nov 2025 21:17:30 +0100
Subject: [PATCH 10/28] [lldb] fix a misleading name of the register
---
lldb/unittests/Utility/RegisterValueTest.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lldb/unittests/Utility/RegisterValueTest.cpp b/lldb/unittests/Utility/RegisterValueTest.cpp
index 48a920b11e4e0..6dbc2dafd8f81 100644
--- a/lldb/unittests/Utility/RegisterValueTest.cpp
+++ b/lldb/unittests/Utility/RegisterValueTest.cpp
@@ -59,7 +59,7 @@ TEST(RegisterValueTest, GetScalarValue) {
void TestSetValueFromData(const Scalar &etalon, void *src, size_t src_byte_size,
const lldb::ByteOrder endianness) {
- RegisterInfo ri{"uint128_register",
+ RegisterInfo ri{"test",
nullptr,
static_cast<uint32_t>(src_byte_size),
0,
>From b796fae5c6d8060764263d6184a2ecf07c8a1dc1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Matej=20Ko=C5=A1=C3=ADk?= <matej.kosik at codasip.com>
Date: Wed, 5 Nov 2025 21:18:23 +0100
Subject: [PATCH 11/28] [lldb] add new tests
---
lldb/unittests/Utility/RegisterValueTest.cpp | 245 ++++++++++++++++++-
1 file changed, 236 insertions(+), 9 deletions(-)
diff --git a/lldb/unittests/Utility/RegisterValueTest.cpp b/lldb/unittests/Utility/RegisterValueTest.cpp
index 6dbc2dafd8f81..b1bdabbe7116e 100644
--- a/lldb/unittests/Utility/RegisterValueTest.cpp
+++ b/lldb/unittests/Utility/RegisterValueTest.cpp
@@ -77,21 +77,248 @@ void TestSetValueFromData(const Scalar &etalon, void *src, size_t src_byte_size,
EXPECT_EQ(s, etalon);
}
-static const Scalar etalon72(APInt(72, 0x0000000000000008ull) << 1 * 64 |
+static const Scalar etalon7(APInt(32, 0x0000007F));
+
+// Test that the "RegisterValue::SetValueFromData" method works correctly
+// with 7-bit little-endian data that represents an integer.
+TEST(RegisterValueTest, SetValueFromData_7_le) {
+ uint8_t src[] = {0x7F};
+ TestSetValueFromData(etalon7, src, 1, lldb::ByteOrder::eByteOrderLittle);
+}
+
+// Test that the "RegisterValue::SetValueFromData" method works correctly
+// with 7-bit big-endian data that represents an integer.
+TEST(RegisterValueTest, SetValueFromData_7_be) {
+ uint8_t src[] = {0x7F};
+ TestSetValueFromData(etalon7, src, 1, lldb::ByteOrder::eByteOrderBig);
+}
+
+static const Scalar etalon8(APInt(32, 0x000000FE));
+
+// Test that the "RegisterValue::SetValueFromData" method works correctly
+// with 8-bit little-endian data that represents an integer.
+TEST(RegisterValueTest, SetValueFromData_8_le) {
+ uint8_t src[] = {0xFE};
+ TestSetValueFromData(etalon8, src, 1, lldb::ByteOrder::eByteOrderLittle);
+}
+
+// Test that the "RegisterValue::SetValueFromData" method works correctly
+// with 8-bit big-endian data that represents an integer.
+TEST(RegisterValueTest, SetValueFromData_8_be) {
+ uint8_t src[] = {0xFE};
+ TestSetValueFromData(etalon8, src, 1, lldb::ByteOrder::eByteOrderBig);
+}
+
+static const Scalar etalon9(APInt(32, 0x000001FE));
+
+// Test that the "RegisterValue::SetValueFromData" method works correctly
+// with 9-bit little-endian data that represents an integer.
+TEST(RegisterValueTest, SetValueFromData_9_le) {
+ uint8_t src[] = {0xFE, 0x01};
+ TestSetValueFromData(etalon9, src, 2, lldb::ByteOrder::eByteOrderLittle);
+}
+
+// Test that the "RegisterValue::SetValueFromData" method works correctly
+// with 9-bit big-endian data that represents an integer.
+TEST(RegisterValueTest, SetValueFromData_9_be) {
+ uint8_t src[] = {0x01, 0xFE};
+ TestSetValueFromData(etalon9, src, 2, lldb::ByteOrder::eByteOrderBig);
+}
+
+static const Scalar etalon15(APInt(32, 0x00007FED));
+
+// Test that the "RegisterValue::SetValueFromData" method works correctly
+// with 15-bit little-endian data that represents an integer.
+TEST(RegisterValueTest, SetValueFromData_15_le) {
+ uint8_t src[] = {0xED, 0x7F};
+ TestSetValueFromData(etalon15, src, 2, lldb::ByteOrder::eByteOrderLittle);
+}
+
+// Test that the "RegisterValue::SetValueFromData" method works correctly
+// with 15-bit big-endian data that represents an integer.
+TEST(RegisterValueTest, SetValueFromData_15_be) {
+ uint8_t src[] = {0x7F, 0xED};
+ TestSetValueFromData(etalon15, src, 2, lldb::ByteOrder::eByteOrderBig);
+}
+
+static const Scalar etalon16(APInt(32, 0x0000FEDC));
+
+// Test that the "RegisterValue::SetValueFromData" method works correctly
+// with 16-bit little-endian data that represents an integer.
+TEST(RegisterValueTest, SetValueFromData_16_le) {
+ uint8_t src[] = {0xDC, 0xFE};
+ TestSetValueFromData(etalon16, src, 2, lldb::ByteOrder::eByteOrderLittle);
+}
+
+// Test that the "RegisterValue::SetValueFromData" method works correctly
+// with 16-bit big-endian data that represents an integer.
+TEST(RegisterValueTest, SetValueFromData_16_be) {
+ uint8_t src[] = {0xFE, 0xDC};
+ TestSetValueFromData(etalon16, src, 2, lldb::ByteOrder::eByteOrderBig);
+}
+
+static const Scalar etalon17(APInt(32, 0x0001FEDC));
+
+// Test that the "RegisterValue::SetValueFromData" method works correctly
+// with 17-bit little-endian data that represents an integer.
+TEST(RegisterValueTest, SetValueFromData_17_le) {
+ uint8_t src[] = {0xDC, 0xFE, 0x01};
+ TestSetValueFromData(etalon17, src, 3, lldb::ByteOrder::eByteOrderLittle);
+}
+
+// Test that the "RegisterValue::SetValueFromData" method works correctly
+// with 17-bit big-endian data that represents an integer.
+TEST(RegisterValueTest, SetValueFromData_17_be) {
+ uint8_t src[] = {0x01, 0xFE, 0xDC};
+ TestSetValueFromData(etalon17, src, 3, lldb::ByteOrder::eByteOrderBig);
+}
+
+static const Scalar etalon24(APInt(32, 0x00FEDCBA));
+
+// Test that the "RegisterValue::SetValueFromData" method works correctly
+// with 24-bit little-endian data that represents an integer.
+TEST(RegisterValueTest, SetValueFromData_24_le) {
+ uint8_t src[] = {0xBA, 0xDC, 0xFE};
+ TestSetValueFromData(etalon24, src, 3, lldb::ByteOrder::eByteOrderLittle);
+}
+
+// Test that the "RegisterValue::SetValueFromData" method works correctly
+// with 24-bit big-endian data that represents an integer.
+TEST(RegisterValueTest, SetValueFromData_24_be) {
+ uint8_t src[] = {0xFE, 0xDC, 0xBA};
+ TestSetValueFromData(etalon24, src, 3, lldb::ByteOrder::eByteOrderBig);
+}
+
+static const Scalar etalon31(APInt(32, 0x7EDCBA98));
+
+// Test that the "RegisterValue::SetValueFromData" method works correctly
+// with 31-bit little-endian data that represents an integer.
+TEST(RegisterValueTest, SetValueFromData_31_le) {
+ uint8_t src[] = {0x98, 0xBA, 0xDC, 0x7E};
+ TestSetValueFromData(etalon31, src, 4, lldb::ByteOrder::eByteOrderLittle);
+}
+
+// Test that the "RegisterValue::SetValueFromData" method works correctly
+// with 31-bit big-endian data that represents an integer.
+TEST(RegisterValueTest, SetValueFromData_31_be) {
+ uint8_t src[] = {0x7E, 0xDC, 0xBA, 0x98};
+ TestSetValueFromData(etalon31, src, 4, lldb::ByteOrder::eByteOrderBig);
+}
+
+static const Scalar etalon32(APInt(32, 0xFEDCBA98));
+
+// Test that the "RegisterValue::SetValueFromData" method works correctly
+// with 32-bit little-endian data that represents an integer.
+TEST(RegisterValueTest, SetValueFromData_32_le) {
+ uint8_t src[] = {0x98, 0xBA, 0xDC, 0xFE};
+ TestSetValueFromData(etalon32, src, 4, lldb::ByteOrder::eByteOrderLittle);
+}
+
+// Test that the "RegisterValue::SetValueFromData" method works correctly
+// with 32-bit big-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);
+}
+
+static const Scalar etalon33(APInt(64, 0x00000001FEDCBA98));
+
+// Test that the "RegisterValue::SetValueFromData" method works correctly
+// with 33-bit little-endian data that represents an integer.
+TEST(RegisterValueTest, SetValueFromData_33_le) {
+ uint8_t src[] = {0x98, 0xBA, 0xDC, 0xFE, 0x01};
+ TestSetValueFromData(etalon33, src, 5, lldb::ByteOrder::eByteOrderLittle);
+}
+
+// Test that the "RegisterValue::SetValueFromData" method works correctly
+// with 33-bit big-endian data that represents an integer.
+TEST(RegisterValueTest, SetValueFromData_33_be) {
+ uint8_t src[] = {0x01, 0xFE, 0xDC, 0xBA, 0x98};
+ TestSetValueFromData(etalon33, src, 5, lldb::ByteOrder::eByteOrderBig);
+}
+
+static const Scalar etalon40(APInt(64, 0x000000FEDCBA9876));
+
+// Test that the "RegisterValue::SetValueFromData" method works correctly
+// with 40-bit little-endian data that represents an integer.
+TEST(RegisterValueTest, SetValueFromData_40_le) {
+ uint8_t src[] = {0x76, 0x98, 0xBA, 0xDC, 0xFE};
+ TestSetValueFromData(etalon40, src, 5, lldb::ByteOrder::eByteOrderLittle);
+}
+
+// Test that the "RegisterValue::SetValueFromData" method works correctly
+// with 33-bit big-endian data that represents an integer.
+TEST(RegisterValueTest, SetValueFromData_40_be) {
+ uint8_t src[] = {0xFE, 0xDC, 0xBA, 0x98, 0x76};
+ TestSetValueFromData(etalon40, src, 5, lldb::ByteOrder::eByteOrderBig);
+}
+
+static const Scalar etalon63(APInt(64, 0x7EDCBA9876543210));
+
+// Test that the "RegisterValue::SetValueFromData" method works correctly
+// with 63-bit little-endian data that represents an integer.
+TEST(RegisterValueTest, SetValueFromData_63_le) {
+ uint8_t src[] = {0x10, 0x32, 0x54, 0x76, 0x98, 0xBA, 0xDC, 0x7E};
+ TestSetValueFromData(etalon63, src, 8, lldb::ByteOrder::eByteOrderLittle);
+}
+
+// Test that the "RegisterValue::SetValueFromData" method works correctly
+// with 63-bit big-endian data that represents an integer.
+TEST(RegisterValueTest, SetValueFromData_63_be) {
+ uint8_t src[] = {0x7E, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10};
+ TestSetValueFromData(etalon63, src, 8, lldb::ByteOrder::eByteOrderBig);
+}
+
+static const Scalar etalon64(APInt(64, 0xFEDCBA9876543210));
+
+// Test that the "RegisterValue::SetValueFromData" method works correctly
+// with 64-bit little-endian data that represents an integer.
+TEST(RegisterValueTest, SetValueFromData_64_le) {
+ uint8_t src[] = {0x10, 0x32, 0x54, 0x76, 0x98, 0xBA, 0xDC, 0xFE};
+ TestSetValueFromData(etalon64, src, 8, lldb::ByteOrder::eByteOrderLittle);
+}
+
+// Test that the "RegisterValue::SetValueFromData" method works correctly
+// with 64-bit big-endian data that represents an integer.
+TEST(RegisterValueTest, SetValueFromData_64_be) {
+ uint8_t src[] = {0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10};
+ TestSetValueFromData(etalon64, src, 8, lldb::ByteOrder::eByteOrderBig);
+}
+
+static const Scalar etalon65(APInt(72, 0x0000000000000001ull) << 1 * 64 |
APInt(72, 0x0706050403020100ull) << 0 * 64);
// Test that the "RegisterValue::SetValueFromData" method works correctly
-// with 72-bit little-endian data that represents an integer.
-TEST(RegisterValueTest, SetValueFromData_72_le) {
- uint8_t src[] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08};
- TestSetValueFromData(etalon72, src, 9, lldb::ByteOrder::eByteOrderLittle);
+// with 65-bit little-endian data that represents an integer.
+TEST(RegisterValueTest, SetValueFromData_65_le) {
+ uint8_t src[] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01};
+ TestSetValueFromData(etalon65, src, 9, lldb::ByteOrder::eByteOrderLittle);
+}
+
+// Test that the "RegisterValue::SetValueFromData" method works correctly
+// with 65-bit big-endian data that represents an integer.
+TEST(RegisterValueTest, SetValueFromData_65_be) {
+ uint8_t src[] = {0x01, 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00};
+ TestSetValueFromData(etalon65, src, 9, lldb::ByteOrder::eByteOrderBig);
+}
+
+static const Scalar etalon127(APInt(128, 0x7f0e0d0c0b0a0908ull) << 1 * 64 |
+ APInt(128, 0x0706050403020100ull) << 0 * 64);
+
+// Test that the "RegisterValue::SetValueFromData" method works correctly
+// with 127-bit little-endian data that represents an integer.
+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);
}
// Test that the "RegisterValue::SetValueFromData" method works correctly
-// with 72-bit big-endian data that represents an integer.
-TEST(RegisterValueTest, SetValueFromData_72_be) {
- uint8_t src[] = {0x08, 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00};
- TestSetValueFromData(etalon72, src, 9, lldb::ByteOrder::eByteOrderBig);
+// with 128-bit big-endian data that represents an integer.
+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);
}
static const Scalar etalon128(APInt(128, 0x0f0e0d0c0b0a0908ull) << 1 * 64 |
>From d368469f9656963ede5b84e6670fc847c1bb6933 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Matej=20Ko=C5=A1=C3=ADk?= <matej.kosik at codasip.com>
Date: Wed, 5 Nov 2025 22:40:28 +0100
Subject: [PATCH 12/28] [lldb] add a new test
---
lldb/unittests/Utility/RegisterValueTest.cpp | 28 ++++++++++++++++++++
1 file changed, 28 insertions(+)
diff --git a/lldb/unittests/Utility/RegisterValueTest.cpp b/lldb/unittests/Utility/RegisterValueTest.cpp
index b1bdabbe7116e..63795d23bbbae 100644
--- a/lldb/unittests/Utility/RegisterValueTest.cpp
+++ b/lldb/unittests/Utility/RegisterValueTest.cpp
@@ -364,3 +364,31 @@ TEST(RegisterValueTest, SetValueFromData_256_be) {
0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00};
TestSetValueFromData(etalon256, src, 32, lldb::ByteOrder::eByteOrderBig);
}
+
+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 that the "RegisterValue::SetValueFromData" method works correctly
+// with 256-bit little-endian data that represents an integer.
+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);
+}
+
+// Test that the "RegisterValue::SetValueFromData" method works correctly
+// with 256-bit big-endian data that represents an integer.
+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);
+}
>From 804442f418bce677fb6381b5d1facab1fedc1693 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Matej=20Ko=C5=A1=C3=ADk?= <matej.kosik at codasip.com>
Date: Wed, 5 Nov 2025 23:11:53 +0100
Subject: [PATCH 13/28] [lldb] formatting
---
lldb/source/Utility/RegisterValue.cpp | 2 ++
1 file changed, 2 insertions(+)
diff --git a/lldb/source/Utility/RegisterValue.cpp b/lldb/source/Utility/RegisterValue.cpp
index bc7ae5606bf64..a2a2ff9da1351 100644
--- a/lldb/source/Utility/RegisterValue.cpp
+++ b/lldb/source/Utility/RegisterValue.cpp
@@ -211,8 +211,10 @@ Status RegisterValue::SetValueFromData(const RegisterInfo ®_info,
std::vector<uint8_t> bytes(src_len, 0);
for (size_t i = 0; i < src_len; i++)
bytes[i] = src.GetU8(&src_offset);
+
if (src.GetByteOrder() == eByteOrderBig)
std::reverse(bytes.begin(), bytes.end());
+
// The number of 64-bit wide words that are stored in "src".
size_t size64 = (reg_info.byte_size - 1) / 8 + 1;
bytes.resize(size64 * sizeof(uint64_t), 0);
>From 2a1bb4c68e72e2c8773b220604663e8354ec559c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Matej=20Ko=C5=A1=C3=ADk?= <matej.kosik at codasip.com>
Date: Thu, 6 Nov 2025 13:58:01 +0100
Subject: [PATCH 14/28] [lldb] add more comments
---
lldb/source/Utility/RegisterValue.cpp | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
diff --git a/lldb/source/Utility/RegisterValue.cpp b/lldb/source/Utility/RegisterValue.cpp
index a2a2ff9da1351..f68b8ab383eb4 100644
--- a/lldb/source/Utility/RegisterValue.cpp
+++ b/lldb/source/Utility/RegisterValue.cpp
@@ -213,11 +213,20 @@ Status RegisterValue::SetValueFromData(const RegisterInfo ®_info,
bytes[i] = src.GetU8(&src_offset);
if (src.GetByteOrder() == eByteOrderBig)
+ // Transform the big-endian input to little-endian
+ // because that is what the "llvm::LoadIntFromMemory" function
+ // we call below expects.
std::reverse(bytes.begin(), bytes.end());
- // The number of 64-bit wide words that are stored in "src".
- size_t size64 = (reg_info.byte_size - 1) / 8 + 1;
- bytes.resize(size64 * sizeof(uint64_t), 0);
+ if (llvm::sys::IsBigEndianHost) {
+ // If LLDB runs on a big-endian architecture,
+ // make sure that the input data can be read in
+ // 64-bit chunks because that is what
+ // the "llvm::LoadIntFromMemory" function will do.
+ size_t size64 = (reg_info.byte_size - 1) / 8 + 1;
+ bytes.resize(size64 * sizeof(uint64_t), 0);
+ }
+
llvm::APInt uint = llvm::APInt::getZero(src_len * 8);
llvm::LoadIntFromMemory(uint, bytes.data(), src_len);
SetUInt128(uint);
>From 79a8afbdfbe41da5faae6d536c34383798496e6b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Matej=20Ko=C5=A1=C3=ADk?= <matej.kosik at codasip.com>
Date: Thu, 6 Nov 2025 14:04:55 +0100
Subject: [PATCH 15/28] [lldb] formatting
---
lldb/unittests/Utility/RegisterValueTest.cpp | 18 ++++++++----------
1 file changed, 8 insertions(+), 10 deletions(-)
diff --git a/lldb/unittests/Utility/RegisterValueTest.cpp b/lldb/unittests/Utility/RegisterValueTest.cpp
index 63795d23bbbae..c89848e006ccf 100644
--- a/lldb/unittests/Utility/RegisterValueTest.cpp
+++ b/lldb/unittests/Utility/RegisterValueTest.cpp
@@ -374,21 +374,19 @@ static const Scalar etalon257(APInt(512, 0x0000000000000001ull) << 4 * 64 |
// Test that the "RegisterValue::SetValueFromData" method works correctly
// with 256-bit little-endian data that represents an integer.
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};
+ 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);
}
// Test that the "RegisterValue::SetValueFromData" method works correctly
// with 256-bit big-endian data that represents an integer.
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};
+ 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);
}
>From b362aeb16a793fbfe4c14550b47ca286492ff16b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Matej=20Ko=C5=A1=C3=ADk?= <matej.kosik at codasip.com>
Date: Thu, 6 Nov 2025 14:15:57 +0100
Subject: [PATCH 16/28] [lldb] rename the enum value
---
lldb/include/lldb/Utility/RegisterValue.h | 2 +-
lldb/source/Utility/RegisterValue.cpp | 24 +++++++++++------------
2 files changed, 13 insertions(+), 13 deletions(-)
diff --git a/lldb/include/lldb/Utility/RegisterValue.h b/lldb/include/lldb/Utility/RegisterValue.h
index 6587cff786c01..1814b01adc68b 100644
--- a/lldb/include/lldb/Utility/RegisterValue.h
+++ b/lldb/include/lldb/Utility/RegisterValue.h
@@ -46,7 +46,7 @@ class RegisterValue {
eTypeUInt16,
eTypeUInt32,
eTypeUInt64,
- eTypeUInt, /// < An integer that has more than 64 bits.
+ eTypeUIntN, // An integer that has more than 64 bits.
eTypeFloat,
eTypeDouble,
eTypeLongDouble,
diff --git a/lldb/source/Utility/RegisterValue.cpp b/lldb/source/Utility/RegisterValue.cpp
index f68b8ab383eb4..89bc047172537 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 eTypeUInt:
+ case eTypeUIntN:
case eTypeFloat:
case eTypeDouble:
case eTypeLongDouble:
@@ -465,7 +465,7 @@ bool RegisterValue::SignExtend(uint32_t sign_bitpos) {
case eTypeUInt16:
case eTypeUInt32:
case eTypeUInt64:
- case eTypeUInt:
+ case eTypeUIntN:
return m_scalar.SignExtend(sign_bitpos);
case eTypeFloat:
case eTypeDouble:
@@ -488,7 +488,7 @@ bool RegisterValue::CopyValue(const RegisterValue &rhs) {
case eTypeUInt16:
case eTypeUInt32:
case eTypeUInt64:
- case eTypeUInt:
+ case eTypeUIntN:
case eTypeFloat:
case eTypeDouble:
case eTypeLongDouble:
@@ -604,7 +604,7 @@ llvm::APInt RegisterValue::GetAsUInt128(const llvm::APInt &fail_value,
case eTypeUInt16:
case eTypeUInt32:
case eTypeUInt64:
- case eTypeUInt:
+ case eTypeUIntN:
case eTypeFloat:
case eTypeDouble:
case eTypeLongDouble:
@@ -639,7 +639,7 @@ float RegisterValue::GetAsFloat(float fail_value, bool *success_ptr) const {
break;
case eTypeUInt32:
case eTypeUInt64:
- case eTypeUInt:
+ case eTypeUIntN:
case eTypeFloat:
case eTypeDouble:
case eTypeLongDouble:
@@ -659,7 +659,7 @@ double RegisterValue::GetAsDouble(double fail_value, bool *success_ptr) const {
case eTypeUInt32:
case eTypeUInt64:
- case eTypeUInt:
+ case eTypeUIntN:
case eTypeFloat:
case eTypeDouble:
case eTypeLongDouble:
@@ -680,7 +680,7 @@ long double RegisterValue::GetAsLongDouble(long double fail_value,
case eTypeUInt32:
case eTypeUInt64:
- case eTypeUInt:
+ case eTypeUIntN:
case eTypeFloat:
case eTypeDouble:
case eTypeLongDouble:
@@ -699,7 +699,7 @@ const void *RegisterValue::GetBytes() const {
case eTypeUInt16:
case eTypeUInt32:
case eTypeUInt64:
- case eTypeUInt:
+ case eTypeUIntN:
case eTypeFloat:
case eTypeDouble:
case eTypeLongDouble:
@@ -721,7 +721,7 @@ uint32_t RegisterValue::GetByteSize() const {
return 2;
case eTypeUInt32:
case eTypeUInt64:
- case eTypeUInt:
+ case eTypeUIntN:
case eTypeFloat:
case eTypeDouble:
case eTypeLongDouble:
@@ -772,7 +772,7 @@ bool RegisterValue::operator==(const RegisterValue &rhs) const {
case eTypeUInt16:
case eTypeUInt32:
case eTypeUInt64:
- case eTypeUInt:
+ case eTypeUIntN:
case eTypeFloat:
case eTypeDouble:
case eTypeLongDouble:
@@ -797,7 +797,7 @@ bool RegisterValue::ClearBit(uint32_t bit) {
case eTypeUInt16:
case eTypeUInt32:
case eTypeUInt64:
- case eTypeUInt:
+ case eTypeUIntN:
if (bit < (GetByteSize() * 8)) {
return m_scalar.ClearBit(bit);
}
@@ -837,7 +837,7 @@ bool RegisterValue::SetBit(uint32_t bit) {
case eTypeUInt16:
case eTypeUInt32:
case eTypeUInt64:
- case eTypeUInt:
+ case eTypeUIntN:
if (bit < (GetByteSize() * 8)) {
return m_scalar.SetBit(bit);
}
>From 84fb0313576d4eb0f6cf65ddc4bf089e262e8425 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Matej=20Ko=C5=A1=C3=ADk?= <matej.kosik at codasip.com>
Date: Thu, 6 Nov 2025 14:21:52 +0100
Subject: [PATCH 17/28] [lldb] update the comment
---
lldb/include/lldb/Utility/RegisterValue.h | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/lldb/include/lldb/Utility/RegisterValue.h b/lldb/include/lldb/Utility/RegisterValue.h
index 1814b01adc68b..c64c3b0f5d240 100644
--- a/lldb/include/lldb/Utility/RegisterValue.h
+++ b/lldb/include/lldb/Utility/RegisterValue.h
@@ -46,7 +46,8 @@ class RegisterValue {
eTypeUInt16,
eTypeUInt32,
eTypeUInt64,
- eTypeUIntN, // An integer that has more than 64 bits.
+ eTypeUIntN, /// < This value is used when the (integer) register is larger
+ /// than 64-bits.
eTypeFloat,
eTypeDouble,
eTypeLongDouble,
>From 7682406275994654cb33ea0fad86b4defeebf38c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Matej=20Ko=C5=A1=C3=ADk?= <matej.kosik at codasip.com>
Date: Thu, 6 Nov 2025 17:16:24 +0100
Subject: [PATCH 18/28] [lldb] fix the compilation
---
lldb/include/lldb/Utility/RegisterValue.h | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/lldb/include/lldb/Utility/RegisterValue.h b/lldb/include/lldb/Utility/RegisterValue.h
index c64c3b0f5d240..a6c583c39ff51 100644
--- a/lldb/include/lldb/Utility/RegisterValue.h
+++ b/lldb/include/lldb/Utility/RegisterValue.h
@@ -70,7 +70,7 @@ class RegisterValue {
m_scalar = inst;
}
- explicit RegisterValue(llvm::APInt inst) : m_type(eTypeUInt) {
+ explicit RegisterValue(llvm::APInt inst) : m_type(eTypeUIntN) {
m_scalar = llvm::APInt(std::move(inst));
}
@@ -179,7 +179,7 @@ class RegisterValue {
}
void operator=(llvm::APInt uint) {
- m_type = eTypeUInt;
+ m_type = eTypeUIntN;
m_scalar = llvm::APInt(std::move(uint));
}
@@ -219,7 +219,7 @@ class RegisterValue {
}
void SetUInt128(llvm::APInt uint) {
- m_type = eTypeUInt;
+ m_type = eTypeUIntN;
m_scalar = std::move(uint);
}
>From 56c86e5a4b140ada7d8878194ca0c7112e2dcd07 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Matej=20Ko=C5=A1=C3=ADk?= <matej.kosik at codasip.com>
Date: Thu, 6 Nov 2025 17:34:45 +0100
Subject: [PATCH 19/28] [lldb] change the name of the
"RegisterValue::SetUInt128" method in order to avoid confusion
---
lldb/include/lldb/Utility/RegisterValue.h | 2 +-
lldb/source/Utility/RegisterValue.cpp | 6 +++---
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/lldb/include/lldb/Utility/RegisterValue.h b/lldb/include/lldb/Utility/RegisterValue.h
index a6c583c39ff51..baf984cbcb052 100644
--- a/lldb/include/lldb/Utility/RegisterValue.h
+++ b/lldb/include/lldb/Utility/RegisterValue.h
@@ -218,7 +218,7 @@ class RegisterValue {
m_scalar = uint;
}
- void SetUInt128(llvm::APInt uint) {
+ void SetUIntN(llvm::APInt uint) {
m_type = eTypeUIntN;
m_scalar = std::move(uint);
}
diff --git a/lldb/source/Utility/RegisterValue.cpp b/lldb/source/Utility/RegisterValue.cpp
index 89bc047172537..519348f52d9c5 100644
--- a/lldb/source/Utility/RegisterValue.cpp
+++ b/lldb/source/Utility/RegisterValue.cpp
@@ -206,7 +206,7 @@ Status RegisterValue::SetValueFromData(const RegisterInfo ®_info,
int128.x[0] = data2;
int128.x[1] = data1;
}
- SetUInt128(llvm::APInt(128, int128.x));
+ SetUIntN(llvm::APInt(128, int128.x));
} else {
std::vector<uint8_t> bytes(src_len, 0);
for (size_t i = 0; i < src_len; i++)
@@ -229,7 +229,7 @@ Status RegisterValue::SetValueFromData(const RegisterInfo ®_info,
llvm::APInt uint = llvm::APInt::getZero(src_len * 8);
llvm::LoadIntFromMemory(uint, bytes.data(), src_len);
- SetUInt128(uint);
+ SetUIntN(uint);
}
break;
case eEncodingIEEE754:
@@ -744,7 +744,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;
>From d36d6bf22048fa8b66e64b849bb60da2cfa4a280 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Matej=20Ko=C5=A1=C3=ADk?= <matej.kosik at codasip.com>
Date: Thu, 6 Nov 2025 18:23:21 +0100
Subject: [PATCH 20/28] [lldb] remove superluous tests from the
"RegisterValueTest.cpp" file
---
lldb/unittests/Utility/RegisterValueTest.cpp | 72 --------------------
1 file changed, 72 deletions(-)
diff --git a/lldb/unittests/Utility/RegisterValueTest.cpp b/lldb/unittests/Utility/RegisterValueTest.cpp
index c89848e006ccf..6f616b1aca392 100644
--- a/lldb/unittests/Utility/RegisterValueTest.cpp
+++ b/lldb/unittests/Utility/RegisterValueTest.cpp
@@ -79,15 +79,11 @@ void TestSetValueFromData(const Scalar &etalon, void *src, size_t src_byte_size,
static const Scalar etalon7(APInt(32, 0x0000007F));
-// Test that the "RegisterValue::SetValueFromData" method works correctly
-// with 7-bit little-endian data that represents an integer.
TEST(RegisterValueTest, SetValueFromData_7_le) {
uint8_t src[] = {0x7F};
TestSetValueFromData(etalon7, src, 1, lldb::ByteOrder::eByteOrderLittle);
}
-// Test that the "RegisterValue::SetValueFromData" method works correctly
-// with 7-bit big-endian data that represents an integer.
TEST(RegisterValueTest, SetValueFromData_7_be) {
uint8_t src[] = {0x7F};
TestSetValueFromData(etalon7, src, 1, lldb::ByteOrder::eByteOrderBig);
@@ -95,15 +91,11 @@ TEST(RegisterValueTest, SetValueFromData_7_be) {
static const Scalar etalon8(APInt(32, 0x000000FE));
-// Test that the "RegisterValue::SetValueFromData" method works correctly
-// with 8-bit little-endian data that represents an integer.
TEST(RegisterValueTest, SetValueFromData_8_le) {
uint8_t src[] = {0xFE};
TestSetValueFromData(etalon8, src, 1, lldb::ByteOrder::eByteOrderLittle);
}
-// Test that the "RegisterValue::SetValueFromData" method works correctly
-// with 8-bit big-endian data that represents an integer.
TEST(RegisterValueTest, SetValueFromData_8_be) {
uint8_t src[] = {0xFE};
TestSetValueFromData(etalon8, src, 1, lldb::ByteOrder::eByteOrderBig);
@@ -111,15 +103,11 @@ TEST(RegisterValueTest, SetValueFromData_8_be) {
static const Scalar etalon9(APInt(32, 0x000001FE));
-// Test that the "RegisterValue::SetValueFromData" method works correctly
-// with 9-bit little-endian data that represents an integer.
TEST(RegisterValueTest, SetValueFromData_9_le) {
uint8_t src[] = {0xFE, 0x01};
TestSetValueFromData(etalon9, src, 2, lldb::ByteOrder::eByteOrderLittle);
}
-// Test that the "RegisterValue::SetValueFromData" method works correctly
-// with 9-bit big-endian data that represents an integer.
TEST(RegisterValueTest, SetValueFromData_9_be) {
uint8_t src[] = {0x01, 0xFE};
TestSetValueFromData(etalon9, src, 2, lldb::ByteOrder::eByteOrderBig);
@@ -127,15 +115,11 @@ TEST(RegisterValueTest, SetValueFromData_9_be) {
static const Scalar etalon15(APInt(32, 0x00007FED));
-// Test that the "RegisterValue::SetValueFromData" method works correctly
-// with 15-bit little-endian data that represents an integer.
TEST(RegisterValueTest, SetValueFromData_15_le) {
uint8_t src[] = {0xED, 0x7F};
TestSetValueFromData(etalon15, src, 2, lldb::ByteOrder::eByteOrderLittle);
}
-// Test that the "RegisterValue::SetValueFromData" method works correctly
-// with 15-bit big-endian data that represents an integer.
TEST(RegisterValueTest, SetValueFromData_15_be) {
uint8_t src[] = {0x7F, 0xED};
TestSetValueFromData(etalon15, src, 2, lldb::ByteOrder::eByteOrderBig);
@@ -143,15 +127,11 @@ TEST(RegisterValueTest, SetValueFromData_15_be) {
static const Scalar etalon16(APInt(32, 0x0000FEDC));
-// Test that the "RegisterValue::SetValueFromData" method works correctly
-// with 16-bit little-endian data that represents an integer.
TEST(RegisterValueTest, SetValueFromData_16_le) {
uint8_t src[] = {0xDC, 0xFE};
TestSetValueFromData(etalon16, src, 2, lldb::ByteOrder::eByteOrderLittle);
}
-// Test that the "RegisterValue::SetValueFromData" method works correctly
-// with 16-bit big-endian data that represents an integer.
TEST(RegisterValueTest, SetValueFromData_16_be) {
uint8_t src[] = {0xFE, 0xDC};
TestSetValueFromData(etalon16, src, 2, lldb::ByteOrder::eByteOrderBig);
@@ -159,15 +139,11 @@ TEST(RegisterValueTest, SetValueFromData_16_be) {
static const Scalar etalon17(APInt(32, 0x0001FEDC));
-// Test that the "RegisterValue::SetValueFromData" method works correctly
-// with 17-bit little-endian data that represents an integer.
TEST(RegisterValueTest, SetValueFromData_17_le) {
uint8_t src[] = {0xDC, 0xFE, 0x01};
TestSetValueFromData(etalon17, src, 3, lldb::ByteOrder::eByteOrderLittle);
}
-// Test that the "RegisterValue::SetValueFromData" method works correctly
-// with 17-bit big-endian data that represents an integer.
TEST(RegisterValueTest, SetValueFromData_17_be) {
uint8_t src[] = {0x01, 0xFE, 0xDC};
TestSetValueFromData(etalon17, src, 3, lldb::ByteOrder::eByteOrderBig);
@@ -175,15 +151,11 @@ TEST(RegisterValueTest, SetValueFromData_17_be) {
static const Scalar etalon24(APInt(32, 0x00FEDCBA));
-// Test that the "RegisterValue::SetValueFromData" method works correctly
-// with 24-bit little-endian data that represents an integer.
TEST(RegisterValueTest, SetValueFromData_24_le) {
uint8_t src[] = {0xBA, 0xDC, 0xFE};
TestSetValueFromData(etalon24, src, 3, lldb::ByteOrder::eByteOrderLittle);
}
-// Test that the "RegisterValue::SetValueFromData" method works correctly
-// with 24-bit big-endian data that represents an integer.
TEST(RegisterValueTest, SetValueFromData_24_be) {
uint8_t src[] = {0xFE, 0xDC, 0xBA};
TestSetValueFromData(etalon24, src, 3, lldb::ByteOrder::eByteOrderBig);
@@ -191,15 +163,11 @@ TEST(RegisterValueTest, SetValueFromData_24_be) {
static const Scalar etalon31(APInt(32, 0x7EDCBA98));
-// Test that the "RegisterValue::SetValueFromData" method works correctly
-// with 31-bit little-endian data that represents an integer.
TEST(RegisterValueTest, SetValueFromData_31_le) {
uint8_t src[] = {0x98, 0xBA, 0xDC, 0x7E};
TestSetValueFromData(etalon31, src, 4, lldb::ByteOrder::eByteOrderLittle);
}
-// Test that the "RegisterValue::SetValueFromData" method works correctly
-// with 31-bit big-endian data that represents an integer.
TEST(RegisterValueTest, SetValueFromData_31_be) {
uint8_t src[] = {0x7E, 0xDC, 0xBA, 0x98};
TestSetValueFromData(etalon31, src, 4, lldb::ByteOrder::eByteOrderBig);
@@ -207,15 +175,11 @@ TEST(RegisterValueTest, SetValueFromData_31_be) {
static const Scalar etalon32(APInt(32, 0xFEDCBA98));
-// Test that the "RegisterValue::SetValueFromData" method works correctly
-// with 32-bit little-endian data that represents an integer.
TEST(RegisterValueTest, SetValueFromData_32_le) {
uint8_t src[] = {0x98, 0xBA, 0xDC, 0xFE};
TestSetValueFromData(etalon32, src, 4, lldb::ByteOrder::eByteOrderLittle);
}
-// Test that the "RegisterValue::SetValueFromData" method works correctly
-// with 32-bit big-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);
@@ -223,15 +187,11 @@ TEST(RegisterValueTest, SetValueFromData_32_be) {
static const Scalar etalon33(APInt(64, 0x00000001FEDCBA98));
-// Test that the "RegisterValue::SetValueFromData" method works correctly
-// with 33-bit little-endian data that represents an integer.
TEST(RegisterValueTest, SetValueFromData_33_le) {
uint8_t src[] = {0x98, 0xBA, 0xDC, 0xFE, 0x01};
TestSetValueFromData(etalon33, src, 5, lldb::ByteOrder::eByteOrderLittle);
}
-// Test that the "RegisterValue::SetValueFromData" method works correctly
-// with 33-bit big-endian data that represents an integer.
TEST(RegisterValueTest, SetValueFromData_33_be) {
uint8_t src[] = {0x01, 0xFE, 0xDC, 0xBA, 0x98};
TestSetValueFromData(etalon33, src, 5, lldb::ByteOrder::eByteOrderBig);
@@ -239,15 +199,11 @@ TEST(RegisterValueTest, SetValueFromData_33_be) {
static const Scalar etalon40(APInt(64, 0x000000FEDCBA9876));
-// Test that the "RegisterValue::SetValueFromData" method works correctly
-// with 40-bit little-endian data that represents an integer.
TEST(RegisterValueTest, SetValueFromData_40_le) {
uint8_t src[] = {0x76, 0x98, 0xBA, 0xDC, 0xFE};
TestSetValueFromData(etalon40, src, 5, lldb::ByteOrder::eByteOrderLittle);
}
-// Test that the "RegisterValue::SetValueFromData" method works correctly
-// with 33-bit big-endian data that represents an integer.
TEST(RegisterValueTest, SetValueFromData_40_be) {
uint8_t src[] = {0xFE, 0xDC, 0xBA, 0x98, 0x76};
TestSetValueFromData(etalon40, src, 5, lldb::ByteOrder::eByteOrderBig);
@@ -255,15 +211,11 @@ TEST(RegisterValueTest, SetValueFromData_40_be) {
static const Scalar etalon63(APInt(64, 0x7EDCBA9876543210));
-// Test that the "RegisterValue::SetValueFromData" method works correctly
-// with 63-bit little-endian data that represents an integer.
TEST(RegisterValueTest, SetValueFromData_63_le) {
uint8_t src[] = {0x10, 0x32, 0x54, 0x76, 0x98, 0xBA, 0xDC, 0x7E};
TestSetValueFromData(etalon63, src, 8, lldb::ByteOrder::eByteOrderLittle);
}
-// Test that the "RegisterValue::SetValueFromData" method works correctly
-// with 63-bit big-endian data that represents an integer.
TEST(RegisterValueTest, SetValueFromData_63_be) {
uint8_t src[] = {0x7E, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10};
TestSetValueFromData(etalon63, src, 8, lldb::ByteOrder::eByteOrderBig);
@@ -271,15 +223,11 @@ TEST(RegisterValueTest, SetValueFromData_63_be) {
static const Scalar etalon64(APInt(64, 0xFEDCBA9876543210));
-// Test that the "RegisterValue::SetValueFromData" method works correctly
-// with 64-bit little-endian data that represents an integer.
TEST(RegisterValueTest, SetValueFromData_64_le) {
uint8_t src[] = {0x10, 0x32, 0x54, 0x76, 0x98, 0xBA, 0xDC, 0xFE};
TestSetValueFromData(etalon64, src, 8, lldb::ByteOrder::eByteOrderLittle);
}
-// Test that the "RegisterValue::SetValueFromData" method works correctly
-// with 64-bit big-endian data that represents an integer.
TEST(RegisterValueTest, SetValueFromData_64_be) {
uint8_t src[] = {0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10};
TestSetValueFromData(etalon64, src, 8, lldb::ByteOrder::eByteOrderBig);
@@ -288,15 +236,11 @@ TEST(RegisterValueTest, SetValueFromData_64_be) {
static const Scalar etalon65(APInt(72, 0x0000000000000001ull) << 1 * 64 |
APInt(72, 0x0706050403020100ull) << 0 * 64);
-// Test that the "RegisterValue::SetValueFromData" method works correctly
-// with 65-bit little-endian data that represents an integer.
TEST(RegisterValueTest, SetValueFromData_65_le) {
uint8_t src[] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x01};
TestSetValueFromData(etalon65, src, 9, lldb::ByteOrder::eByteOrderLittle);
}
-// Test that the "RegisterValue::SetValueFromData" method works correctly
-// with 65-bit big-endian data that represents an integer.
TEST(RegisterValueTest, SetValueFromData_65_be) {
uint8_t src[] = {0x01, 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00};
TestSetValueFromData(etalon65, src, 9, lldb::ByteOrder::eByteOrderBig);
@@ -305,16 +249,12 @@ TEST(RegisterValueTest, SetValueFromData_65_be) {
static const Scalar etalon127(APInt(128, 0x7f0e0d0c0b0a0908ull) << 1 * 64 |
APInt(128, 0x0706050403020100ull) << 0 * 64);
-// Test that the "RegisterValue::SetValueFromData" method works correctly
-// with 127-bit little-endian data that represents an integer.
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);
}
-// Test that the "RegisterValue::SetValueFromData" method works correctly
-// with 128-bit big-endian data that represents an integer.
TEST(RegisterValueTest, SetValueFromData_127_be) {
uint8_t src[] = {0x7f, 0x0e, 0x0d, 0x0c, 0x0b, 0x0a, 0x09, 0x08,
0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00};
@@ -324,16 +264,12 @@ TEST(RegisterValueTest, SetValueFromData_127_be) {
static const Scalar etalon128(APInt(128, 0x0f0e0d0c0b0a0908ull) << 1 * 64 |
APInt(128, 0x0706050403020100ull) << 0 * 64);
-// Test that the "RegisterValue::SetValueFromData" method works correctly
-// with 128-bit little-endian data that represents an integer.
TEST(RegisterValueTest, SetValueFromData_128_le) {
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);
}
-// 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[] = {0x0f, 0x0e, 0x0d, 0x0c, 0x0b, 0x0a, 0x09, 0x08,
0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00};
@@ -345,8 +281,6 @@ static const Scalar etalon256(APInt(256, 0x1f1e1d1c1b1a1918ull) << 3 * 64 |
APInt(256, 0x0f0e0d0c0b0a0908ull) << 1 * 64 |
APInt(256, 0x0706050403020100ull) << 0 * 64);
-// Test that the "RegisterValue::SetValueFromData" method works correctly
-// with 256-bit little-endian data that represents an integer.
TEST(RegisterValueTest, SetValueFromData_256_le) {
uint8_t src[] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
@@ -355,8 +289,6 @@ TEST(RegisterValueTest, SetValueFromData_256_le) {
TestSetValueFromData(etalon256, src, 32, lldb::ByteOrder::eByteOrderLittle);
}
-// Test that the "RegisterValue::SetValueFromData" method works correctly
-// with 256-bit big-endian data that represents an integer.
TEST(RegisterValueTest, SetValueFromData_256_be) {
uint8_t src[] = {0x1f, 0x1e, 0x1d, 0x1c, 0x1b, 0x1a, 0x19, 0x18,
0x17, 0x16, 0x15, 0x14, 0x13, 0x12, 0x11, 0x10,
@@ -371,8 +303,6 @@ static const Scalar etalon257(APInt(512, 0x0000000000000001ull) << 4 * 64 |
APInt(512, 0x0f0e0d0c0b0a0908ull) << 1 * 64 |
APInt(512, 0x0706050403020100ull) << 0 * 64);
-// Test that the "RegisterValue::SetValueFromData" method works correctly
-// with 256-bit little-endian data that represents an integer.
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,
@@ -381,8 +311,6 @@ TEST(RegisterValueTest, SetValueFromData_257_le) {
TestSetValueFromData(etalon257, src, 33, lldb::ByteOrder::eByteOrderLittle);
}
-// Test that the "RegisterValue::SetValueFromData" method works correctly
-// with 256-bit big-endian data that represents an integer.
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,
>From 359cd66926004caa07c5d4a57e5c7f7b6ac1d1a3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Matej=20Ko=C5=A1=C3=ADk?= <matej.kosik at codasip.com>
Date: Fri, 7 Nov 2025 12:42:26 +0100
Subject: [PATCH 21/28] [lldb] explicitely check the type of the created
RegisterValue object in tests
---
lldb/unittests/Utility/RegisterValueTest.cpp | 112 +++++++++++++------
1 file changed, 75 insertions(+), 37 deletions(-)
diff --git a/lldb/unittests/Utility/RegisterValueTest.cpp b/lldb/unittests/Utility/RegisterValueTest.cpp
index 6f616b1aca392..7b27e841cbec5 100644
--- a/lldb/unittests/Utility/RegisterValueTest.cpp
+++ b/lldb/unittests/Utility/RegisterValueTest.cpp
@@ -58,7 +58,8 @@ TEST(RegisterValueTest, GetScalarValue) {
}
void TestSetValueFromData(const Scalar &etalon, void *src, size_t src_byte_size,
- const lldb::ByteOrder endianness) {
+ const lldb::ByteOrder endianness,
+ const RegisterValue::Type register_value_type) {
RegisterInfo ri{"test",
nullptr,
static_cast<uint32_t>(src_byte_size),
@@ -74,6 +75,7 @@ void TestSetValueFromData(const Scalar &etalon, void *src, size_t src_byte_size,
EXPECT_TRUE(rv.SetValueFromData(ri, src_extractor, 0, false).Success());
Scalar s;
EXPECT_TRUE(rv.GetScalarValue(s));
+ EXPECT_EQ(rv.GetType(), register_value_type);
EXPECT_EQ(s, etalon);
}
@@ -81,156 +83,182 @@ static const Scalar etalon7(APInt(32, 0x0000007F));
TEST(RegisterValueTest, SetValueFromData_7_le) {
uint8_t src[] = {0x7F};
- TestSetValueFromData(etalon7, src, 1, lldb::ByteOrder::eByteOrderLittle);
+ 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);
+ 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);
+ 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);
+ 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);
+ 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);
+ 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);
+ 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);
+ 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);
+ 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);
+ 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);
+ 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);
+ 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);
+ 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);
+ 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);
+ 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);
+ 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);
+ TestSetValueFromData(etalon32, src, 4, lldb::ByteOrder::eByteOrderLittle,
+ RegisterValue::eTypeUInt32);
}
TEST(RegisterValueTest, SetValueFromData_32_be) {
uint8_t src[] = {0xFE, 0xDC, 0xBA, 0x98};
- TestSetValueFromData(etalon32, src, 4, lldb::ByteOrder::eByteOrderBig);
+ 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);
+ 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);
+ 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);
+ 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);
+ 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);
+ 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);
+ 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);
+ 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);
+ TestSetValueFromData(etalon64, src, 8, lldb::ByteOrder::eByteOrderBig,
+ RegisterValue::eTypeUInt64);
}
static const Scalar etalon65(APInt(72, 0x0000000000000001ull) << 1 * 64 |
@@ -238,12 +266,14 @@ static const Scalar etalon65(APInt(72, 0x0000000000000001ull) << 1 * 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);
+ 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);
+ TestSetValueFromData(etalon65, src, 9, lldb::ByteOrder::eByteOrderBig,
+ RegisterValue::eTypeUIntN);
}
static const Scalar etalon127(APInt(128, 0x7f0e0d0c0b0a0908ull) << 1 * 64 |
@@ -252,13 +282,15 @@ static const Scalar etalon127(APInt(128, 0x7f0e0d0c0b0a0908ull) << 1 * 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);
+ 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);
+ TestSetValueFromData(etalon127, src, 16, lldb::ByteOrder::eByteOrderBig,
+ RegisterValue::eTypeUIntN);
}
static const Scalar etalon128(APInt(128, 0x0f0e0d0c0b0a0908ull) << 1 * 64 |
@@ -267,13 +299,15 @@ static const Scalar etalon128(APInt(128, 0x0f0e0d0c0b0a0908ull) << 1 * 64 |
TEST(RegisterValueTest, SetValueFromData_128_le) {
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);
+ TestSetValueFromData(etalon128, src, 16, lldb::ByteOrder::eByteOrderLittle,
+ RegisterValue::eTypeUIntN);
}
TEST(RegisterValueTest, SetValueFromData_128_be) {
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);
+ TestSetValueFromData(etalon128, src, 16, lldb::ByteOrder::eByteOrderBig,
+ RegisterValue::eTypeUIntN);
}
static const Scalar etalon256(APInt(256, 0x1f1e1d1c1b1a1918ull) << 3 * 64 |
@@ -286,7 +320,8 @@ TEST(RegisterValueTest, SetValueFromData_256_le) {
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);
+ TestSetValueFromData(etalon256, src, 32, lldb::ByteOrder::eByteOrderLittle,
+ RegisterValue::eTypeUIntN);
}
TEST(RegisterValueTest, SetValueFromData_256_be) {
@@ -294,7 +329,8 @@ TEST(RegisterValueTest, SetValueFromData_256_be) {
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);
+ TestSetValueFromData(etalon256, src, 32, lldb::ByteOrder::eByteOrderBig,
+ RegisterValue::eTypeUIntN);
}
static const Scalar etalon257(APInt(512, 0x0000000000000001ull) << 4 * 64 |
@@ -308,7 +344,8 @@ TEST(RegisterValueTest, SetValueFromData_257_le) {
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);
+ TestSetValueFromData(etalon257, src, 33, lldb::ByteOrder::eByteOrderLittle,
+ RegisterValue::eTypeUIntN);
}
TEST(RegisterValueTest, SetValueFromData_257_be) {
@@ -316,5 +353,6 @@ TEST(RegisterValueTest, SetValueFromData_257_be) {
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);
+ TestSetValueFromData(etalon257, src, 33, lldb::ByteOrder::eByteOrderBig,
+ RegisterValue::eTypeUIntN);
}
>From f563fcd8c5bb05133bdbe6ec2860355f0ab45e0e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Matej=20Ko=C5=A1=C3=ADk?= <matej.kosik at codasip.com>
Date: Fri, 7 Nov 2025 15:41:06 +0100
Subject: [PATCH 22/28] [lldb] simplify the code
---
lldb/source/Utility/DataExtractor.cpp | 4 ----
lldb/source/Utility/RegisterValue.cpp | 9 +--------
2 files changed, 1 insertion(+), 12 deletions(-)
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 519348f52d9c5..fa1af5762d717 100644
--- a/lldb/source/Utility/RegisterValue.cpp
+++ b/lldb/source/Utility/RegisterValue.cpp
@@ -209,14 +209,7 @@ Status RegisterValue::SetValueFromData(const RegisterInfo ®_info,
SetUIntN(llvm::APInt(128, int128.x));
} else {
std::vector<uint8_t> bytes(src_len, 0);
- for (size_t i = 0; i < src_len; i++)
- bytes[i] = src.GetU8(&src_offset);
-
- if (src.GetByteOrder() == eByteOrderBig)
- // Transform the big-endian input to little-endian
- // because that is what the "llvm::LoadIntFromMemory" function
- // we call below expects.
- std::reverse(bytes.begin(), bytes.end());
+ src.ExtractBytes(src_offset, src_len, eByteOrderLittle, bytes.data());
if (llvm::sys::IsBigEndianHost) {
// If LLDB runs on a big-endian architecture,
>From 8121a95ebc8fc669009a5fc0c729896bf6c780aa Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Matej=20Ko=C5=A1=C3=ADk?= <matej.kosik at codasip.com>
Date: Fri, 7 Nov 2025 17:08:39 +0100
Subject: [PATCH 23/28] [lldb] on a big-endian machine, call the
"llvm::LoadIntFromMemory" function with the correct "LoadBytes" parameter
---
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 fa1af5762d717..68c8e7724eb21 100644
--- a/lldb/source/Utility/RegisterValue.cpp
+++ b/lldb/source/Utility/RegisterValue.cpp
@@ -221,7 +221,7 @@ Status RegisterValue::SetValueFromData(const RegisterInfo ®_info,
}
llvm::APInt uint = llvm::APInt::getZero(src_len * 8);
- llvm::LoadIntFromMemory(uint, bytes.data(), src_len);
+ llvm::LoadIntFromMemory(uint, bytes.data(), bytes.size());
SetUIntN(uint);
}
break;
>From 66105864e24a545b7cd03654db9f7920e216fc12 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Matej=20Ko=C5=A1=C3=ADk?= <matej.kosik at codasip.com>
Date: Sun, 9 Nov 2025 09:16:38 +0100
Subject: [PATCH 24/28] [lldb] simplify the implementation
"RegisterValue::SetValueFromData" method
---
lldb/source/Utility/RegisterValue.cpp | 18 ++++++------------
1 file changed, 6 insertions(+), 12 deletions(-)
diff --git a/lldb/source/Utility/RegisterValue.cpp b/lldb/source/Utility/RegisterValue.cpp
index 68c8e7724eb21..0676d01551e70 100644
--- a/lldb/source/Utility/RegisterValue.cpp
+++ b/lldb/source/Utility/RegisterValue.cpp
@@ -208,19 +208,13 @@ Status RegisterValue::SetValueFromData(const RegisterInfo ®_info,
}
SetUIntN(llvm::APInt(128, int128.x));
} else {
+ size_t bit_count = src_len * 8;
std::vector<uint8_t> bytes(src_len, 0);
- src.ExtractBytes(src_offset, src_len, eByteOrderLittle, bytes.data());
-
- if (llvm::sys::IsBigEndianHost) {
- // If LLDB runs on a big-endian architecture,
- // make sure that the input data can be read in
- // 64-bit chunks because that is what
- // the "llvm::LoadIntFromMemory" function will do.
- size_t size64 = (reg_info.byte_size - 1) / 8 + 1;
- bytes.resize(size64 * sizeof(uint64_t), 0);
- }
-
- llvm::APInt uint = llvm::APInt::getZero(src_len * 8);
+ src.ExtractBytes(
+ src_offset, src_len,
+ llvm::sys::IsLittleEndianHost ? eByteOrderLittle : eByteOrderBig,
+ bytes.data());
+ llvm::APInt uint = llvm::APInt::getZero(bit_count);
llvm::LoadIntFromMemory(uint, bytes.data(), bytes.size());
SetUIntN(uint);
}
>From 63ab91988cfdc5c7d25735631647ae84831c1a13 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Matej=20Ko=C5=A1=C3=ADk?= <matej.kosik at codasip.com>
Date: Sun, 9 Nov 2025 22:27:17 +0100
Subject: [PATCH 25/28] [lldb] formatting
---
lldb/source/Utility/RegisterValue.cpp | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/lldb/source/Utility/RegisterValue.cpp b/lldb/source/Utility/RegisterValue.cpp
index 0676d01551e70..ccf17b02b2ab0 100644
--- a/lldb/source/Utility/RegisterValue.cpp
+++ b/lldb/source/Utility/RegisterValue.cpp
@@ -210,10 +210,10 @@ Status RegisterValue::SetValueFromData(const RegisterInfo ®_info,
} else {
size_t bit_count = src_len * 8;
std::vector<uint8_t> bytes(src_len, 0);
- src.ExtractBytes(
- src_offset, src_len,
- llvm::sys::IsLittleEndianHost ? eByteOrderLittle : eByteOrderBig,
- bytes.data());
+ src.ExtractBytes(src_offset, src_len,
+ llvm::sys::IsLittleEndianHost ? eByteOrderLittle
+ : eByteOrderBig,
+ bytes.data());
llvm::APInt uint = llvm::APInt::getZero(bit_count);
llvm::LoadIntFromMemory(uint, bytes.data(), bytes.size());
SetUIntN(uint);
>From 54b4d8273dce44b0598df27bba6f80a207102468 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Matej=20Ko=C5=A1=C3=ADk?= <matej.kosik at codasip.com>
Date: Sun, 9 Nov 2025 22:37:19 +0100
Subject: [PATCH 26/28] [lldb] simplify the code
---
lldb/source/Utility/RegisterValue.cpp | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/lldb/source/Utility/RegisterValue.cpp b/lldb/source/Utility/RegisterValue.cpp
index ccf17b02b2ab0..7c0069ee168d3 100644
--- a/lldb/source/Utility/RegisterValue.cpp
+++ b/lldb/source/Utility/RegisterValue.cpp
@@ -208,14 +208,13 @@ Status RegisterValue::SetValueFromData(const RegisterInfo ®_info,
}
SetUIntN(llvm::APInt(128, int128.x));
} else {
- size_t bit_count = src_len * 8;
- std::vector<uint8_t> bytes(src_len, 0);
+ std::vector<uint8_t> native_endian_src(src_len, 0);
src.ExtractBytes(src_offset, src_len,
llvm::sys::IsLittleEndianHost ? eByteOrderLittle
: eByteOrderBig,
- bytes.data());
- llvm::APInt uint = llvm::APInt::getZero(bit_count);
- llvm::LoadIntFromMemory(uint, bytes.data(), bytes.size());
+ 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;
>From 14db79bc55a39ef2cac8f53666a9c22c170589ab Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Matej=20Ko=C5=A1=C3=ADk?= <matej.kosik at codasip.com>
Date: Mon, 10 Nov 2025 07:22:07 +0100
Subject: [PATCH 27/28] [lldb] simplify the code
---
lldb/source/Utility/RegisterValue.cpp | 13 +------------
1 file changed, 1 insertion(+), 12 deletions(-)
diff --git a/lldb/source/Utility/RegisterValue.cpp b/lldb/source/Utility/RegisterValue.cpp
index 7c0069ee168d3..4a5473eed762a 100644
--- a/lldb/source/Utility/RegisterValue.cpp
+++ b/lldb/source/Utility/RegisterValue.cpp
@@ -196,18 +196,7 @@ 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;
- }
- SetUIntN(llvm::APInt(128, int128.x));
- } else {
+ else {
std::vector<uint8_t> native_endian_src(src_len, 0);
src.ExtractBytes(src_offset, src_len,
llvm::sys::IsLittleEndianHost ? eByteOrderLittle
>From 84b1d66398a1396ec9d19af4ea55a590d546e548 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Matej=20Ko=C5=A1=C3=ADk?= <matej.kosik at codasip.com>
Date: Mon, 10 Nov 2025 08:10:19 +0100
Subject: [PATCH 28/28] [lldb] simplify the code
---
lldb/source/Utility/RegisterValue.cpp | 2 --
1 file changed, 2 deletions(-)
diff --git a/lldb/source/Utility/RegisterValue.cpp b/lldb/source/Utility/RegisterValue.cpp
index 4a5473eed762a..c28c9e2d4d106 100644
--- a/lldb/source/Utility/RegisterValue.cpp
+++ b/lldb/source/Utility/RegisterValue.cpp
@@ -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:
More information about the lldb-commits
mailing list