1 # This test verifies that if a DW_TAG_compile_unit has DW_AT_ranges that
2 # overlap, that it doesn't end up producing invalid errors claiming a child
3 # DW_TAG_subprogram DIE is not in the parant (CU) ranges. Prior to the commit
4 # that fixed this, a loop was iterating over all DW_AT_ranges for a DIE and
5 # stopping the loop if any intersecting ranges were found. This would cause
6 # the DW_TAG_subprogram DIEs, like "stripped2" and "main", to improperly report
7 # that they were not contained in the parent's address ranges
9 # The DWARF looks like:
10 # 0x0000000b: DW_TAG_compile_unit
11 # DW_AT_name ("/tmp/main.c")
12 # DW_AT_language (DW_LANG_C)
13 # DW_AT_low_pc (0x0000000000000000)
14 # DW_AT_ranges (0x00000000
15 # [0x0000000000002000, 0x0000000000003000)
16 # [0x0000000000000000, 0x0000000000000020)
17 # [0x0000000000000000, 0x0000000000000030)
18 # [0x0000000000001000, 0x0000000000002000))
20 # 0x0000001e: DW_TAG_subprogram
21 # DW_AT_name ("stripped1")
22 # DW_AT_low_pc (0x0000000000000000)
23 # DW_AT_high_pc (0x0000000000000020)
25 # 0x0000002f: DW_TAG_subprogram
26 # DW_AT_name ("stripped2")
27 # DW_AT_low_pc (0x0000000000000000)
28 # DW_AT_high_pc (0x0000000000000030)
30 # 0x00000044: DW_TAG_subprogram
32 # DW_AT_low_pc (0x0000000000001000)
33 # DW_AT_high_pc (0x0000000000002000)
35 # 0x00000055: DW_TAG_subprogram
37 # DW_AT_low_pc (0x0000000000002000)
38 # DW_AT_high_pc (0x0000000000003000)
42 # RUN: yaml2obj %s | not llvm-dwarfdump --verify - | FileCheck %s --implicit-check-not=error:
44 # CHECK: error: DIE has overlapping ranges in DW_AT_ranges attribute: [0x0000000000000000, 0x0000000000000020) and [0x0000000000000000, 0x0000000000000030)
46 # CHECK: 0x0000000b: DW_TAG_compile_unit
47 # CHECK-NEXT: DW_AT_name [DW_FORM_strp] ( .debug_str[0x00000001] = "/tmp/main.c")
48 # CHECK-NEXT: DW_AT_language [DW_FORM_data2] (DW_LANG_C)
49 # CHECK-NEXT: DW_AT_low_pc [DW_FORM_addr] (0x0000000000000000)
50 # CHECK-NEXT: DW_AT_ranges [DW_FORM_sec_offset] (0x00000000
51 # CHECK-NEXT: [0x0000000000002000, 0x0000000000003000)
52 # CHECK-NEXT: [0x0000000000000000, 0x0000000000000020)
53 # CHECK-NEXT: [0x0000000000000000, 0x0000000000000030)
54 # CHECK-NEXT: [0x0000000000001000, 0x0000000000002000))
56 # CHECK: error: DIEs have overlapping address ranges:
57 # CHECK: 0x0000002f: DW_TAG_subprogram
58 # CHECK-NEXT: DW_AT_name [DW_FORM_strp] ( .debug_str[0x00000017] = "stripped2")
59 # CHECK-NEXT: DW_AT_low_pc [DW_FORM_addr] (0x0000000000000000)
60 # CHECK-NEXT: DW_AT_high_pc [DW_FORM_addr] (0x0000000000000030)
62 # CHECK: 0x0000001e: DW_TAG_subprogram
63 # CHECK-NEXT: DW_AT_name [DW_FORM_strp] ( .debug_str[0x0000000d] = "stripped1")
64 # CHECK-NEXT: DW_AT_low_pc [DW_FORM_addr] (0x0000000000000000)
65 # CHECK-NEXT: DW_AT_high_pc [DW_FORM_data4] (0x00000020)
71 cpusubtype: 0x00000003
90 - sectname: __debug_abbrev
92 addr: 0x0000000000000000
100 reserved2: 0x00000000
101 reserved3: 0x00000000
102 - sectname: __debug_info
104 addr: 0x0000000000000024
111 reserved1: 0x00000000
112 reserved2: 0x00000000
113 reserved3: 0x00000000
114 - sectname: __debug_ranges
116 addr: 0x000000000000008B
123 reserved1: 0x00000000
124 reserved2: 0x00000000
125 reserved3: 0x00000000
126 - sectname: __debug_str
128 addr: 0x00000000000000DB
135 reserved1: 0x00000000
136 reserved2: 0x00000000
137 reserved3: 0x00000000
144 - cmd: LC_BUILD_VERSION
153 - cmd: LC_DATA_IN_CODE
177 Tag: DW_TAG_compile_unit
178 Children: DW_CHILDREN_yes
180 - Attribute: DW_AT_name
182 - Attribute: DW_AT_language
184 - Attribute: DW_AT_low_pc
186 - Attribute: DW_AT_ranges
187 Form: DW_FORM_sec_offset
189 Tag: DW_TAG_subprogram
190 Children: DW_CHILDREN_no
192 - Attribute: DW_AT_name
194 - Attribute: DW_AT_low_pc
196 - Attribute: DW_AT_high_pc
199 Tag: DW_TAG_subprogram
200 Children: DW_CHILDREN_no
202 - Attribute: DW_AT_name
204 - Attribute: DW_AT_low_pc
206 - Attribute: DW_AT_high_pc
212 - LowOffset: 0x0000000000002000
213 HighOffset: 0x0000000000003000
214 - LowOffset: 0x0000000000000000
215 HighOffset: 0x0000000000000020
216 - LowOffset: 0x0000000000000000
217 HighOffset: 0x0000000000000030
218 - LowOffset: 0x0000000000001000
219 HighOffset: 0x0000000000002000
224 - AbbrCode: 0x00000001
226 - Value: 0x0000000000000001
227 - Value: 0x0000000000000002
228 - Value: 0x0000000000000000
229 - Value: 0x0000000000000000
230 - AbbrCode: 0x00000002
232 - Value: 0x000000000000000D
233 - Value: 0x0000000000000000
234 - Value: 0x0000000000000020
235 - AbbrCode: 0x00000003
237 - Value: 0x0000000000000017
238 - Value: 0x0000000000000000
239 - Value: 0x0000000000000030
240 - AbbrCode: 0x00000002
242 - Value: 0x0000000000000021
243 - Value: 0x0000000000001000
244 - Value: 0x0000000000001000
245 - AbbrCode: 0x00000002
247 - Value: 0x0000000000000026
248 - Value: 0x0000000000002000
249 - Value: 0x0000000000001000
250 - AbbrCode: 0x00000000