Skip to content

Commit 2094c5d

Browse files
committed
[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
1 parent c9122b8 commit 2094c5d

File tree

4 files changed

+103
-12
lines changed

4 files changed

+103
-12
lines changed

llvm/lib/DebugInfo/DWARF/DWARFListTable.cpp

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -79,20 +79,21 @@ Error DWARFListTableHeader::extract(DWARFDataExtractor Data,
7979
void DWARFListTableHeader::dump(raw_ostream &OS, DIDumpOptions DumpOpts) const {
8080
if (DumpOpts.Verbose)
8181
OS << format("0x%8.8" PRIx64 ": ", HeaderOffset);
82-
OS << format(
83-
"%s list header: length = 0x%8.8" PRIx64 ", version = 0x%4.4" PRIx16 ", "
84-
"addr_size = 0x%2.2" PRIx8 ", seg_size = 0x%2.2" PRIx8
85-
", offset_entry_count = "
86-
"0x%8.8" PRIx32 "\n",
87-
ListTypeString.data(), HeaderData.Length, HeaderData.Version,
88-
HeaderData.AddrSize, HeaderData.SegSize, HeaderData.OffsetEntryCount);
82+
int OffsetDumpWidth = 2 * dwarf::getDwarfOffsetByteSize(Format);
83+
OS << format("%s list header: length = 0x%0*" PRIx64
84+
", version = 0x%4.4" PRIx16 ", addr_size = 0x%2.2" PRIx8
85+
", seg_size = 0x%2.2" PRIx8
86+
", offset_entry_count = 0x%8.8" PRIx32 "\n",
87+
ListTypeString.data(), OffsetDumpWidth, HeaderData.Length,
88+
HeaderData.Version, HeaderData.AddrSize, HeaderData.SegSize,
89+
HeaderData.OffsetEntryCount);
8990

9091
if (HeaderData.OffsetEntryCount > 0) {
9192
OS << "offsets: [";
9293
for (const auto &Off : Offsets) {
93-
OS << format("\n0x%8.8" PRIx64, Off);
94+
OS << format("\n0x%0*" PRIx64, OffsetDumpWidth, Off);
9495
if (DumpOpts.Verbose)
95-
OS << format(" => 0x%8.8" PRIx64,
96+
OS << format(" => 0x%08" PRIx64,
9697
Off + HeaderOffset + getHeaderSize(Format));
9798
}
9899
OS << "\n]\n";
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# RUN: llvm-mc %s -filetype obj -triple x86_64 -o - | \
2+
# RUN: llvm-dwarfdump -v -debug-loclists - | \
3+
# RUN: FileCheck %s
4+
5+
# CHECK: .debug_loclists contents:
6+
# CHECK-NEXT: locations list header:
7+
# CHECK-SAME: length = 0x0000000000000028,
8+
# CHECK-SAME: version = 0x0005,
9+
# CHECK-SAME: addr_size = 0x08,
10+
# CHECK-SAME: seg_size = 0x00,
11+
# CHECK-SAME: offset_entry_count = 0x00000002
12+
# CHECK-NEXT: offsets: [
13+
# CHECK-NEXT: 0x0000000000000010 => 0x00000024
14+
# CHECK-NEXT: 0x0000000000000018 => 0x0000002c
15+
# CHECK-NEXT: ]
16+
# CHECK-NEXT: 0x00000024:
17+
# CHECK-NEXT: DW_LLE_offset_pair (0x0000000000000001, 0x0000000000000002): DW_OP_consts +7, DW_OP_stack_value
18+
# CHECK-NEXT: DW_LLE_end_of_list ()
19+
# CHECK-EMPTY:
20+
# CHECK-NEXT: 0x0000002c:
21+
# CHECK-NEXT: DW_LLE_offset_pair (0x0000000000000005, 0x0000000000000007): DW_OP_consts +12, DW_OP_stack_value
22+
# CHECK-NEXT: DW_LLE_end_of_list ()
23+
24+
.section .debug_loclists, "", @progbits
25+
.long 0xffffffff # DWARF64 mark
26+
.quad .LLLEnd-.LLLBegin # Length
27+
.LLLBegin:
28+
.short 5 # Version
29+
.byte 8 # Address size
30+
.byte 0 # Segment selector size
31+
.long 2 # Offset entry count
32+
.LLLBase:
33+
.quad .LLL0-.LLLBase
34+
.quad .LLL1-.LLLBase
35+
.LLL0:
36+
.byte 4 # DW_LLE_offset_pair
37+
.uleb128 1 # starting offset
38+
.uleb128 2 # ending offset
39+
.byte 3 # Loc expr size
40+
.byte 17 # DW_OP_consts
41+
.byte 7 # 7
42+
.byte 159 # DW_OP_stack_value
43+
.byte 0 # DW_LLE_end_of_list
44+
45+
.LLL1:
46+
.byte 4 # DW_LLE_offset_pair
47+
.uleb128 5 # starting offset
48+
.uleb128 7 # ending offset
49+
.byte 3 # Loc expr size
50+
.byte 17 # DW_OP_consts
51+
.byte 12 # 12
52+
.byte 159 # DW_OP_stack_value
53+
.byte 0 # DW_LLE_end_of_list
54+
.LLLEnd:

llvm/test/DebugInfo/X86/dwarfdump-rnglists-dwarf64.s

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
# RUN: FileCheck %s --input-file %t.err --check-prefix=ERR
44
# RUN: not llvm-dwarfdump -lookup 10 %t.o 2> %t2.err
55
# RUN: FileCheck %s --input-file %t2.err --check-prefix=ERR
6+
# RUN: llvm-dwarfdump -debug-rnglists %t.o | \
7+
# RUN: FileCheck %s --check-prefix=RNGLISTS
68

79
# Test object to verify dwarfdump handles v5 range lists in 64-bit DWARF format.
810
# This is similar to 'dwarfdump-rnglists.s', which uses 32-bit DWARF format.
@@ -210,3 +212,37 @@ Range1_end:
210212
#ERR: error: parsing a range list table: did not detect a valid list table with base = 0x8
211213
#ERR: error: decoding address ranges: missing or invalid range list table
212214
#ERR: error: decoding address ranges: invalid range list offset 0xfa0
215+
216+
# RNGLISTS: .debug_rnglists contents:
217+
# RNGLISTS: range list header:
218+
# RNGLISTS-SAME: length = 0x0000000000000031,
219+
# RNGLISTS-SAME: version = 0x0005,
220+
# RNGLISTS-SAME: addr_size = 0x04,
221+
# RNGLISTS-SAME: seg_size = 0x00,
222+
# RNGLISTS-SAME: offset_entry_count = 0x00000002
223+
# RNGLISTS-NEXT: offsets: [
224+
# RNGLISTS-NEXT: 0x0000000000000010
225+
# RNGLISTS-NEXT: 0x0000000000000020
226+
# RNGLISTS-NEXT: ]
227+
# RNGLISTS-NEXT: ranges:
228+
# RNGLISTS-NEXT: [0x00000014, 0x0000001e)
229+
# RNGLISTS-NEXT: [0x0000002a, 0x00000034)
230+
# RNGLISTS-NEXT: <End of list>
231+
# RNGLISTS-NEXT: [0x0000002a, 0x00000034)
232+
# RNGLISTS-NEXT: <End of list>
233+
234+
# RNGLISTS: .debug_rnglists.dwo contents:
235+
# RNGLISTS: range list header:
236+
# RNGLISTS-SAME: length = 0x0000000000000022,
237+
# RNGLISTS-SAME: version = 0x0005,
238+
# RNGLISTS-SAME: addr_size = 0x04,
239+
# RNGLISTS-SAME: seg_size = 0x00,
240+
# RNGLISTS-SAME: offset_entry_count = 0x00000002
241+
# RNGLISTS-NEXT: offsets: [
242+
# RNGLISTS-NEXT: 0x0000000000000010
243+
# RNGLISTS-NEXT: 0x0000000000000011
244+
# RNGLISTS-NEXT: ]
245+
# RNGLISTS-NEXT: ranges:
246+
# RNGLISTS-NEXT: <End of list>
247+
# RNGLISTS-NEXT: [0x0000002a, 0x00000034)
248+
# RNGLISTS-NEXT: <End of list>

llvm/test/tools/llvm-dwarfdump/X86/debug_rnglists_dwarf64.s

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@
44

55
# CHECK: .debug_rnglists contents:
66
# CHECK-NEXT: 0x00000000: range list header:
7-
# CHECK-SAME: length = 0x0000001a,
7+
# CHECK-SAME: length = 0x000000000000001a,
88
# CHECK-SAME: version = 0x0005,
99
# CHECK-SAME: addr_size = 0x08,
1010
# CHECK-SAME: seg_size = 0x00,
1111
# CHECK-SAME: offset_entry_count = 0x00000002
1212
# CHECK-NEXT: offsets: [
13-
# CHECK-NEXT: 0x00000010 => 0x00000024
14-
# CHECK-NEXT: 0x00000011 => 0x00000025
13+
# CHECK-NEXT: 0x0000000000000010 => 0x00000024
14+
# CHECK-NEXT: 0x0000000000000011 => 0x00000025
1515
# CHECK-NEXT: ]
1616
# CHECK-NEXT: ranges:
1717
# CHECK-NEXT: 0x00000024: [DW_RLE_end_of_list]

0 commit comments

Comments
 (0)