Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
2db982d
[lldb] reorganize existing tests (in order to facility sucessive addi…
Oct 31, 2025
eb234f9
[lldb] add new tests that demonstrate the problem
Oct 31, 2025
6b48d03
[lldb] fix the "RegisterValue::SetValueFromData" method
Oct 31, 2025
ca5d68a
[lldb] add new tests that demonstrate the problem
Oct 31, 2025
ef8859f
[lldb] fix the "RegisterValue::SetValueFromData" method
Oct 31, 2025
460b8fc
[lldb] rename an existing enum value so that it better expresses its …
Nov 3, 2025
82b5385
formatting
Nov 4, 2025
a0f52e4
[lldb] rename "eTypeUIntBig" enum value to "eTypeUInt"
Nov 4, 2025
eab73d2
[lldb] fix the comment
sedymrak Nov 5, 2025
9c94621
[lldb] fix a misleading name of the register
Nov 5, 2025
b796fae
[lldb] add new tests
Nov 5, 2025
d368469
[lldb] add a new test
Nov 5, 2025
804442f
[lldb] formatting
Nov 5, 2025
2a1bb4c
[lldb] add more comments
Nov 6, 2025
79a8afb
[lldb] formatting
Nov 6, 2025
b362aeb
[lldb] rename the enum value
Nov 6, 2025
84fb031
[lldb] update the comment
Nov 6, 2025
7682406
[lldb] fix the compilation
Nov 6, 2025
56c86e5
[lldb] change the name of the "RegisterValue::SetUInt128" method in o…
Nov 6, 2025
d36d6bf
[lldb] remove superluous tests from the "RegisterValueTest.cpp" file
Nov 6, 2025
359cd66
[lldb] explicitely check the type of the created RegisterValue object…
Nov 7, 2025
f563fcd
[lldb] simplify the code
Nov 7, 2025
8121a95
[lldb] on a big-endian machine, call the "llvm::LoadIntFromMemory" fu…
Nov 7, 2025
6610586
[lldb] simplify the implementation "RegisterValue::SetValueFromData" …
Nov 9, 2025
63ab919
[lldb] formatting
Nov 9, 2025
54b4d82
[lldb] simplify the code
Nov 9, 2025
14db79b
[lldb] simplify the code
Nov 10, 2025
84b1d66
[lldb] simplify the code
Nov 10, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions lldb/include/lldb/Utility/RegisterValue.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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));
}

Expand Down Expand Up @@ -178,7 +179,7 @@ class RegisterValue {
}

void operator=(llvm::APInt uint) {
m_type = eTypeUInt128;
m_type = eTypeUIntN;
m_scalar = llvm::APInt(std::move(uint));
}

Expand Down Expand Up @@ -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);
}

Expand Down
4 changes: 0 additions & 4 deletions lldb/source/Utility/DataExtractor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
48 changes: 22 additions & 26 deletions lldb/source/Utility/RegisterValue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -180,8 +180,6 @@ Status RegisterValue::SetValueFromData(const RegisterInfo &reg_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:
Expand All @@ -196,17 +194,15 @@ Status RegisterValue::SetValueFromData(const RegisterInfo &reg_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:
Expand Down Expand Up @@ -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:
Expand All @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand All @@ -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:
Expand All @@ -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:
Expand All @@ -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:
Expand All @@ -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:
Expand All @@ -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;
Expand Down Expand Up @@ -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:
Expand All @@ -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);
}
Expand Down Expand Up @@ -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);
}
Expand Down
Loading
Loading