OSDN Git Service

[DebugInfo] Dump length of CUs and TUs according to the DWARF format (3/8).
authorIgor Kudrin <ikudrin@accesssoftek.com>
Tue, 19 May 2020 06:35:20 +0000 (13:35 +0700)
committerIgor Kudrin <ikudrin@accesssoftek.com>
Tue, 19 May 2020 06:35:20 +0000 (13:35 +0700)
The patch changes dumping of the unit_length field in a unit header so
that it is printed as a 16-digit hex value if the unit is in the DWARF64
format.

Differential Revision: https://reviews.llvm.org/D79997

llvm/include/llvm/DebugInfo/DWARF/DWARFUnit.h
llvm/lib/DebugInfo/DWARF/DWARFCompileUnit.cpp
llvm/lib/DebugInfo/DWARF/DWARFTypeUnit.cpp
llvm/test/DebugInfo/X86/dwp-dwarf64.s
llvm/test/tools/llvm-dwarfdump/X86/debug_info_min_dwarf64.s
llvm/test/tools/llvm-dwarfdump/X86/typeunit-v4-dwarf64.s
llvm/test/tools/llvm-dwarfdump/X86/typeunit-v5-dwarf64.s

index cb9e2c3..5b3b466 100644 (file)
@@ -291,6 +291,7 @@ public:
     return Header.getDwarfOffsetByteSize();
   }
   uint64_t getLength() const { return Header.getLength(); }
+  dwarf::DwarfFormat getFormat() const { return Header.getFormat(); }
   uint8_t getUnitType() const { return Header.getUnitType(); }
   bool isTypeUnit() const { return Header.isTypeUnit(); }
   uint64_t getNextUnitOffset() const { return Header.getNextUnitOffset(); }
index f59e492..3c3513e 100644 (file)
@@ -15,8 +15,9 @@
 using namespace llvm;
 
 void DWARFCompileUnit::dump(raw_ostream &OS, DIDumpOptions DumpOpts) {
+  int OffsetDumpWidth = 2 * dwarf::getDwarfOffsetByteSize(getFormat());
   OS << format("0x%08" PRIx64, getOffset()) << ": Compile Unit:"
-     << " length = " << format("0x%08" PRIx64, getLength())
+     << " length = " << format("0x%0*" PRIx64, OffsetDumpWidth, getLength())
      << " version = " << format("0x%04x", getVersion());
   if (getVersion() >= 5)
     OS << " unit_type = " << dwarf::UnitTypeString(getUnitType());
index bb81090..1873e22 100644 (file)
@@ -20,16 +20,18 @@ using namespace llvm;
 void DWARFTypeUnit::dump(raw_ostream &OS, DIDumpOptions DumpOpts) {
   DWARFDie TD = getDIEForOffset(getTypeOffset() + getOffset());
   const char *Name = TD.getName(DINameKind::ShortName);
+  int OffsetDumpWidth = 2 * dwarf::getDwarfOffsetByteSize(getFormat());
 
   if (DumpOpts.SummarizeTypes) {
     OS << "name = '" << Name << "'"
        << " type_signature = " << format("0x%016" PRIx64, getTypeHash())
-       << " length = " << format("0x%08" PRIx64, getLength()) << '\n';
+       << " length = " << format("0x%0*" PRIx64, OffsetDumpWidth, getLength())
+       << '\n';
     return;
   }
 
   OS << format("0x%08" PRIx64, getOffset()) << ": Type Unit:"
-     << " length = " << format("0x%08" PRIx64, getLength())
+     << " length = " << format("0x%0*" PRIx64, OffsetDumpWidth, getLength())
      << " version = " << format("0x%04x", getVersion());
   if (getVersion() >= 5)
     OS << " unit_type = " << dwarf::UnitTypeString(getUnitType());
index dbba3f7..b5b9fad 100644 (file)
@@ -5,7 +5,7 @@
 # CHECK:      .debug_info.dwo contents:
 
 # CHECK:      0x00000000: Compile Unit:
-# CHECK-SAME:   length = 0x00000018
+# CHECK-SAME:   length = 0x0000000000000018
 # CHECK-SAME:   version = 0x0004
 # CHECK-SAME:   abbr_offset = 0x0000
 # CHECK-SAME:   addr_size = 0x04
index 9a9c9b3..5c1d752 100644 (file)
@@ -18,7 +18,7 @@
 DI_4_64_start:
         .long 0xffffffff       # DWARF64 mark
         .quad DI_4_64_end - DI_4_64_version # Length of Unit
-# CHECK-SAME: length = 0x0000000f
+# CHECK-SAME: length = 0x000000000000000f
 DI_4_64_version:
         .short 4               # DWARF version number
 # CHECK-SAME: version = 0x0004
index a785f8a..6b9eff3 100644 (file)
@@ -25,7 +25,7 @@
 TU_4_64_start:
         .long 0xffffffff            # DWARF64 mark
         .quad TU_4_64_end-TU_4_64_version  # Length of Unit
-# CHECK-SAME: length = 0x00000021
+# CHECK-SAME: length = 0x0000000000000021
 TU_4_64_version:
         .short 4                    # DWARF version number
 # CHECK-SAME: version = 0x0004
index 1a82a05..de07dd1 100644 (file)
@@ -25,7 +25,7 @@
 TU_5_64_start:
         .long 0xffffffff            # DWARF64 mark
         .quad TU_5_64_end-TU_5_64_version  # Length of Unit
-# CHECK-SAME: length = 0x00000022
+# CHECK-SAME: length = 0x0000000000000022
 TU_5_64_version:
         .short 5                    # DWARF version number
 # CHECK-SAME: version = 0x0005