8314163: os::print_hex_dump prints incorrectly for big endian platforms and unit sizes larger than 1
Reviewed-by: mbaesken, shade
This commit is contained in:
parent
6bf4a33593
commit
6a15860b12
@ -942,6 +942,7 @@ ATTRIBUTE_NO_ASAN static bool read_safely_from(intptr_t* p, intptr_t* result) {
|
||||
}
|
||||
|
||||
static void print_hex_location(outputStream* st, address p, int unitsize) {
|
||||
assert(is_aligned(p, unitsize), "Unaligned");
|
||||
address pa = align_down(p, sizeof(intptr_t));
|
||||
#ifndef _LP64
|
||||
// Special handling for printing qwords on 32-bit platforms
|
||||
@ -961,10 +962,14 @@ static void print_hex_location(outputStream* st, address p, int unitsize) {
|
||||
#endif // 32-bit, qwords
|
||||
intptr_t i = 0;
|
||||
if (read_safely_from((intptr_t*)pa, &i)) {
|
||||
// bytes: CA FE BA BE DE AD C0 DE
|
||||
// bytoff: 0 1 2 3 4 5 6 7
|
||||
// LE bits: 0 8 16 24 32 40 48 56
|
||||
// BE bits: 56 48 40 32 24 16 8 0
|
||||
const int offset = (int)(p - (address)pa);
|
||||
const int bitoffset =
|
||||
LITTLE_ENDIAN_ONLY(offset * BitsPerByte)
|
||||
BIG_ENDIAN_ONLY((int)(sizeof(intptr_t) - 1 - offset) * BitsPerByte);
|
||||
BIG_ENDIAN_ONLY((int)((sizeof(intptr_t) - unitsize - offset) * BitsPerByte));
|
||||
const int bitfieldsize = unitsize * BitsPerByte;
|
||||
intptr_t value = bitfield(i, bitoffset, bitfieldsize);
|
||||
switch (unitsize) {
|
||||
|
Loading…
Reference in New Issue
Block a user