352 lldb::Format item_format,
size_t item_byte_size,
size_t item_count,
353 size_t num_per_line, uint64_t base_addr,
354 uint32_t item_bit_size,
356 uint32_t item_bit_offset,
363 if (item_byte_size != 4 && item_byte_size != 8)
369 std::optional<MemoryTagMap> memory_tag_map;
383 for (uint32_t count = 0; DE.
ValidOffset(offset) && count < item_count;
387 if ((count % num_per_line) == 0) {
391 offset > line_start_offset) {
394 (num_per_line - (offset - line_start_offset)) * 3 + 2),
397 offset - line_start_offset, SIZE_MAX,
402 size_t line_len = offset - line_start_offset;
412 s->
Printf(
"0x%8.8" PRIx64
": ",
413 (uint64_t)(base_addr +
416 line_start_offset = offset;
423 switch (item_format) {
425 if (item_byte_size <= 8)
427 item_bit_size, item_bit_offset)
431 s->
Printf(
"error: unsupported byte size (%" PRIu64
432 ") for boolean format",
433 (uint64_t)item_byte_size);
439 if (item_byte_size <= 8) {
441 item_bit_size, item_bit_offset);
444 std::string binary_value(64,
'0');
445 std::bitset<64>
bits(uval64);
446 for (uint32_t i = 0; i < 64; ++i)
448 binary_value[64 - 1 - i] =
'1';
449 if (item_bit_size > 0)
450 s->
Printf(
"0b%s", binary_value.c_str() + 64 - item_bit_size);
451 else if (item_byte_size > 0 && item_byte_size <= 8)
452 s->
Printf(
"0b%s", binary_value.c_str() + 64 - item_byte_size * 8);
454 const bool is_signed =
false;
455 const unsigned radix = 2;
456 offset =
DumpAPInt(s, DE, offset, item_byte_size, is_signed, radix);
462 for (uint32_t i = 0; i < item_byte_size; ++i) {
468 if (item_byte_size > 1)
476 if (item_byte_size > 8) {
477 s->
Printf(
"error: unsupported byte size (%" PRIu64
") for char format",
478 (uint64_t)item_byte_size);
487 item_bit_size, item_bit_offset);
488 if (llvm::isPrint(ch))
489 s->
Printf(
"%c", (
char)ch);
492 if (item_byte_size == 1)
493 s->
Printf(
"\\x%2.2x", (uint8_t)ch);
495 s->
Printf(
"%" PRIu64, ch);
509 if (item_byte_size <= 8)
514 const bool is_signed =
true;
515 const unsigned radix = 10;
516 offset =
DumpAPInt(s, DE, offset, item_byte_size, is_signed, radix);
521 if (item_byte_size <= 8)
526 const bool is_signed =
false;
527 const unsigned radix = 10;
528 offset =
DumpAPInt(s, DE, offset, item_byte_size, is_signed, radix);
533 if (item_byte_size <= 8)
538 const bool is_signed =
false;
539 const unsigned radix = 8;
540 offset =
DumpAPInt(s, DE, offset, item_byte_size, is_signed, radix);
546 item_bit_size, item_bit_offset);
548 for (uint32_t i = 0; i < item_byte_size; ++i) {
549 uint8_t ch = (uint8_t)(uval64 >> ((item_byte_size - i - 1) * 8));
556 const char *cstr = DE.
GetCStr(&offset);
564 while (
const char c = *cstr) {
581 size_t complex_int_byte_size = item_byte_size / 2;
583 if (complex_int_byte_size > 0 && complex_int_byte_size <= 8) {
586 s->
Printf(
" + %" PRIu64
"i",
589 s->
Printf(
"error: unsupported byte size (%" PRIu64
590 ") for complex integer format",
591 (uint64_t)item_byte_size);
597 if (
sizeof(
float) * 2 == item_byte_size) {
601 s->
Printf(
"%g + %gi", f32_1, f32_2);
603 }
else if (
sizeof(
double) * 2 == item_byte_size) {
607 s->
Printf(
"%lg + %lgi", d64_1, d64_2);
609 }
else if (
sizeof(
long double) * 2 == item_byte_size) {
612 s->
Printf(
"%Lg + %Lgi", ld64_1, ld64_2);
615 s->
Printf(
"error: unsupported byte size (%" PRIu64
616 ") for complex float format",
617 (uint64_t)item_byte_size);
627 switch (item_byte_size) {
633 .ShowHexVariableValuesWithLeadingZeroes()) {
634 s->
Printf(wantsuppercase ?
"0x%*.*" PRIX64 :
"0x%*.*" PRIx64,
635 (
int)(2 * item_byte_size), (
int)(2 * item_byte_size),
639 s->
Printf(wantsuppercase ?
"0x%" PRIX64 :
"0x%" PRIx64,
645 assert(item_bit_size == 0 && item_bit_offset == 0);
646 const uint8_t *bytes =
647 (
const uint8_t *)DE.
GetData(&offset, item_byte_size);
652 for (idx = 0; idx < item_byte_size; ++idx)
653 s->
Printf(wantsuppercase ?
"%2.2X" :
"%2.2x", bytes[idx]);
655 for (idx = 0; idx < item_byte_size; ++idx)
656 s->
Printf(wantsuppercase ?
"%2.2X" :
"%2.2x",
657 bytes[item_byte_size - 1 - idx]);
670 std::optional<unsigned> format_max_padding;
672 format_max_padding = target_sp->GetMaxZeroPaddingInFloatFormat();
675 const unsigned format_precision = 0;
677 const llvm::fltSemantics &semantics =
683 const size_t semantics_byte_size =
684 (llvm::APFloat::getSizeInBits(semantics) + 7) / 8;
685 std::optional<llvm::APInt> apint =
686 GetAPInt(DE, &offset, semantics_byte_size);
688 llvm::APFloat apfloat(semantics, *apint);
689 llvm::SmallVector<char, 256> sv;
690 if (format_max_padding)
691 apfloat.toString(sv, format_precision, *format_max_padding);
693 apfloat.toString(sv, format_precision);
696 s->
Format(
"error: unsupported byte size ({0}) for float format",
713 s->
Printf(
"0x%*.*" PRIx64, (
int)(2 * item_byte_size),
714 (
int)(2 * item_byte_size), addr);
719 if (target_sp->ResolveLoadAddress(addr, so_addr)) {
725 so_addr.
Dump(s, exe_scope,
728 if (
ABISP abi_sp = process_sp->GetABI()) {
729 addr_t addr_fixed = abi_sp->FixCodeAddress(addr);
730 if (target_sp->ResolveLoadAddress(addr_fixed, so_addr)) {
732 s->
Printf(
"(0x%*.*" PRIx64
")", (
int)(2 * item_byte_size),
733 (
int)(2 * item_byte_size), addr_fixed);
735 so_addr.
Dump(s, exe_scope,
747 if (
sizeof(
float) == item_byte_size) {
748 char float_cstr[256];
749 llvm::APFloat ap_float(DE.
GetFloat(&offset));
750 ap_float.convertToHexString(float_cstr, 0,
false,
751 llvm::APFloat::rmNearestTiesToEven);
752 s->
Printf(
"%s", float_cstr);
754 }
else if (
sizeof(
double) == item_byte_size) {
755 char float_cstr[256];
756 llvm::APFloat ap_float(DE.
GetDouble(&offset));
757 ap_float.convertToHexString(float_cstr, 0,
false,
758 llvm::APFloat::rmNearestTiesToEven);
759 s->
Printf(
"%s", float_cstr);
762 s->
Printf(
"error: unsupported byte size (%" PRIu64
763 ") for hex float format",
764 (uint64_t)item_byte_size);
800 item_byte_size /
sizeof(uint16_t), item_byte_size /
sizeof(uint16_t),
808 item_byte_size /
sizeof(uint16_t),
809 item_byte_size /
sizeof(uint16_t),
818 item_byte_size /
sizeof(uint32_t), item_byte_size /
sizeof(uint32_t),
826 item_byte_size /
sizeof(uint32_t),
827 item_byte_size /
sizeof(uint32_t),
836 item_byte_size /
sizeof(uint64_t), item_byte_size /
sizeof(uint64_t),
844 item_byte_size /
sizeof(uint64_t),
845 item_byte_size /
sizeof(uint64_t),
887 if (offset > line_start_offset) {
891 (num_per_line - (offset - line_start_offset)) * 3 + 2),
894 offset - line_start_offset, SIZE_MAX,
899 size_t line_len = offset - line_start_offset;
900 lldb::addr_t line_base = base_addr + (offset - start_offset - line_len) /