Debugger: introduce ReadUInt

Change-Id: Iaa32db71b3a015d5496d60a96fb30763b924c89f
Reviewed-on: https://review.haiku-os.org/c/haiku/+/7103
Reviewed-by: Rene Gollent <rene@gollent.com>
This commit is contained in:
David Karoly 2023-11-22 20:11:30 +01:00 committed by Rene Gollent
parent e7371da8b5
commit 85a7824e2a

View File

@ -165,21 +165,32 @@ public:
return fOverflow ? defaultValue : result;
}
uint32 ReadU24(uint32 defaultValue)
uint64 ReadUInt(size_t numBytes, uint64 defaultValue)
{
uint8 res1 = Read<uint8>(0);
uint8 res2 = Read<uint8>(0);
uint8 res3 = Read<uint8>(0);
uint32 result;
if (fIsBigEndian)
result = res3 | (res2 << 8) | (res1 << 16);
else
result = res1 | (res2 << 8) | (res3 << 16);
uint64 result = 0;
if (fIsBigEndian) {
for (size_t i = 0; i < numBytes; i++) {
uint8 byte = Read<uint8>(0);
result <<= 8;
result |= (uint64)byte;
}
} else {
int shift = 0;
for (size_t i = 0; i < numBytes; i++) {
uint8 byte = Read<uint8>(0);
result |= (uint64)byte << shift;
shift += 8;
}
}
return fOverflow ? defaultValue : result;
}
uint32 ReadU24(uint32 defaultValue)
{
return ReadUInt(3, defaultValue);
}
const char* ReadString()
{
const char* string = (const char*)fData;