Skip to content

Commit e94382e

Browse files
committed
[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
1 parent 7e9a740 commit e94382e

File tree

5 files changed

+13
-12
lines changed

5 files changed

+13
-12
lines changed

llvm/lib/DebugInfo/DWARF/DWARFContext.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ static void dumpStringOffsetsSection(raw_ostream &OS, DIDumpOptions DumpOpts,
162162
}
163163

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

llvm/test/DebugInfo/X86/dwarfdump-str-offsets-macho.s

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -261,9 +261,9 @@ TU_5_end:
261261
# COMMON-NEXT: 0x00000020: 0000007c "MyVar3"
262262
# COMMON-NEXT: 0x00000024: Gap, length = 4
263263
# COMMON-NEXT: 0x00000028: Contribution size = 28, Format = DWARF64, Version = 5
264-
# COMMON-NEXT: 0x00000038: 00000000 "Handmade DWARF producer"
265-
# COMMON-NEXT: 0x00000040: 00000036 "Compile_Unit_2"
266-
# COMMON-NEXT: 0x00000048: 00000045 "/home/test/CU2"
264+
# COMMON-NEXT: 0x00000038: 0000000000000000 "Handmade DWARF producer"
265+
# COMMON-NEXT: 0x00000040: 0000000000000036 "Compile_Unit_2"
266+
# COMMON-NEXT: 0x00000048: 0000000000000045 "/home/test/CU2"
267267
# COMMON-NEXT: 0x00000050: Contribution size = 12, Format = DWARF32, Version = 5
268268
# COMMON-NEXT: 0x00000058: 00000054 "Type_Unit"
269269
# COMMON-NEXT: 0x0000005c: 0000005e "MyStruct"

llvm/test/DebugInfo/X86/dwarfdump-str-offsets-v4-dwarf64-dwo.s

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@
2525

2626
# CHECK: .debug_str_offsets.dwo contents:
2727
# CHECK-NEXT: 0x00000000: Contribution size = 24, Format = DWARF64, Version = 4
28-
# CHECK-NEXT: 0x00000000: 00000000 "Compilation Unit"
29-
# CHECK-NEXT: 0x00000008: 00000011 "Type Unit"
30-
# CHECK-NEXT: 0x00000010: 0000001b "Structure"
28+
# CHECK-NEXT: 0x00000000: 0000000000000000 "Compilation Unit"
29+
# CHECK-NEXT: 0x00000008: 0000000000000011 "Type Unit"
30+
# CHECK-NEXT: 0x00000010: 000000000000001b "Structure"
3131

3232
.section .debug_str.dwo, "MSe", @progbits, 1
3333
.LStr0:

llvm/test/DebugInfo/X86/dwarfdump-str-offsets-v4-dwarf64-dwp.s

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@
3030
# CHECK-NEXT: 0x00000000: 00000000 "CU0 Producer"
3131
# CHECK-NEXT: 0x00000004: 0000000d "CU0 Name"
3232
# CHECK-NEXT: 0x00000008: Contribution size = 16, Format = DWARF64, Version = 4
33-
# CHECK-NEXT: 0x00000008: 00000016 "CU1 Producer"
34-
# CHECK-NEXT: 0x00000010: 00000023 "CU1 Name"
33+
# CHECK-NEXT: 0x00000008: 0000000000000016 "CU1 Producer"
34+
# CHECK-NEXT: 0x00000010: 0000000000000023 "CU1 Name"
3535

3636
.section .debug_str.dwo, "MSe", @progbits, 1
3737
.LStr0:

llvm/test/DebugInfo/X86/dwarfdump-str-offsets.s

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -414,9 +414,9 @@ TU_split_5_end:
414414
# COMMON-NEXT: 0x00000020: 0000007c "MyVar3"
415415
# COMMON-NEXT: Gap, length = 4
416416
# COMMON-NEXT: 0x00000028: Contribution size = 28, Format = DWARF64, Version = 5
417-
# COMMON-NEXT: 0x00000038: 00000000 "Handmade DWARF producer"
418-
# COMMON-NEXT: 0x00000040: 00000036 "Compile_Unit_2"
419-
# COMMON-NEXT: 0x00000048: 00000045 "/home/test/CU2"
417+
# COMMON-NEXT: 0x00000038: 0000000000000000 "Handmade DWARF producer"
418+
# COMMON-NEXT: 0x00000040: 0000000000000036 "Compile_Unit_2"
419+
# COMMON-NEXT: 0x00000048: 0000000000000045 "/home/test/CU2"
420420
# COMMON-NEXT: 0x00000050: Contribution size = 12, Format = DWARF32, Version = 5
421421
# COMMON-NEXT: 0x00000058: 00000054 "Type_Unit"
422422
# COMMON-NEXT: 0x0000005c: 0000005e "MyStruct"

0 commit comments

Comments
 (0)