Add PR check to suggest alternatives to using undef (#118506)
[llvm-project.git] / llvm / test / tools / llvm-dwarfutil / ELF / X86 / dwarf5-rnglists.test
blob3f55d687474a7662d4f8cec0fce7cc14f2e1162b
1 ## Test that DWARFv5 .debug_rnglists is correctly recognized
2 ## and converted into the DW_FORM_sec_offset form in --garbage-collection
3 ## case or correctly preserved in --no-garbage-collection case.
5 # RUN: yaml2obj %s -o %t.o
7 # RUN: llvm-dwarfutil %t.o %t1
8 # RUN: llvm-dwarfdump -verify %t1 | FileCheck %s
9 # RUN: llvm-dwarfdump -a --verbose %t1 | FileCheck %s --check-prefix DWARF-CHECK
11 # RUN: llvm-dwarfutil --linker parallel %t.o %t1
12 # RUN: llvm-dwarfdump -verify %t1 | FileCheck %s
13 # RUN: llvm-dwarfdump -a --verbose %t1 | FileCheck %s --check-prefix DWARF-CHECK
15 # RUN: llvm-dwarfutil --no-garbage-collection %t.o %t1
16 # RUN: llvm-dwarfdump -verify %t1 | FileCheck %s
17 # RUN: llvm-dwarfdump -a --verbose %t1 | FileCheck %s --check-prefix UPD-DWARF-CHECK
19 # RUN: llvm-dwarfutil --linker parallel --no-garbage-collection %t.o %t1
20 # RUN: llvm-dwarfdump -verify %t1 | FileCheck %s
21 # RUN: llvm-dwarfdump -a --verbose %t1 | FileCheck %s --check-prefix UPD-DWARF-CHECK
23 # RUN: llvm-dwarfutil --no-garbage-collection --build-accelerator=DWARF %t.o %t1
24 # RUN: llvm-dwarfdump -verify %t1 | FileCheck %s
25 # RUN: llvm-dwarfdump -a --verbose %t1 | FileCheck %s --check-prefix UPD-DWARF-CHECK
27 # RUN: llvm-dwarfutil --linker parallel --no-garbage-collection --build-accelerator=DWARF %t.o %t1
28 # RUN: llvm-dwarfdump -verify %t1 | FileCheck %s
29 # RUN: llvm-dwarfdump -a --verbose %t1 | FileCheck %s --check-prefix UPD-DWARF-CHECK
31 #CHECK: No errors.
33 #DWARF-CHECK: DW_TAG_compile_unit
34 #DWARF-CHECK:   DW_AT_name [DW_FORM_strx]  {{.*}}     "CU1"
35 #DWARF-CHECK:   DW_AT_low_pc [DW_FORM_addrx]      (indexed (00000000) address = 0x0000000000001130)
36 #DWARF-CHECK:   DW_AT_ranges [DW_FORM_sec_offset] (0x[[CURANGE_OFF:[0-9a-f]*]]
37 #DWARF-CHECK:   [0x0000000000001130, 0x0000000000001170))
38 #DWARF-CHECK:   DW_AT_str_offsets_base [DW_FORM_sec_offset]
39 #DWARF-CHECK:   DW_TAG_subprogram
40 #DWARF-CHECK:     DW_AT_name  [DW_FORM_strx] {{.*}}   "foo1"
41 #DWARF-CHECK:     DW_AT_low_pc [DW_FORM_addrx]    (indexed (00000000) address = 0x0000000000001130)
42 #DWARF-CHECK:     DW_AT_high_pc [DW_FORM_data8]   (0x0000000000000010)
43 #DWARF-CHECK:     DW_TAG_lexical_block
44 #DWARF-CHECK:       DW_AT_ranges [DW_FORM_sec_offset]     (0x[[F1RANGE_OFF:[0-9a-f]*]]
45 #DWARF-CHECK:       [0x0000000000001130, 0x0000000000001140))
46 #DWARF-CHECK:   DW_TAG_subprogram
47 #DWARF-CHECK:     DW_AT_name  [DW_FORM_strx] {{.*}}   "foo2"
48 #DWARF-CHECK:     DW_AT_low_pc [DW_FORM_addrx]    (indexed (00000001) address = 0x0000000000001140)
49 #DWARF-CHECK:     DW_AT_high_pc [DW_FORM_data8]   (0x0000000000000010)
50 #DWARF-CHECK:     DW_TAG_lexical_block
51 #DWARF-CHECK:       DW_AT_ranges [DW_FORM_sec_offset]     (0x[[F2RANGE_OFF:[0-9a-f]*]]
52 #DWARF-CHECK:            [0x0000000000001140, 0x0000000000001150))
53 #DWARF-CHECK:   DW_TAG_subprogram
54 #DWARF-CHECK:     DW_AT_name  [DW_FORM_strx] {{.*}}   "foo3"
55 #DWARF-CHECK:     DW_AT_low_pc [DW_FORM_addrx]    (indexed (00000002) address = 0x0000000000001150)
56 #DWARF-CHECK:     DW_AT_high_pc [DW_FORM_data8]   (0x0000000000000010)
57 #DWARF-CHECK:     DW_TAG_lexical_block
58 #DWARF-CHECK:       DW_AT_ranges [DW_FORM_sec_offset]     (0x[[F3RANGE_OFF:[0-9a-f]*]]
59 #DWARF-CHECK:          [0x0000000000001150, 0x0000000000001160))
60 #DWARF-CHECK:   DW_TAG_subprogram
61 #DWARF-CHECK:     DW_AT_name  [DW_FORM_strx] {{.*}}   "foo4"
62 #DWARF-CHECK:     DW_AT_low_pc [DW_FORM_addrx]    (indexed (00000003) address = 0x0000000000001160)
63 #DWARF-CHECK:     DW_AT_high_pc [DW_FORM_data8]   (0x0000000000000010)
64 #DWARF-CHECK:     DW_TAG_lexical_block
65 #DWARF-CHECK:       DW_AT_ranges [DW_FORM_sec_offset]     (0x[[F4RANGE_OFF:[0-9a-f]*]]
66 #DWARF-CHECK:          [0x0000000000001160, 0x0000000000001170))
67 #DWARF-CHECK: .debug_aranges contents:
68 #DWARF-CHECK: Address Range Header: length = 0x0000002c, format = DWARF32, version = 0x0002, cu_offset = 0x000000{{00|21}}, addr_size = 0x08, seg_size = 0x00
69 #DWARF-CHECK: [0x0000000000001130, 0x0000000000001170)
70 #DWARF-CHECK: .debug_addr contents:
71 #DWARF-CHECK: 0x00000000: Address table header: length = 0x00000024, format = DWARF32, version = 0x0005, addr_size = 0x08, seg_size = 0x00
72 #DWARF-CHECK: Addrs: [
73 #DWARF-CHECK: 0x0000000000001130
74 #DWARF-CHECK: 0x0000000000001140
75 #DWARF-CHECK: 0x0000000000001150
76 #DWARF-CHECK: 0x0000000000001160
77 #DWARF-CHECK: ]
78 #DWARF-CHECK: .debug_rnglists contents:
79 #DWARF-CHECK: 0x00000000: range list header: length = 0x00000026, format = DWARF32, version = 0x0005, addr_size = 0x08, seg_size = 0x00, offset_entry_count = 0x00000000
80 #DWARF-CHECK: ranges:
81 #DWARF-CHECK: 0x[[F1RANGE_OFF]]: [DW_RLE_base_addressx]:  0x0000000000000000
82 #DWARF-CHECK: {{.}}: [DW_RLE_offset_pair  ]:  0x0000000000000000, 0x0000000000000010
83 #DWARF-CHECK: {{.}}: [DW_RLE_end_of_list  ]
84 #DWARF-CHECK: 0x[[F2RANGE_OFF]]: [DW_RLE_base_addressx]:  0x0000000000000001
85 #DWARF-CHECK: {{.}}: [DW_RLE_offset_pair  ]:  0x0000000000000000, 0x0000000000000010
86 #DWARF-CHECK: {{.}}: [DW_RLE_end_of_list  ]
87 #DWARF-CHECK: 0x[[F3RANGE_OFF]]: [DW_RLE_base_addressx]:  0x0000000000000002
88 #DWARF-CHECK: {{.}}: [DW_RLE_offset_pair  ]:  0x0000000000000000, 0x0000000000000010
89 #DWARF-CHECK: {{.}}: [DW_RLE_end_of_list  ]
90 #DWARF-CHECK: 0x[[F4RANGE_OFF]]: [DW_RLE_base_addressx]:  0x0000000000000003
91 #DWARF-CHECK: {{.}}: [DW_RLE_offset_pair  ]:  0x0000000000000000, 0x0000000000000010
92 #DWARF-CHECK: {{.}}: [DW_RLE_end_of_list  ]
93 #DWARF-CHECK 0x[[CURANGE_OFF]]: [DW_RLE_base_addressx]:  0x0000000000000000
94 #DWARF-CHECK: {{.}}: [DW_RLE_offset_pair  ]:  0x0000000000000000, 0x0000000000000040
95 #DWARF-CHECK: {{.}}: [DW_RLE_end_of_list  ]
97 #UPD-DWARF-CHECK: DW_TAG_compile_unit
98 #UPD-DWARF-CHECK:   DW_AT_name {{.*}}"CU1"
99 #UPD-DWARF-CHECK:   DW_AT_low_pc [DW_FORM_addrx]      (indexed (00000000) address = 0x0000000000001130)
100 #UPD-DWARF-CHECK:   DW_AT_ranges [DW_FORM_rnglistx] (indexed (0x4) rangelist = 0x0000003e
101 #UPD-DWARF-CHECK:      [0x0000000000001130, 0x0000000000001170))
102 #UPD-DWARF-CHECK:   DW_TAG_subprogram
103 #UPD-DWARF-CHECK:     DW_AT_name  {{.*}}"foo1"
104 #UPD-DWARF-CHECK:     DW_AT_low_pc [DW_FORM_addrx]   (indexed (00000000) address = 0x0000000000001130) 
105 #UPD-DWARF-CHECK:     DW_AT_high_pc [DW_FORM_data8]   (0x0000000000000010)
106 #UPD-DWARF-CHECK:     DW_TAG_lexical_block
107 #UPD-DWARF-CHECK:     DW_AT_ranges [DW_FORM_rnglistx]       (indexed (0x0) rangelist = 0x00000020
108 #UPD-DWARF-CHECK:        [0x0000000000001130, 0x0000000000001140))
109 #UPD-DWARF-CHECK:   DW_TAG_subprogram
110 #UPD-DWARF-CHECK:     DW_AT_name  {{.*}}"foo2"
111 #UPD-DWARF-CHECK:     DW_AT_low_pc [DW_FORM_addrx]   (indexed (00000001) address = 0x0000000000001140) 
112 #UPD-DWARF-CHECK:     DW_AT_high_pc [DW_FORM_data8]   (0x0000000000000010)
113 #UPD-DWARF-CHECK:     DW_TAG_lexical_block
114 #UPD-DWARF-CHECK:     DW_AT_ranges [DW_FORM_rnglistx]       (indexed (0x1) rangelist = 0x00000024
115 #UPD-DWARF-CHECK:     [0x0000000000001140, 0x0000000000001150))
116 #UPD-DWARF-CHECK:   DW_TAG_subprogram
117 #UPD-DWARF-CHECK:     DW_AT_name  {{.*}}"foo3"
118 #UPD-DWARF-CHECK:     DW_AT_low_pc [DW_FORM_addrx]   (indexed (00000002) address = 0x0000000000001150) 
119 #UPD-DWARF-CHECK:     DW_AT_high_pc [DW_FORM_data8]   (0x0000000000000010)
120 #UPD-DWARF-CHECK:     DW_TAG_lexical_block
121 #UPD-DWARF-CHECK:     DW_AT_ranges [DW_FORM_sec_offset]     (0x00000028
122 #UPD-DWARF-CHECK:        [0x0000000000001150, 0x0000000000001160))
123 #UPD-DWARF-CHECK:   DW_TAG_subprogram
124 #UPD-DWARF-CHECK:     DW_AT_name  {{.*}}"foo4"
125 #UPD-DWARF-CHECK:     DW_AT_low_pc [DW_FORM_addrx]   (indexed (00000003) address = 0x0000000000001160)
126 #UPD-DWARF-CHECK:     DW_AT_high_pc [DW_FORM_data8]   (0x0000000000000010)
127 #UPD-DWARF-CHECK:     DW_TAG_lexical_block
128 #UPD-DWARF-CHECK:     DW_AT_ranges [DW_FORM_sec_offset]     (0x00000033
129 #UPD-DWARF-CHECK:        [0x0000000000001160, 0x0000000000001170))
130 #UPD-DWARF-CHECK: .debug_addr contents:
131 #UPD-DWARF-CHECK: 0x00000000: Address table header: length = 0x00000024, format = DWARF32, version = 0x0005, addr_size = 0x08, seg_size = 0x00
132 #UPD-DWARF-CHECK: Addrs: [
133 #UPD-DWARF-CHECK: 0x0000000000001130
134 #UPD-DWARF-CHECK: 0x0000000000001140
135 #UPD-DWARF-CHECK: 0x0000000000001150
136 #UPD-DWARF-CHECK: 0x0000000000001160
137 #UPD-DWARF-CHECK: ]
138 #UPD-DWARF-CHECK: .debug_rnglists contents:
139 #UPD-DWARF-CHECK: 0x00000000: range list header: length = 0x0000003e, format = DWARF32, version = 0x0005, addr_size = 0x08, seg_size = 0x00, offset_entry_count = 0x00000005
140 #UPD-DWARF-CHECK: offsets: [
141 #UPD-DWARF-CHECK: 0x00000014 => 0x00000020
142 #UPD-DWARF-CHECK: 0x00000018 => 0x00000024
143 #UPD-DWARF-CHECK: 0x0000001c => 0x00000028
144 #UPD-DWARF-CHECK: 0x00000027 => 0x00000033
145 #UPD-DWARF-CHECK: 0x00000032 => 0x0000003e
146 #UPD-DWARF-CHECK: ]
147 #UPD-DWARF-CHECK: ranges:
148 #UPD-DWARF-CHECK: 0x00000020: [DW_RLE_startx_length]:  0x0000000000000000, 0x0000000000000010
149 #UPD-DWARF-CHECK: 0x00000023: [DW_RLE_end_of_list  ]
150 #UPD-DWARF-CHECK: 0x00000024: [DW_RLE_startx_length]:  0x0000000000000001, 0x0000000000000010
151 #UPD-DWARF-CHECK: 0x00000027: [DW_RLE_end_of_list  ]
152 #UPD-DWARF-CHECK: 0x00000028: [DW_RLE_start_length ]:  0x0000000000001150, 0x0000000000000010
153 #UPD-DWARF-CHECK: 0x00000032: [DW_RLE_end_of_list  ]
154 #UPD-DWARF-CHECK: 0x00000033: [DW_RLE_start_length ]:  0x0000000000001160, 0x0000000000000010
155 #UPD-DWARF-CHECK: 0x0000003d: [DW_RLE_end_of_list  ]
156 #UPD-DWARF-CHECK: 0x0000003e: [DW_RLE_startx_length]:  0x0000000000000000, 0x0000000000000040
157 #UPD-DWARF-CHECK: 0x00000041: [DW_RLE_end_of_list  ]
159 ## Following yaml description has Content of the .debug_rnglists exactly like above data ^^^^^^
160 --- !ELF
161 FileHeader:
162   Class:    ELFCLASS64
163   Data:     ELFDATA2LSB
164   Type:     ET_REL
165   Machine:  EM_X86_64
166 Sections:
167   - Name:            .text
168     Type:            SHT_PROGBITS
169     Flags:           [ SHF_ALLOC, SHF_EXECINSTR ]
170     Address:         0x1130
171     Size:            0x70
172   - Name:            .debug_rnglists
173     Type:            SHT_PROGBITS
174     Flags:           [  ]
175     Content:        "3e000000050008000500000014000000180000001c000000270000003200000003001000030110000750110000000000001000076011000000000000100003004000"
176 DWARF:
177   debug_abbrev:
178     - Table:
179       - Tag:      DW_TAG_compile_unit
180         Children: DW_CHILDREN_yes
181         Attributes:
182           - Attribute: DW_AT_producer
183             Form:      DW_FORM_string
184           - Attribute: DW_AT_language
185             Form:      DW_FORM_data2
186           - Attribute: DW_AT_name
187             Form:      DW_FORM_string
188           - Attribute: DW_AT_low_pc
189             Form:      DW_FORM_addrx
190           - Attribute: DW_AT_ranges
191             Form:      DW_FORM_rnglistx 
192           - Attribute: DW_AT_rnglists_base
193             Form:      DW_FORM_sec_offset
194           - Attribute: DW_AT_addr_base
195             Form:      DW_FORM_sec_offset
196       - Tag:      DW_TAG_subprogram
197         Children: DW_CHILDREN_yes
198         Attributes:
199           - Attribute: DW_AT_name
200             Form:      DW_FORM_string
201           - Attribute: DW_AT_low_pc
202             Form:      DW_FORM_addrx 
203           - Attribute: DW_AT_high_pc
204             Form:      DW_FORM_data8
205           - Attribute: DW_AT_type
206             Form:      DW_FORM_ref4
207       - Tag:      DW_TAG_lexical_block
208         Children: DW_CHILDREN_no
209         Attributes:
210           - Attribute: DW_AT_ranges
211             Form:      DW_FORM_rnglistx
212       - Tag:      DW_TAG_lexical_block
213         Children: DW_CHILDREN_no
214         Attributes:
215           - Attribute: DW_AT_ranges    
216             Form:      DW_FORM_sec_offset 
217       - Tag:      DW_TAG_base_type
218         Children: DW_CHILDREN_no
219         Attributes:
220           - Attribute: DW_AT_name
221             Form:      DW_FORM_string
222   debug_info:
223     - Version: 5
224       UnitType:   DW_UT_compile
225       Entries:
226         - AbbrCode: 1
227           Values:
228             - CStr: by_hand
229             - Value:  0x04
230             - CStr: CU1
231             - Value:  0x0
232             - Value:  0x4
233             - Value:  0xc
234             - Value:  0x8
235         - AbbrCode: 2
236           Values:
237             - CStr: foo1
238             - Value: 0x00
239             - Value: 0x10
240             - Value: 0x83
241         - AbbrCode: 3
242           Values:
243             - Value: 0x00
244         - AbbrCode: 0
245         - AbbrCode: 2
246           Values:
247             - CStr: foo2
248             - Value: 0x01
249             - Value: 0x10
250             - Value: 0x83
251         - AbbrCode: 3
252           Values:
253             - Value: 0x01
254         - AbbrCode: 0
255         - AbbrCode: 2
256           Values:
257             - CStr: foo3
258             - Value: 0x02
259             - Value: 0x10
260             - Value: 0x83
261         - AbbrCode: 4
262           Values:
263             - Value: 0x28
264         - AbbrCode: 0
265         - AbbrCode: 2
266           Values:
267             - CStr: foo4
268             - Value: 0x03
269             - Value: 0x10
270             - Value: 0x83
271         - AbbrCode: 4
272           Values:
273             - Value: 0x33
274         - AbbrCode: 0
275         - AbbrCode: 5
276           Values:
277             - CStr: int
278         - AbbrCode: 0
279   debug_addr:
280     - Version: 5
281       AddressSize: 0x08
282       Entries:
283         - Address: 0x1130
284         - Address: 0x1140
285         - Address: 0x1150
286         - Address: 0x1160