Skip to content

Commit 7e9a740

Browse files
committed
[DebugInfo] Dump values in .debug_pubnames and .debug_pubtypes according to the DWARF format (6/8).
The patch changes dumping of unit_length, debug_info_offset, and debug_info_length fields in headers in .debug_pubname and .debug_pubtypes sections so that they are printed as 16-digit hex values if the contribution is in the DWARF64 format. Dumping of offsets in the tables is changed in the same way. Differential Revision: https://reviews.llvm.org/D79997
1 parent 2094c5d commit 7e9a740

File tree

3 files changed

+22
-16
lines changed

3 files changed

+22
-16
lines changed

llvm/include/llvm/DebugInfo/DWARF/DWARFDebugPubTable.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ class DWARFDebugPubTable {
4444
/// field itself.
4545
uint64_t Length;
4646

47+
/// The DWARF format of the set.
48+
dwarf::DwarfFormat Format;
49+
4750
/// This number is specific to the name lookup table and is independent of
4851
/// the DWARF version number.
4952
uint16_t Version;

llvm/lib/DebugInfo/DWARF/DWARFDebugPubTable.cpp

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ DWARFDebugPubTable::DWARFDebugPubTable(const DWARFObject &Obj,
2828
Sets.push_back({});
2929
Set &SetData = Sets.back();
3030

31-
dwarf::DwarfFormat Format;
32-
std::tie(SetData.Length, Format) = PubNames.getInitialLength(&Offset);
33-
const unsigned OffsetSize = dwarf::getDwarfOffsetByteSize(Format);
31+
std::tie(SetData.Length, SetData.Format) =
32+
PubNames.getInitialLength(&Offset);
33+
const unsigned OffsetSize = dwarf::getDwarfOffsetByteSize(SetData.Format);
3434

3535
SetData.Version = PubNames.getU16(&Offset);
3636
SetData.Offset = PubNames.getRelocatedValue(OffsetSize, &Offset);
@@ -50,15 +50,18 @@ DWARFDebugPubTable::DWARFDebugPubTable(const DWARFObject &Obj,
5050

5151
void DWARFDebugPubTable::dump(raw_ostream &OS) const {
5252
for (const Set &S : Sets) {
53-
OS << "length = " << format("0x%08" PRIx64, S.Length);
53+
int OffsetDumpWidth = 2 * dwarf::getDwarfOffsetByteSize(S.Format);
54+
OS << "length = " << format("0x%0*" PRIx64, OffsetDumpWidth, S.Length);
5455
OS << " version = " << format("0x%04x", S.Version);
55-
OS << " unit_offset = " << format("0x%08" PRIx64, S.Offset);
56-
OS << " unit_size = " << format("0x%08" PRIx64, S.Size) << '\n';
56+
OS << " unit_offset = "
57+
<< format("0x%0*" PRIx64, OffsetDumpWidth, S.Offset);
58+
OS << " unit_size = " << format("0x%0*" PRIx64, OffsetDumpWidth, S.Size)
59+
<< '\n';
5760
OS << (GnuStyle ? "Offset Linkage Kind Name\n"
5861
: "Offset Name\n");
5962

6063
for (const Entry &E : S.Entries) {
61-
OS << format("0x%8.8" PRIx64 " ", E.SecOffset);
64+
OS << format("0x%0*" PRIx64 " ", OffsetDumpWidth, E.SecOffset);
6265
if (GnuStyle) {
6366
StringRef EntryLinkage =
6467
GDBIndexEntryLinkageString(E.Descriptor.Linkage);

llvm/test/DebugInfo/X86/dwarfdump-debug-pubnames.s

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,24 @@
33
# RUN: FileCheck %s
44

55
# CHECK: .debug_pubnames contents:
6-
# CHECK-NEXT: length = 0x00000032
6+
# CHECK-NEXT: length = 0x0000000000000032
77
# CHECK-SAME: version = 0x0002
8-
# CHECK-SAME: unit_offset = 0x1122334455667788
9-
# CHECK-SAME: unit_size = 0x1100220033004400
8+
# CHECK-SAME: unit_offset = 0x0000112233445566
9+
# CHECK-SAME: unit_size = 0x0000110022003300
1010
# CHECK-NEXT: Offset Name
11-
# CHECK-NEXT: 0xaa01aaaabbbbbbbb "foo"
12-
# CHECK-NEXT: 0xaa02aaaabbbbbbbb "bar"
11+
# CHECK-NEXT: 0x0000aa01aaaabbbb "foo"
12+
# CHECK-NEXT: 0x0000aa02aaaabbbb "bar"
1313

1414
.section .debug_pubnames,"",@progbits
1515
.long 0xffffffff # DWARF64 mark
1616
.quad .Lend - .Lversion # Unit Length
1717
.Lversion:
1818
.short 2 # Version
19-
.quad 0x1122334455667788 # Debug Info Offset
20-
.quad 0x1100220033004400 # Debug Info Length
21-
.quad 0xaa01aaaabbbbbbbb # Tuple0: Offset
19+
.quad 0x112233445566 # Debug Info Offset
20+
.quad 0x110022003300 # Debug Info Length
21+
.quad 0xaa01aaaabbbb # Tuple0: Offset
2222
.asciz "foo" # Name
23-
.quad 0xaa02aaaabbbbbbbb # Tuple1: Offset
23+
.quad 0xaa02aaaabbbb # Tuple1: Offset
2424
.asciz "bar" # Name
2525
.quad 0 # Terminator
2626
.Lend:

0 commit comments

Comments
 (0)