[llvm] 69dfa07 - [DebugInfo] Dump fields in .debug_aranges according to the DWARF format (1/8).

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


Author: Igor Kudrin
Date: 2020-05-19T13:34:54+07:00
New Revision: 69dfa07b4cefba5d403749d04190c7c8e1823f71

URL: https://github.com/llvm/llvm-project/commit/69dfa07b4cefba5d403749d04190c7c8e1823f71
DIFF: https://github.com/llvm/llvm-project/commit/69dfa07b4cefba5d403749d04190c7c8e1823f71.diff

LOG: [DebugInfo] Dump fields in .debug_aranges according to the DWARF format (1/8).

The patch changes dumping of unit_length and debug_info_offset fields in
an address range header so that they are printed as 16-digit hex values
if the contribution is in the DWARF64 format.

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

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugArangeSet.h b/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugArangeSet.h
index 92c46057fe5c..0681a2e33a50 100644
--- a/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugArangeSet.h
+++ b/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugArangeSet.h
@@ -25,6 +25,8 @@ class DWARFDebugArangeSet {
     /// The total length of the entries for that set, not including the length
     /// field itself.
     uint64_t Length;
+    /// The DWARF format of the set.
+    dwarf::DwarfFormat Format;
     /// The offset from the beginning of the .debug_info section of the
     /// compilation unit entry referenced by the table.
     uint64_t CuOffset;

diff  --git a/llvm/lib/DebugInfo/DWARF/DWARFDebugArangeSet.cpp b/llvm/lib/DebugInfo/DWARF/DWARFDebugArangeSet.cpp
index 9d640b84b33b..77bd49a65927 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFDebugArangeSet.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFDebugArangeSet.cpp
@@ -60,12 +60,12 @@ Error DWARFDebugArangeSet::extract(DWARFDataExtractor data,
   // the segment selectors are omitted from all tuples, including
   // the terminating tuple.
 
-  dwarf::DwarfFormat format;
   Error Err = Error::success();
-  std::tie(HeaderData.Length, format) = data.getInitialLength(offset_ptr, &Err);
+  std::tie(HeaderData.Length, HeaderData.Format) =
+      data.getInitialLength(offset_ptr, &Err);
   HeaderData.Version = data.getU16(offset_ptr, &Err);
-  HeaderData.CuOffset =
-      data.getUnsigned(offset_ptr, dwarf::getDwarfOffsetByteSize(format), &Err);
+  HeaderData.CuOffset = data.getUnsigned(
+      offset_ptr, dwarf::getDwarfOffsetByteSize(HeaderData.Format), &Err);
   HeaderData.AddrSize = data.getU8(offset_ptr, &Err);
   HeaderData.SegSize = data.getU8(offset_ptr, &Err);
   if (Err) {
@@ -77,7 +77,7 @@ Error DWARFDebugArangeSet::extract(DWARFDataExtractor data,
 
   // Perform basic validation of the header fields.
   uint64_t full_length =
-      dwarf::getUnitLengthFieldByteSize(format) + HeaderData.Length;
+      dwarf::getUnitLengthFieldByteSize(HeaderData.Format) + HeaderData.Length;
   if (!data.isValidOffsetForDataOfSize(Offset, full_length))
     return createStringError(errc::invalid_argument,
                              "the length of address range table at offset "
@@ -157,10 +157,12 @@ Error DWARFDebugArangeSet::extract(DWARFDataExtractor data,
 }
 
 void DWARFDebugArangeSet::dump(raw_ostream &OS) const {
+  int OffsetDumpWidth = 2 * dwarf::getDwarfOffsetByteSize(HeaderData.Format);
   OS << "Address Range Header: "
-     << format("length = 0x%8.8" PRIx64 ", ", HeaderData.Length)
+     << format("length = 0x%0*" PRIx64 ", ", OffsetDumpWidth, HeaderData.Length)
      << format("version = 0x%4.4x, ", HeaderData.Version)
-     << format("cu_offset = 0x%8.8" PRIx64 ", ", HeaderData.CuOffset)
+     << format("cu_offset = 0x%0*" PRIx64 ", ", OffsetDumpWidth,
+               HeaderData.CuOffset)
      << format("addr_size = 0x%2.2x, ", HeaderData.AddrSize)
      << format("seg_size = 0x%2.2x\n", HeaderData.SegSize);
 

diff  --git a/llvm/test/DebugInfo/X86/dwarfdump-debug-aranges.s b/llvm/test/DebugInfo/X86/dwarfdump-debug-aranges.s
index 9bd7ee49ab4e..5007021c1ab0 100644
--- a/llvm/test/DebugInfo/X86/dwarfdump-debug-aranges.s
+++ b/llvm/test/DebugInfo/X86/dwarfdump-debug-aranges.s
@@ -28,11 +28,11 @@
 # CHECK: Address Range Header: length = 0x0000001c,
 .L2version:
     .short  2                       # Version
-    .long   0x11223344              # Debug Info Offset
+    .long   0x112233                # Debug Info Offset
     .byte   4                       # Address Size
     .byte   0                       # Segment Selector Size
 # CHECK-SAME: version = 0x0002,
-# CHECK-SAME: cu_offset = 0x11223344,
+# CHECK-SAME: cu_offset = 0x00112233,
 # CHECK-SAME: addr_size = 0x04,
 # CHECK-SAME: seg_size = 0x00
     .space  4                       # Padding
@@ -48,11 +48,11 @@
 # CHECK: Address Range Header: length = 0x0000002c,
 .L3version:
     .short  2                       # Version
-    .long   0x22334455              # Debug Info Offset
+    .long   0x112233                # Debug Info Offset
     .byte   8                       # Address Size
     .byte   0                       # Segment Selector Size
 # CHECK-SAME: version = 0x0002,
-# CHECK-SAME: cu_offset = 0x22334455,
+# CHECK-SAME: cu_offset = 0x00112233,
 # CHECK-SAME: addr_size = 0x08,
 # CHECK-SAME: seg_size = 0x00
     .space  4                       # Padding
@@ -67,14 +67,14 @@
 ## Case 4: Check that 64-bit DWARF format is supported.
     .long 0xffffffff                # DWARF64 mark
     .quad   .L4end - .L4version     # Length
-# CHECK: Address Range Header: length = 0x0000001c,
+# CHECK: Address Range Header: length = 0x000000000000001c,
 .L4version:
     .short  2                       # Version
-    .quad   0x1234567899aabbcc      # Debug Info Offset
+    .quad   0x123456789abc          # Debug Info Offset
     .byte   4                       # Address Size
     .byte   0                       # Segment Selector Size
 # CHECK-SAME: version = 0x0002,
-# CHECK-SAME: cu_offset = 0x1234567899aabbcc,
+# CHECK-SAME: cu_offset = 0x0000123456789abc,
 # CHECK-SAME: addr_size = 0x04,
 # CHECK-SAME: seg_size = 0x00
                                     # No padding


        


More information about the llvm-commits mailing list