Skip to content

Commit 92c45e4

Browse files
committed
llvm-dwarfdump: Add support for DW_RLE_startx_endx
1 parent 4b38ceb commit 92c45e4

File tree

3 files changed

+62
-27
lines changed

3 files changed

+62
-27
lines changed

llvm/lib/DebugInfo/DWARF/DWARFDebugRnglists.cpp

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,9 @@ Error RangeListEntry::extract(DWARFDataExtractor Data, uint64_t *OffsetPtr) {
3737
break;
3838
}
3939
case dwarf::DW_RLE_startx_endx:
40-
consumeError(C.takeError());
41-
return createStringError(
42-
errc::not_supported,
43-
"unsupported rnglists encoding DW_RLE_startx_endx at "
44-
"offset 0x%" PRIx64,
45-
Offset);
40+
Value0 = Data.getULEB128(C);
41+
Value1 = Data.getULEB128(C);
42+
break;
4643
case dwarf::DW_RLE_startx_length: {
4744
Value0 = Data.getULEB128(C);
4845
Value1 = Data.getULEB128(C);
@@ -150,6 +147,19 @@ DWARFAddressRangesVector DWARFDebugRnglist::getAbsoluteRanges(
150147
E.HighPC = E.LowPC + RLE.Value1;
151148
break;
152149
}
150+
case dwarf::DW_RLE_startx_endx: {
151+
auto Start = LookupPooledAddress(RLE.Value0);
152+
if (!Start)
153+
Start = {0, -1ULL};
154+
auto End = LookupPooledAddress(RLE.Value1);
155+
if (!End)
156+
End = {0, -1ULL};
157+
// FIXME: Some error handling if Start.SectionIndex != End.SectionIndex
158+
E.SectionIndex = Start->SectionIndex;
159+
E.LowPC = Start->Address;
160+
E.HighPC = End->Address;
161+
break;
162+
}
153163
default:
154164
// Unsupported encodings should have been reported during extraction,
155165
// so we should not run into any here.
@@ -235,6 +245,17 @@ void RangeListEntry::dump(
235245
DWARFAddressRange(Start, Start + Value1).dump(OS, AddrSize, DumpOpts);
236246
break;
237247
}
248+
case dwarf::DW_RLE_startx_endx: {
249+
PrintRawEntry(OS, *this, AddrSize, DumpOpts);
250+
uint64_t Start = 0;
251+
if (auto SA = LookupPooledAddress(Value0))
252+
Start = SA->Address;
253+
uint64_t End = 0;
254+
if (auto SA = LookupPooledAddress(Value1))
255+
End = SA->Address;
256+
DWARFAddressRange(Start, End).dump(OS, AddrSize, DumpOpts);
257+
break;
258+
}
238259
default:
239260
llvm_unreachable("Unsupported range list encoding");
240261
}

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

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# RUN: llvm-mc %s -filetype obj -triple x86_64-pc-linux -o %t.o
2-
# RUN: not llvm-dwarfdump --debug-rnglists %t.o 2> %t.err | FileCheck %s --check-prefixes=TERSE,BOTH
3-
# RUN: FileCheck %s --input-file %t.err --check-prefix=ERR
4-
# RUN: not llvm-dwarfdump -v --debug-rnglists %t.o 2> %t.err | FileCheck %s --check-prefixes=VERBOSE,BOTH
5-
# RUN: FileCheck %s --input-file %t.err --check-prefix=ERR
2+
# RUN: llvm-dwarfdump --debug-rnglists %t.o 2> %t.err | FileCheck %s --check-prefixes=TERSE,BOTH
3+
# RUN: FileCheck %s --allow-empty --input-file %t.err --check-prefix=ERR
4+
# RUN: llvm-dwarfdump -v --debug-rnglists %t.o 2> %t.err | FileCheck %s --check-prefixes=VERBOSE,BOTH
5+
# RUN: FileCheck %s --allow-empty --input-file %t.err --check-prefix=ERR
66

77
# BOTH: .debug_rnglists contents:
88
# TERSE-NEXT: range list header: length = 0x00000037, format = DWARF32, version = 0x0005, addr_size = 0x08, seg_size = 0x00, offset_entry_count = 0x00000000
@@ -74,6 +74,18 @@
7474
# VERBOSE-NEXT: 0x{{[0-9a-f]*}}:
7575
# VERBOSE-SAME: range list header: length = 0x0000000c, format = DWARF32, version = 0x0005, addr_size = 0x08, seg_size = 0x00, offset_entry_count = 0x00000000
7676

77+
# BOTH-NEXT: ranges:
78+
# TERSE-NEXT: [0x0000000000000000, 0x0000000000000000)
79+
# TERSE-NEXT: <End of list>
80+
81+
# VERBOSE-NEXT: 0x00000091: [DW_RLE_startx_endx]: 0x0000000000000001, 0x000000000000000a => [0x0000000000000000, 0x0000000000000000)
82+
# VERBOSE-NEXT: 0x00000094: [DW_RLE_end_of_list]
83+
84+
# TERSE-NEXT: range list header: length = 0x0000000c, format = DWARF32, version = 0x0005, addr_size = 0x08, seg_size = 0x00, offset_entry_count = 0x00000000
85+
86+
# VERBOSE-NEXT: 0x{{[0-9a-f]*}}:
87+
# VERBOSE-SAME: range list header: length = 0x0000000c, format = DWARF32, version = 0x0005, addr_size = 0x08, seg_size = 0x00, offset_entry_count = 0x00000000
88+
7789
# BOTH-NEXT: ranges:
7890
# TERSE-NEXT: [0x0000000000000000, 0x000000000000002a)
7991
# TERSE-NEXT: <End of list>
@@ -110,8 +122,6 @@
110122

111123
# BOTH-NOT: range list header:
112124

113-
# ERR-NOT: error:
114-
# ERR: error: unsupported rnglists encoding DW_RLE_startx_endx at offset 0x91
115125
# ERR-NOT: error:
116126

117127
.section .debug_rnglists,"",@progbits

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

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
# CHECK-NEXT: [0x00000042, 0x00000048)
2525
# CHECK-NEXT: [0x00000042, 0x00000048)
2626
# CHECK-NEXT: [0x00000042, 0x00000048)
27+
# CHECK-NEXT: [0x00000042, 0x00000042)
2728
# CHECK-NEXT: [0x00000042, 0x00000048)
2829
# CHECK-NEXT: [0x00000042, 0x00000048))
2930
# CHECK: DW_TAG_subprogram
@@ -48,10 +49,11 @@
4849
# entire rnglists contribution (since there's no way to know where such a
4950
# contribution starts) - rather than assuming one starts at 0.
5051

51-
# CHECK: DW_AT_ranges [DW_FORM_sec_offset] (0x00000057)
52+
# CHECK: DW_AT_ranges
5253
# [0x0000000000000042, 0x0000000000000048)
5354
# [0x0000000000000042, 0x0000000000000048)
5455
# [0x0000000000000042, 0x0000000000000048)
56+
# [0x0000000000000042, 0x0000000000000042)
5557
# [0x0000000000000042, 0x0000000000000048)
5658
# [0x0000000000000042, 0x0000000000000048))
5759
# CHECK: DW_TAG_subprogram
@@ -127,6 +129,8 @@
127129
# CHECK-NEXT: [DW_RLE_startx_length]: 0x00000001, 0x00000006
128130
# CHECK-NEXT: [DW_RLE_start_end ]: [0xffffffff, 0xffffffff)
129131
# CHECK-NEXT: [DW_RLE_start_end ]: [0x00000042, 0x00000048)
132+
# CHECK-NEXT: [DW_RLE_startx_endx ]: 0x00000000, 0x00000000
133+
# CHECK-NEXT: [DW_RLE_startx_endx ]: 0x00000001, 0x00000001
130134
# CHECK-NEXT: [DW_RLE_base_address ]: 0x00000040
131135
# CHECK-NEXT: [DW_RLE_offset_pair ]: 0x00000002, 0x00000008 => [0x00000042, 0x00000048)
132136
# CHECK-NEXT: [DW_RLE_base_address ]: 0xffffffff
@@ -146,6 +150,8 @@
146150
# CHECK-NEXT: [DW_RLE_startx_length]: 0x0000000000000001, 0x0000000000000006
147151
# CHECK-NEXT: [DW_RLE_start_end ]: [0xffffffffffffffff, 0xffffffffffffffff)
148152
# CHECK-NEXT: [DW_RLE_start_end ]: [0x0000000000000042, 0x0000000000000048)
153+
# CHECK-NEXT: [DW_RLE_startx_endx ]: 0x0000000000000000, 0x0000000000000000
154+
# CHECK-NEXT: [DW_RLE_startx_endx ]: 0x0000000000000001, 0x0000000000000001
149155
# CHECK-NEXT: [DW_RLE_base_address ]: 0x0000000000000040
150156
# CHECK-NEXT: [DW_RLE_offset_pair ]: 0x0000000000000002, 0x0000000000000008 => [0x0000000000000042, 0x0000000000000048)
151157
# CHECK-NEXT: [DW_RLE_base_address ]: 0xffffffffffffffff
@@ -304,13 +310,12 @@
304310
.byte 6 # DW_RLE_start_end
305311
.long 0x42 # start address
306312
.long 0x48 # length
307-
# FIXME: RLE_startx_endx unsupported by llvm-dwarfdump
308-
# .byte 2 # DW_RLE_startx_endx
309-
# .uleb128 0 # start address
310-
# .uleb128 0 # length
311-
# .byte 2 # DW_RLE_startx_endx
312-
# .uleb128 1 # start address
313-
# .uleb128 1 # length
313+
.byte 2 # DW_RLE_startx_endx
314+
.uleb128 0 # start index
315+
.uleb128 0 # end index
316+
.byte 2 # DW_RLE_startx_endx
317+
.uleb128 1 # start index
318+
.uleb128 1 # end index
314319
.byte 5 # DW_RLE_base_address
315320
.long 0x40 # address
316321
.byte 4 # DW_RLE_offset_pair
@@ -358,13 +363,12 @@
358363
.byte 6 # DW_RLE_start_end
359364
.quad 0x42 # start address
360365
.quad 0x48 # length
361-
# FIXME: RLE_startx_endx unsupported by llvm-dwarfdump
362-
# .byte 2 # DW_RLE_startx_endx
363-
# .uleb128 0 # start address
364-
# .uleb128 0 # length
365-
# .byte 2 # DW_RLE_startx_endx
366-
# .uleb128 1 # start address
367-
# .uleb128 1 # length
366+
.byte 2 # DW_RLE_startx_endx
367+
.uleb128 0 # start index
368+
.uleb128 0 # end index
369+
.byte 2 # DW_RLE_startx_endx
370+
.uleb128 1 # start index
371+
.uleb128 1 # end index
368372
.byte 5 # DW_RLE_base_address
369373
.quad 0x40 # address
370374
.byte 4 # DW_RLE_offset_pair

0 commit comments

Comments
 (0)