[llvm] 7e9a740 - [DebugInfo] Dump values in .debug_pubnames and .debug_pubtypes according to the DWARF format (6/8).

Igor Kudrin via llvm-commits llvm-commits at lists.llvm.org
Mon May 18 23:40:07 PDT 2020


Author: Igor Kudrin
Date: 2020-05-19T13:35:48+07:00
New Revision: 7e9a740198fb526fe292441248983c2d8bdc8e3a

URL: https://github.com/llvm/llvm-project/commit/7e9a740198fb526fe292441248983c2d8bdc8e3a
DIFF: https://github.com/llvm/llvm-project/commit/7e9a740198fb526fe292441248983c2d8bdc8e3a.diff

LOG: [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

Added: 
    

Modified: 
    llvm/include/llvm/DebugInfo/DWARF/DWARFDebugPubTable.h
    llvm/lib/DebugInfo/DWARF/DWARFDebugPubTable.cpp
    llvm/test/DebugInfo/X86/dwarfdump-debug-pubnames.s

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugPubTable.h b/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugPubTable.h
index 5f7d812ec0f6..60f80bb12aa9 100644
--- a/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugPubTable.h
+++ b/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugPubTable.h
@@ -44,6 +44,9 @@ class DWARFDebugPubTable {
     /// 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;

diff  --git a/llvm/lib/DebugInfo/DWARF/DWARFDebugPubTable.cpp b/llvm/lib/DebugInfo/DWARF/DWARFDebugPubTable.cpp
index e3458d9ab8aa..70663fa85da4 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFDebugPubTable.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFDebugPubTable.cpp
@@ -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);

diff  --git a/llvm/test/DebugInfo/X86/dwarfdump-debug-pubnames.s b/llvm/test/DebugInfo/X86/dwarfdump-debug-pubnames.s
index 1ac4e13bfc1e..eedaea79cbc4 100644
--- a/llvm/test/DebugInfo/X86/dwarfdump-debug-pubnames.s
+++ b/llvm/test/DebugInfo/X86/dwarfdump-debug-pubnames.s
@@ -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,"", at 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:


        


More information about the llvm-commits mailing list