[llvm] 0db1684 - [DebugInfo] Dump length of CUs and TUs according to the DWARF format (3/8).

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


Author: Igor Kudrin
Date: 2020-05-19T13:35:20+07:00
New Revision: 0db1684b7435201e6b30236e6334a618fcfa6771

URL: https://github.com/llvm/llvm-project/commit/0db1684b7435201e6b30236e6334a618fcfa6771
DIFF: https://github.com/llvm/llvm-project/commit/0db1684b7435201e6b30236e6334a618fcfa6771.diff

LOG: [DebugInfo] Dump length of CUs and TUs according to the DWARF format (3/8).

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

Added: 
    

Modified: 
    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

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/DebugInfo/DWARF/DWARFUnit.h b/llvm/include/llvm/DebugInfo/DWARF/DWARFUnit.h
index cb9e2c32a640..5b3b46626059 100644
--- a/llvm/include/llvm/DebugInfo/DWARF/DWARFUnit.h
+++ b/llvm/include/llvm/DebugInfo/DWARF/DWARFUnit.h
@@ -291,6 +291,7 @@ class DWARFUnit {
     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(); }

diff  --git a/llvm/lib/DebugInfo/DWARF/DWARFCompileUnit.cpp b/llvm/lib/DebugInfo/DWARF/DWARFCompileUnit.cpp
index f59e49268288..3c3513e3114b 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFCompileUnit.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFCompileUnit.cpp
@@ -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());

diff  --git a/llvm/lib/DebugInfo/DWARF/DWARFTypeUnit.cpp b/llvm/lib/DebugInfo/DWARF/DWARFTypeUnit.cpp
index bb81090ba25c..1873e2285140 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFTypeUnit.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFTypeUnit.cpp
@@ -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());

diff  --git a/llvm/test/DebugInfo/X86/dwp-dwarf64.s b/llvm/test/DebugInfo/X86/dwp-dwarf64.s
index dbba3f7fc8f3..b5b9fad3f5ed 100644
--- a/llvm/test/DebugInfo/X86/dwp-dwarf64.s
+++ b/llvm/test/DebugInfo/X86/dwp-dwarf64.s
@@ -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

diff  --git a/llvm/test/tools/llvm-dwarfdump/X86/debug_info_min_dwarf64.s b/llvm/test/tools/llvm-dwarfdump/X86/debug_info_min_dwarf64.s
index 9a9c9b3562c7..5c1d752ad2bf 100644
--- a/llvm/test/tools/llvm-dwarfdump/X86/debug_info_min_dwarf64.s
+++ b/llvm/test/tools/llvm-dwarfdump/X86/debug_info_min_dwarf64.s
@@ -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

diff  --git a/llvm/test/tools/llvm-dwarfdump/X86/typeunit-v4-dwarf64.s b/llvm/test/tools/llvm-dwarfdump/X86/typeunit-v4-dwarf64.s
index a785f8a2f0eb..6b9eff3baa9d 100644
--- a/llvm/test/tools/llvm-dwarfdump/X86/typeunit-v4-dwarf64.s
+++ b/llvm/test/tools/llvm-dwarfdump/X86/typeunit-v4-dwarf64.s
@@ -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

diff  --git a/llvm/test/tools/llvm-dwarfdump/X86/typeunit-v5-dwarf64.s b/llvm/test/tools/llvm-dwarfdump/X86/typeunit-v5-dwarf64.s
index 1a82a05003ad..de07dd150f3e 100644
--- a/llvm/test/tools/llvm-dwarfdump/X86/typeunit-v5-dwarf64.s
+++ b/llvm/test/tools/llvm-dwarfdump/X86/typeunit-v5-dwarf64.s
@@ -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


        


More information about the llvm-commits mailing list