[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
This commit is contained in:
Igor Kudrin 2020-05-19 13:35:48 +07:00
parent 2094c5d292
commit 7e9a740198
3 changed files with 22 additions and 16 deletions

View File

@ -44,6 +44,9 @@ public:
/// field itself.
uint64_t Length;
/// The DWARF format of the set.
dwarf::DwarfFormat Format;
/// This number is specific to the name lookup table and is independent of
/// the DWARF version number.
uint16_t Version;

View File

@ -28,9 +28,9 @@ DWARFDebugPubTable::DWARFDebugPubTable(const DWARFObject &Obj,
Sets.push_back({});
Set &SetData = Sets.back();
dwarf::DwarfFormat Format;
std::tie(SetData.Length, Format) = PubNames.getInitialLength(&Offset);
const unsigned OffsetSize = dwarf::getDwarfOffsetByteSize(Format);
std::tie(SetData.Length, SetData.Format) =
PubNames.getInitialLength(&Offset);
const unsigned OffsetSize = dwarf::getDwarfOffsetByteSize(SetData.Format);
SetData.Version = PubNames.getU16(&Offset);
SetData.Offset = PubNames.getRelocatedValue(OffsetSize, &Offset);
@ -50,15 +50,18 @@ DWARFDebugPubTable::DWARFDebugPubTable(const DWARFObject &Obj,
void DWARFDebugPubTable::dump(raw_ostream &OS) const {
for (const Set &S : Sets) {
OS << "length = " << format("0x%08" PRIx64, S.Length);
int OffsetDumpWidth = 2 * dwarf::getDwarfOffsetByteSize(S.Format);
OS << "length = " << format("0x%0*" PRIx64, OffsetDumpWidth, S.Length);
OS << " version = " << format("0x%04x", S.Version);
OS << " unit_offset = " << format("0x%08" PRIx64, S.Offset);
OS << " unit_size = " << format("0x%08" PRIx64, S.Size) << '\n';
OS << " unit_offset = "
<< format("0x%0*" PRIx64, OffsetDumpWidth, S.Offset);
OS << " unit_size = " << format("0x%0*" PRIx64, OffsetDumpWidth, S.Size)
<< '\n';
OS << (GnuStyle ? "Offset Linkage Kind Name\n"
: "Offset Name\n");
for (const Entry &E : S.Entries) {
OS << format("0x%8.8" PRIx64 " ", E.SecOffset);
OS << format("0x%0*" PRIx64 " ", OffsetDumpWidth, E.SecOffset);
if (GnuStyle) {
StringRef EntryLinkage =
GDBIndexEntryLinkageString(E.Descriptor.Linkage);

View File

@ -3,24 +3,24 @@
# RUN: FileCheck %s
# CHECK: .debug_pubnames contents:
# CHECK-NEXT: length = 0x00000032
# CHECK-NEXT: length = 0x0000000000000032
# CHECK-SAME: version = 0x0002
# CHECK-SAME: unit_offset = 0x1122334455667788
# CHECK-SAME: unit_size = 0x1100220033004400
# CHECK-SAME: unit_offset = 0x0000112233445566
# CHECK-SAME: unit_size = 0x0000110022003300
# CHECK-NEXT: Offset Name
# CHECK-NEXT: 0xaa01aaaabbbbbbbb "foo"
# CHECK-NEXT: 0xaa02aaaabbbbbbbb "bar"
# CHECK-NEXT: 0x0000aa01aaaabbbb "foo"
# CHECK-NEXT: 0x0000aa02aaaabbbb "bar"
.section .debug_pubnames,"",@progbits
.long 0xffffffff # DWARF64 mark
.quad .Lend - .Lversion # Unit Length
.Lversion:
.short 2 # Version
.quad 0x1122334455667788 # Debug Info Offset
.quad 0x1100220033004400 # Debug Info Length
.quad 0xaa01aaaabbbbbbbb # Tuple0: Offset
.quad 0x112233445566 # Debug Info Offset
.quad 0x110022003300 # Debug Info Length
.quad 0xaa01aaaabbbb # Tuple0: Offset
.asciz "foo" # Name
.quad 0xaa02aaaabbbbbbbb # Tuple1: Offset
.quad 0xaa02aaaabbbb # Tuple1: Offset
.asciz "bar" # Name
.quad 0 # Terminator
.Lend: