351 lldb::Format item_format,
size_t item_byte_size,
size_t item_count,
352 size_t num_per_line, uint64_t base_addr,
353 uint32_t item_bit_size,
355 uint32_t item_bit_offset,
362 if (item_byte_size != 4 && item_byte_size != 8)
368 std::optional<MemoryTagMap> memory_tag_map;
382 for (uint32_t count = 0; DE.
ValidOffset(offset) && count < item_count;
386 if ((count % num_per_line) == 0) {
390 offset > line_start_offset) {
393 (num_per_line - (offset - line_start_offset)) * 3 + 2),
396 offset - line_start_offset, SIZE_MAX,
401 size_t line_len = offset - line_start_offset;
411 s->
Printf(
"0x%8.8" PRIx64
": ",
412 (uint64_t)(base_addr +
415 line_start_offset = offset;
422 switch (item_format) {
424 if (item_byte_size <= 8)
426 item_bit_size, item_bit_offset)
430 s->
Printf(
"error: unsupported byte size (%" PRIu64
431 ") for boolean format",
432 (uint64_t)item_byte_size);
438 if (item_byte_size <= 8) {
440 item_bit_size, item_bit_offset);
443 std::string binary_value(64,
'0');
444 std::bitset<64>
bits(uval64);
445 for (uint32_t i = 0; i < 64; ++i)
447 binary_value[64 - 1 - i] =
'1';
448 if (item_bit_size > 0)
449 s->
Printf(
"0b%s", binary_value.c_str() + 64 - item_bit_size);
450 else if (item_byte_size > 0 && item_byte_size <= 8)
451 s->
Printf(
"0b%s", binary_value.c_str() + 64 - item_byte_size * 8);
453 const bool is_signed =
false;
454 const unsigned radix = 2;
455 offset =
DumpAPInt(s, DE, offset, item_byte_size, is_signed, radix);
461 for (uint32_t i = 0; i < item_byte_size; ++i) {
467 if (item_byte_size > 1)
475 if (item_byte_size > 8) {
476 s->
Printf(
"error: unsupported byte size (%" PRIu64
") for char format",
477 (uint64_t)item_byte_size);
486 item_bit_size, item_bit_offset);
487 if (llvm::isPrint(ch))
488 s->
Printf(
"%c", (
char)ch);
491 if (item_byte_size == 1)
492 s->
Printf(
"\\x%2.2x", (uint8_t)ch);
494 s->
Printf(
"%" PRIu64, ch);
508 if (item_byte_size <= 8)
513 const bool is_signed =
true;
514 const unsigned radix = 10;
515 offset =
DumpAPInt(s, DE, offset, item_byte_size, is_signed, radix);
520 if (item_byte_size <= 8)
525 const bool is_signed =
false;
526 const unsigned radix = 10;
527 offset =
DumpAPInt(s, DE, offset, item_byte_size, is_signed, radix);
532 if (item_byte_size <= 8)
537 const bool is_signed =
false;
538 const unsigned radix = 8;
539 offset =
DumpAPInt(s, DE, offset, item_byte_size, is_signed, radix);
545 item_bit_size, item_bit_offset);
547 for (uint32_t i = 0; i < item_byte_size; ++i) {
548 uint8_t ch = (uint8_t)(uval64 >> ((item_byte_size - i - 1) * 8));
555 const char *cstr = DE.
GetCStr(&offset);
563 while (
const char c = *cstr) {
580 size_t complex_int_byte_size = item_byte_size / 2;
582 if (complex_int_byte_size > 0 && complex_int_byte_size <= 8) {
585 s->
Printf(
" + %" PRIu64
"i",
588 s->
Printf(
"error: unsupported byte size (%" PRIu64
589 ") for complex integer format",
590 (uint64_t)item_byte_size);
596 if (
sizeof(
float) * 2 == item_byte_size) {
600 s->
Printf(
"%g + %gi", f32_1, f32_2);
602 }
else if (
sizeof(
double) * 2 == item_byte_size) {
606 s->
Printf(
"%lg + %lgi", d64_1, d64_2);
608 }
else if (
sizeof(
long double) * 2 == item_byte_size) {
611 s->
Printf(
"%Lg + %Lgi", ld64_1, ld64_2);
614 s->
Printf(
"error: unsupported byte size (%" PRIu64
615 ") for complex float format",
616 (uint64_t)item_byte_size);
626 switch (item_byte_size) {
632 .ShowHexVariableValuesWithLeadingZeroes()) {
633 s->
Printf(wantsuppercase ?
"0x%*.*" PRIX64 :
"0x%*.*" PRIx64,
634 (
int)(2 * item_byte_size), (
int)(2 * item_byte_size),
638 s->
Printf(wantsuppercase ?
"0x%" PRIX64 :
"0x%" PRIx64,
644 assert(item_bit_size == 0 && item_bit_offset == 0);
645 const uint8_t *bytes =
646 (
const uint8_t *)DE.
GetData(&offset, item_byte_size);
651 for (idx = 0; idx < item_byte_size; ++idx)
652 s->
Printf(wantsuppercase ?
"%2.2X" :
"%2.2x", bytes[idx]);
654 for (idx = 0; idx < item_byte_size; ++idx)
655 s->
Printf(wantsuppercase ?
"%2.2X" :
"%2.2x",
656 bytes[item_byte_size - 1 - idx]);
669 std::optional<unsigned> format_max_padding;
671 format_max_padding = target_sp->GetMaxZeroPaddingInFloatFormat();
674 const unsigned format_precision = 0;
676 const llvm::fltSemantics &semantics =
682 const size_t semantics_byte_size =
683 (llvm::APFloat::getSizeInBits(semantics) + 7) / 8;
684 std::optional<llvm::APInt> apint =
685 GetAPInt(DE, &offset, semantics_byte_size);
687 llvm::APFloat apfloat(semantics, *apint);
688 llvm::SmallVector<char, 256> sv;
689 if (format_max_padding)
690 apfloat.toString(sv, format_precision, *format_max_padding);
692 apfloat.toString(sv, format_precision);
695 s->
Format(
"error: unsupported byte size ({0}) for float format",
712 s->
Printf(
"0x%*.*" PRIx64, (
int)(2 * item_byte_size),
713 (
int)(2 * item_byte_size), addr);
718 if (target_sp->ResolveLoadAddress(addr, so_addr)) {
724 so_addr.
Dump(s, exe_scope,
727 if (
ABISP abi_sp = process_sp->GetABI()) {
728 addr_t addr_fixed = abi_sp->FixCodeAddress(addr);
729 if (target_sp->ResolveLoadAddress(addr_fixed, so_addr)) {
731 s->
Printf(
"(0x%*.*" PRIx64
")", (
int)(2 * item_byte_size),
732 (
int)(2 * item_byte_size), addr_fixed);
734 so_addr.
Dump(s, exe_scope,
746 if (
sizeof(
float) == item_byte_size) {
747 char float_cstr[256];
748 llvm::APFloat ap_float(DE.
GetFloat(&offset));
749 ap_float.convertToHexString(float_cstr, 0,
false,
750 llvm::APFloat::rmNearestTiesToEven);
751 s->
Printf(
"%s", float_cstr);
753 }
else if (
sizeof(
double) == item_byte_size) {
754 char float_cstr[256];
755 llvm::APFloat ap_float(DE.
GetDouble(&offset));
756 ap_float.convertToHexString(float_cstr, 0,
false,
757 llvm::APFloat::rmNearestTiesToEven);
758 s->
Printf(
"%s", float_cstr);
761 s->
Printf(
"error: unsupported byte size (%" PRIu64
762 ") for hex float format",
763 (uint64_t)item_byte_size);
799 item_byte_size /
sizeof(uint16_t), item_byte_size /
sizeof(uint16_t),
807 item_byte_size /
sizeof(uint16_t),
808 item_byte_size /
sizeof(uint16_t),
817 item_byte_size /
sizeof(uint32_t), item_byte_size /
sizeof(uint32_t),
825 item_byte_size /
sizeof(uint32_t),
826 item_byte_size /
sizeof(uint32_t),
835 item_byte_size /
sizeof(uint64_t), item_byte_size /
sizeof(uint64_t),
843 item_byte_size /
sizeof(uint64_t),
844 item_byte_size /
sizeof(uint64_t),
886 if (offset > line_start_offset) {
890 (num_per_line - (offset - line_start_offset)) * 3 + 2),
893 offset - line_start_offset, SIZE_MAX,
898 size_t line_len = offset - line_start_offset;
899 lldb::addr_t line_base = base_addr + (offset - start_offset - line_len) /