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;
404 base_addr + (offset - start_offset - line_len);
411 s->
Printf(
"0x%8.8" PRIx64
": ",
412 (uint64_t)(base_addr + (offset - start_offset)));
414 line_start_offset = offset;
421 switch (item_format) {
423 if (item_byte_size <= 8)
425 item_bit_size, item_bit_offset)
429 s->
Printf(
"error: unsupported byte size (%" PRIu64
430 ") for boolean format",
431 (uint64_t)item_byte_size);
437 if (item_byte_size <= 8) {
439 item_bit_size, item_bit_offset);
442 std::string binary_value(64,
'0');
443 std::bitset<64>
bits(uval64);
444 for (uint32_t i = 0; i < 64; ++i)
446 binary_value[64 - 1 - i] =
'1';
447 if (item_bit_size > 0)
448 s->
Printf(
"0b%s", binary_value.c_str() + 64 - item_bit_size);
449 else if (item_byte_size > 0 && item_byte_size <= 8)
450 s->
Printf(
"0b%s", binary_value.c_str() + 64 - item_byte_size * 8);
452 const bool is_signed =
false;
453 const unsigned radix = 2;
454 offset =
DumpAPInt(s, DE, offset, item_byte_size, is_signed, radix);
460 for (uint32_t i = 0; i < item_byte_size; ++i) {
466 if (item_byte_size > 1)
474 if (item_byte_size > 8) {
475 s->
Printf(
"error: unsupported byte size (%" PRIu64
") for char format",
476 (uint64_t)item_byte_size);
485 item_bit_size, item_bit_offset);
486 if (llvm::isPrint(ch))
490 if (item_byte_size == 1)
491 s->
Printf(
"\\x%2.2x", (uint8_t)ch);
493 s->
Printf(
"%" PRIu64, ch);
507 if (item_byte_size <= 8)
512 const bool is_signed =
true;
513 const unsigned radix = 10;
514 offset =
DumpAPInt(s, DE, offset, item_byte_size, is_signed, radix);
519 if (item_byte_size <= 8)
524 const bool is_signed =
false;
525 const unsigned radix = 10;
526 offset =
DumpAPInt(s, DE, offset, item_byte_size, is_signed, radix);
531 if (item_byte_size <= 8)
536 const bool is_signed =
false;
537 const unsigned radix = 8;
538 offset =
DumpAPInt(s, DE, offset, item_byte_size, is_signed, radix);
544 item_bit_size, item_bit_offset);
546 for (uint32_t i = 0; i < item_byte_size; ++i) {
547 uint8_t ch = (uint8_t)(uval64 >> ((item_byte_size - i - 1) * 8));
554 const char *cstr = DE.
GetCStr(&offset);
562 while (
const char c = *cstr) {
579 size_t complex_int_byte_size = item_byte_size / 2;
581 if (complex_int_byte_size > 0 && complex_int_byte_size <= 8) {
584 s->
Printf(
" + %" PRIu64
"i",
587 s->
Printf(
"error: unsupported byte size (%" PRIu64
588 ") for complex integer format",
589 (uint64_t)item_byte_size);
595 if (
sizeof(
float) * 2 == item_byte_size) {
599 s->
Printf(
"%g + %gi", f32_1, f32_2);
601 }
else if (
sizeof(
double) * 2 == item_byte_size) {
605 s->
Printf(
"%lg + %lgi", d64_1, d64_2);
607 }
else if (
sizeof(
long double) * 2 == item_byte_size) {
610 s->
Printf(
"%Lg + %Lgi", ld64_1, ld64_2);
613 s->
Printf(
"error: unsupported byte size (%" PRIu64
614 ") for complex float format",
615 (uint64_t)item_byte_size);
625 switch (item_byte_size) {
631 .ShowHexVariableValuesWithLeadingZeroes()) {
632 s->
Printf(wantsuppercase ?
"0x%*.*" PRIX64 :
"0x%*.*" PRIx64,
633 (
int)(2 * item_byte_size), (
int)(2 * item_byte_size),
637 s->
Printf(wantsuppercase ?
"0x%" PRIX64 :
"0x%" PRIx64,
643 assert(item_bit_size == 0 && item_bit_offset == 0);
644 const uint8_t *bytes =
645 (
const uint8_t *)DE.
GetData(&offset, item_byte_size);
650 for (idx = 0; idx < item_byte_size; ++idx)
651 s->
Printf(wantsuppercase ?
"%2.2X" :
"%2.2x", bytes[idx]);
653 for (idx = 0; idx < item_byte_size; ++idx)
654 s->
Printf(wantsuppercase ?
"%2.2X" :
"%2.2x",
655 bytes[item_byte_size - 1 - idx]);
668 std::optional<unsigned> format_max_padding;
670 format_max_padding = target_sp->GetMaxZeroPaddingInFloatFormat();
673 const unsigned format_precision = 0;
675 const llvm::fltSemantics &semantics =
681 const size_t semantics_byte_size =
682 (llvm::APFloat::getSizeInBits(semantics) + 7) / 8;
683 std::optional<llvm::APInt> apint =
684 GetAPInt(DE, &offset, semantics_byte_size);
686 llvm::APFloat apfloat(semantics, *apint);
687 llvm::SmallVector<char, 256> sv;
688 if (format_max_padding)
689 apfloat.toString(sv, format_precision, *format_max_padding);
691 apfloat.toString(sv, format_precision);
694 s->
Format(
"error: unsupported byte size ({0}) for float format",
707 const uint32_t cp = DE.
GetU32(&offset);
710 s->
Format(
"U+{0:X-4}", cp);
712 s->
Format(
"0x{0:x-8}", cp);
718 s->
Printf(
"0x%*.*" PRIx64, (
int)(2 * item_byte_size),
719 (
int)(2 * item_byte_size), addr);
724 if (target_sp->ResolveLoadAddress(addr, so_addr)) {
730 so_addr.
Dump(s, exe_scope,
733 if (
ABISP abi_sp = process_sp->GetABI()) {
734 addr_t addr_fixed = abi_sp->FixCodeAddress(addr);
735 if (target_sp->ResolveLoadAddress(addr_fixed, so_addr)) {
737 s->
Printf(
"(0x%*.*" PRIx64
")", (
int)(2 * item_byte_size),
738 (
int)(2 * item_byte_size), addr_fixed);
740 so_addr.
Dump(s, exe_scope,
752 if (
sizeof(
float) == item_byte_size) {
753 char float_cstr[256];
754 llvm::APFloat ap_float(DE.
GetFloat(&offset));
755 ap_float.convertToHexString(float_cstr, 0,
false,
756 llvm::APFloat::rmNearestTiesToEven);
759 }
else if (
sizeof(
double) == item_byte_size) {
760 char float_cstr[256];
761 llvm::APFloat ap_float(DE.
GetDouble(&offset));
762 ap_float.convertToHexString(float_cstr, 0,
false,
763 llvm::APFloat::rmNearestTiesToEven);
767 s->
Printf(
"error: unsupported byte size (%" PRIu64
768 ") for hex float format",
769 (uint64_t)item_byte_size);
805 item_byte_size /
sizeof(uint16_t), item_byte_size /
sizeof(uint16_t),
813 item_byte_size /
sizeof(uint16_t),
814 item_byte_size /
sizeof(uint16_t),
823 item_byte_size /
sizeof(uint32_t), item_byte_size /
sizeof(uint32_t),
831 item_byte_size /
sizeof(uint32_t),
832 item_byte_size /
sizeof(uint32_t),
841 item_byte_size /
sizeof(uint64_t), item_byte_size /
sizeof(uint64_t),
849 item_byte_size /
sizeof(uint64_t),
850 item_byte_size /
sizeof(uint64_t),
892 if (offset > line_start_offset) {
896 (num_per_line - (offset - line_start_offset)) * 3 + 2),
899 offset - line_start_offset, SIZE_MAX,
904 size_t line_len = offset - line_start_offset;
905 lldb::addr_t line_base = base_addr + (offset - start_offset - line_len);