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";
--- /dev/null
+# 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:
# 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.
#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>
# 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]