[DebugInfo] Dump offsets in .debug_str_offsets according to the DWARF format (7/8).

The patch changes dumping of offsets in .debug_str_offsets sections so
that they are printed as 16-digit hex values if the contribution is in
the DWARF64 format.

Differential Revision: https://reviews.llvm.org/D79997
This commit is contained in:
Igor Kudrin 2020-05-19 13:35:58 +07:00
parent 7e9a740198
commit e94382ee37
5 changed files with 13 additions and 12 deletions

View File

@ -162,6 +162,7 @@ static void dumpStringOffsetsSection(raw_ostream &OS, DIDumpOptions DumpOpts,
}
dwarf::DwarfFormat Format = Contribution->getFormat();
int OffsetDumpWidth = 2 * dwarf::getDwarfOffsetByteSize(Format);
uint16_t Version = Contribution->getVersion();
uint64_t ContributionHeader = Contribution->Base;
// In DWARF v5 there is a contribution header that immediately precedes
@ -198,7 +199,7 @@ static void dumpStringOffsetsSection(raw_ostream &OS, DIDumpOptions DumpOpts,
OS << format("0x%8.8" PRIx64 ": ", Offset);
uint64_t StringOffset =
StrOffsetExt.getRelocatedValue(EntrySize, &Offset);
OS << format("%8.8" PRIx64 " ", StringOffset);
OS << format("%0*" PRIx64 " ", OffsetDumpWidth, StringOffset);
const char *S = StrData.getCStr(&StringOffset);
if (S)
OS << format("\"%s\"", S);

View File

@ -261,9 +261,9 @@ TU_5_end:
# COMMON-NEXT: 0x00000020: 0000007c "MyVar3"
# COMMON-NEXT: 0x00000024: Gap, length = 4
# COMMON-NEXT: 0x00000028: Contribution size = 28, Format = DWARF64, Version = 5
# COMMON-NEXT: 0x00000038: 00000000 "Handmade DWARF producer"
# COMMON-NEXT: 0x00000040: 00000036 "Compile_Unit_2"
# COMMON-NEXT: 0x00000048: 00000045 "/home/test/CU2"
# COMMON-NEXT: 0x00000038: 0000000000000000 "Handmade DWARF producer"
# COMMON-NEXT: 0x00000040: 0000000000000036 "Compile_Unit_2"
# COMMON-NEXT: 0x00000048: 0000000000000045 "/home/test/CU2"
# COMMON-NEXT: 0x00000050: Contribution size = 12, Format = DWARF32, Version = 5
# COMMON-NEXT: 0x00000058: 00000054 "Type_Unit"
# COMMON-NEXT: 0x0000005c: 0000005e "MyStruct"

View File

@ -25,9 +25,9 @@
# CHECK: .debug_str_offsets.dwo contents:
# CHECK-NEXT: 0x00000000: Contribution size = 24, Format = DWARF64, Version = 4
# CHECK-NEXT: 0x00000000: 00000000 "Compilation Unit"
# CHECK-NEXT: 0x00000008: 00000011 "Type Unit"
# CHECK-NEXT: 0x00000010: 0000001b "Structure"
# CHECK-NEXT: 0x00000000: 0000000000000000 "Compilation Unit"
# CHECK-NEXT: 0x00000008: 0000000000000011 "Type Unit"
# CHECK-NEXT: 0x00000010: 000000000000001b "Structure"
.section .debug_str.dwo, "MSe", @progbits, 1
.LStr0:

View File

@ -30,8 +30,8 @@
# CHECK-NEXT: 0x00000000: 00000000 "CU0 Producer"
# CHECK-NEXT: 0x00000004: 0000000d "CU0 Name"
# CHECK-NEXT: 0x00000008: Contribution size = 16, Format = DWARF64, Version = 4
# CHECK-NEXT: 0x00000008: 00000016 "CU1 Producer"
# CHECK-NEXT: 0x00000010: 00000023 "CU1 Name"
# CHECK-NEXT: 0x00000008: 0000000000000016 "CU1 Producer"
# CHECK-NEXT: 0x00000010: 0000000000000023 "CU1 Name"
.section .debug_str.dwo, "MSe", @progbits, 1
.LStr0:

View File

@ -414,9 +414,9 @@ TU_split_5_end:
# COMMON-NEXT: 0x00000020: 0000007c "MyVar3"
# COMMON-NEXT: Gap, length = 4
# COMMON-NEXT: 0x00000028: Contribution size = 28, Format = DWARF64, Version = 5
# COMMON-NEXT: 0x00000038: 00000000 "Handmade DWARF producer"
# COMMON-NEXT: 0x00000040: 00000036 "Compile_Unit_2"
# COMMON-NEXT: 0x00000048: 00000045 "/home/test/CU2"
# COMMON-NEXT: 0x00000038: 0000000000000000 "Handmade DWARF producer"
# COMMON-NEXT: 0x00000040: 0000000000000036 "Compile_Unit_2"
# COMMON-NEXT: 0x00000048: 0000000000000045 "/home/test/CU2"
# COMMON-NEXT: 0x00000050: Contribution size = 12, Format = DWARF32, Version = 5
# COMMON-NEXT: 0x00000058: 00000054 "Type_Unit"
# COMMON-NEXT: 0x0000005c: 0000005e "MyStruct"