[llvm] 2094c5d - [DebugInfo] Dump values in .debug_loclists and .debug_rnglists according to the DWARF format (5/8).

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


Author: Igor Kudrin
Date: 2020-05-19T13:35:41+07:00
New Revision: 2094c5d29200ec67179ce232d7452e0d2c1cf24e

URL: https://github.com/llvm/llvm-project/commit/2094c5d29200ec67179ce232d7452e0d2c1cf24e
DIFF: https://github.com/llvm/llvm-project/commit/2094c5d29200ec67179ce232d7452e0d2c1cf24e.diff

LOG: [DebugInfo] Dump values in .debug_loclists and .debug_rnglists according to the DWARF format (5/8).

The patch changes dumping of a unit_length field and offsets in headers
in .debug_loclists and .debug_rnglists sections 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: 
    llvm/test/DebugInfo/X86/dwarfdump-debug-loclists-dwarf64.s

Modified: 
    llvm/lib/DebugInfo/DWARF/DWARFListTable.cpp
    llvm/test/DebugInfo/X86/dwarfdump-rnglists-dwarf64.s
    llvm/test/tools/llvm-dwarfdump/X86/debug_rnglists_dwarf64.s

Removed: 
    


################################################################################
diff  --git a/llvm/lib/DebugInfo/DWARF/DWARFListTable.cpp b/llvm/lib/DebugInfo/DWARF/DWARFListTable.cpp
index fd928385ad7b..a380434b4d33 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFListTable.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFListTable.cpp
@@ -79,20 +79,21 @@ Error DWARFListTableHeader::extract(DWARFDataExtractor Data,
 void DWARFListTableHeader::dump(raw_ostream &OS, DIDumpOptions DumpOpts) const {
   if (DumpOpts.Verbose)
     OS << format("0x%8.8" PRIx64 ": ", HeaderOffset);
-  OS << format(
-      "%s list header: length = 0x%8.8" PRIx64 ", version = 0x%4.4" PRIx16 ", "
-      "addr_size = 0x%2.2" PRIx8 ", seg_size = 0x%2.2" PRIx8
-      ", offset_entry_count = "
-      "0x%8.8" PRIx32 "\n",
-      ListTypeString.data(), HeaderData.Length, HeaderData.Version,
-      HeaderData.AddrSize, HeaderData.SegSize, HeaderData.OffsetEntryCount);
+  int OffsetDumpWidth = 2 * dwarf::getDwarfOffsetByteSize(Format);
+  OS << format("%s list header: length = 0x%0*" PRIx64
+               ", version = 0x%4.4" PRIx16 ", addr_size = 0x%2.2" PRIx8
+               ", seg_size = 0x%2.2" PRIx8
+               ", offset_entry_count = 0x%8.8" PRIx32 "\n",
+               ListTypeString.data(), OffsetDumpWidth, HeaderData.Length,
+               HeaderData.Version, HeaderData.AddrSize, HeaderData.SegSize,
+               HeaderData.OffsetEntryCount);
 
   if (HeaderData.OffsetEntryCount > 0) {
     OS << "offsets: [";
     for (const auto &Off : Offsets) {
-      OS << format("\n0x%8.8" PRIx64, Off);
+      OS << format("\n0x%0*" PRIx64, OffsetDumpWidth, Off);
       if (DumpOpts.Verbose)
-        OS << format(" => 0x%8.8" PRIx64,
+        OS << format(" => 0x%08" PRIx64,
                      Off + HeaderOffset + getHeaderSize(Format));
     }
     OS << "\n]\n";

diff  --git a/llvm/test/DebugInfo/X86/dwarfdump-debug-loclists-dwarf64.s b/llvm/test/DebugInfo/X86/dwarfdump-debug-loclists-dwarf64.s
new file mode 100644
index 000000000000..bc0a233ec1ad
--- /dev/null
+++ b/llvm/test/DebugInfo/X86/dwarfdump-debug-loclists-dwarf64.s
@@ -0,0 +1,54 @@
+# RUN: llvm-mc %s -filetype obj -triple x86_64 -o - | \
+# RUN:   llvm-dwarfdump -v -debug-loclists - | \
+# RUN:   FileCheck %s
+
+# CHECK:      .debug_loclists contents:
+# CHECK-NEXT: locations list header:
+# CHECK-SAME: length = 0x0000000000000028,
+# CHECK-SAME: version = 0x0005,
+# CHECK-SAME: addr_size = 0x08,
+# CHECK-SAME: seg_size = 0x00,
+# CHECK-SAME: offset_entry_count = 0x00000002
+# CHECK-NEXT: offsets: [
+# CHECK-NEXT: 0x0000000000000010 => 0x00000024
+# CHECK-NEXT: 0x0000000000000018 => 0x0000002c
+# CHECK-NEXT: ]
+# CHECK-NEXT: 0x00000024:
+# CHECK-NEXT:   DW_LLE_offset_pair (0x0000000000000001, 0x0000000000000002): DW_OP_consts +7, DW_OP_stack_value
+# CHECK-NEXT:   DW_LLE_end_of_list ()
+# CHECK-EMPTY:
+# CHECK-NEXT: 0x0000002c:
+# CHECK-NEXT:   DW_LLE_offset_pair (0x0000000000000005, 0x0000000000000007): DW_OP_consts +12, DW_OP_stack_value
+# CHECK-NEXT:   DW_LLE_end_of_list ()
+
+    .section .debug_loclists, "", @progbits
+    .long 0xffffffff            # DWARF64 mark
+    .quad .LLLEnd-.LLLBegin     # Length
+.LLLBegin:
+    .short 5                    # Version
+    .byte 8                     # Address size
+    .byte 0                     # Segment selector size
+    .long 2                     # Offset entry count
+.LLLBase:
+    .quad .LLL0-.LLLBase
+    .quad .LLL1-.LLLBase
+.LLL0:
+    .byte 4                     # DW_LLE_offset_pair
+    .uleb128 1                  #   starting offset
+    .uleb128 2                  #   ending offset
+    .byte 3                     # Loc expr size
+    .byte 17                    # DW_OP_consts
+    .byte 7                     # 7
+    .byte 159                   # DW_OP_stack_value
+    .byte 0                     # DW_LLE_end_of_list
+
+.LLL1:
+    .byte 4                     # DW_LLE_offset_pair
+    .uleb128 5                  #   starting offset
+    .uleb128 7                  #   ending offset
+    .byte 3                     # Loc expr size
+    .byte 17                    # DW_OP_consts
+    .byte 12                    # 12
+    .byte 159                   # DW_OP_stack_value
+    .byte 0                     # DW_LLE_end_of_list
+.LLLEnd:

diff  --git a/llvm/test/DebugInfo/X86/dwarfdump-rnglists-dwarf64.s b/llvm/test/DebugInfo/X86/dwarfdump-rnglists-dwarf64.s
index 9cd4980a32c9..7bf55548179b 100644
--- a/llvm/test/DebugInfo/X86/dwarfdump-rnglists-dwarf64.s
+++ b/llvm/test/DebugInfo/X86/dwarfdump-rnglists-dwarf64.s
@@ -3,6 +3,8 @@
 # RUN: FileCheck %s --input-file %t.err --check-prefix=ERR
 # RUN: not llvm-dwarfdump -lookup 10 %t.o 2> %t2.err
 # RUN: FileCheck %s --input-file %t2.err --check-prefix=ERR
+# RUN: llvm-dwarfdump -debug-rnglists %t.o | \
+# RUN:   FileCheck %s --check-prefix=RNGLISTS
 
 # Test object to verify dwarfdump handles v5 range lists in 64-bit DWARF format.
 # This is similar to 'dwarfdump-rnglists.s', which uses 32-bit DWARF format.
@@ -210,3 +212,37 @@ Range1_end:
 #ERR: error: parsing a range list table: did not detect a valid list table with base = 0x8
 #ERR: error: decoding address ranges: missing or invalid range list table
 #ERR: error: decoding address ranges: invalid range list offset 0xfa0
+
+# RNGLISTS:      .debug_rnglists contents:
+# RNGLISTS:      range list header:
+# RNGLISTS-SAME:   length = 0x0000000000000031,
+# RNGLISTS-SAME:   version = 0x0005,
+# RNGLISTS-SAME:   addr_size = 0x04,
+# RNGLISTS-SAME:   seg_size = 0x00,
+# RNGLISTS-SAME:   offset_entry_count = 0x00000002
+# RNGLISTS-NEXT: offsets: [
+# RNGLISTS-NEXT: 0x0000000000000010
+# RNGLISTS-NEXT: 0x0000000000000020
+# RNGLISTS-NEXT: ]
+# RNGLISTS-NEXT: ranges:
+# RNGLISTS-NEXT: [0x00000014, 0x0000001e)
+# RNGLISTS-NEXT: [0x0000002a, 0x00000034)
+# RNGLISTS-NEXT: <End of list>
+# RNGLISTS-NEXT: [0x0000002a, 0x00000034)
+# RNGLISTS-NEXT: <End of list>
+
+# RNGLISTS:      .debug_rnglists.dwo contents:
+# RNGLISTS:      range list header:
+# RNGLISTS-SAME:   length = 0x0000000000000022,
+# RNGLISTS-SAME:   version = 0x0005,
+# RNGLISTS-SAME:   addr_size = 0x04,
+# RNGLISTS-SAME:   seg_size = 0x00,
+# RNGLISTS-SAME:   offset_entry_count = 0x00000002
+# RNGLISTS-NEXT: offsets: [
+# RNGLISTS-NEXT: 0x0000000000000010
+# RNGLISTS-NEXT: 0x0000000000000011
+# RNGLISTS-NEXT: ]
+# RNGLISTS-NEXT: ranges:
+# RNGLISTS-NEXT: <End of list>
+# RNGLISTS-NEXT: [0x0000002a, 0x00000034)
+# RNGLISTS-NEXT: <End of list>

diff  --git a/llvm/test/tools/llvm-dwarfdump/X86/debug_rnglists_dwarf64.s b/llvm/test/tools/llvm-dwarfdump/X86/debug_rnglists_dwarf64.s
index ae3607a1ca2e..59560ff1c469 100644
--- a/llvm/test/tools/llvm-dwarfdump/X86/debug_rnglists_dwarf64.s
+++ b/llvm/test/tools/llvm-dwarfdump/X86/debug_rnglists_dwarf64.s
@@ -4,14 +4,14 @@
 
 # CHECK:      .debug_rnglists contents:
 # CHECK-NEXT: 0x00000000: range list header:
-# CHECK-SAME:   length = 0x0000001a,
+# CHECK-SAME:   length = 0x000000000000001a,
 # CHECK-SAME:   version = 0x0005,
 # CHECK-SAME:   addr_size = 0x08,
 # CHECK-SAME:   seg_size = 0x00,
 # CHECK-SAME:   offset_entry_count = 0x00000002
 # CHECK-NEXT: offsets: [
-# CHECK-NEXT: 0x00000010 => 0x00000024
-# CHECK-NEXT: 0x00000011 => 0x00000025
+# CHECK-NEXT: 0x0000000000000010 => 0x00000024
+# CHECK-NEXT: 0x0000000000000011 => 0x00000025
 # CHECK-NEXT: ]
 # CHECK-NEXT: ranges:
 # CHECK-NEXT: 0x00000024: [DW_RLE_end_of_list]


        


More information about the llvm-commits mailing list