[Frontend] Remove unused includes (NFC) (#116927)
[llvm-project.git] / llvm / test / tools / llvm-dwarfutil / ELF / X86 / dwarf5-addresses.test
bloba051137248b85ce17b3e2319b56eb565adcf1393
1 ## Test that DWARFv5 address attributes and address expression operands
2 ## are handled correctly, specifically:
3 ## 1. DW_FORM_addrx is correctly recognized and converted into the DW_FORM_addr
4 ##    in --garbage-collection case or correctly preserved in --no-garbage-collection case.
5 ## 2. DW_OP_addrx is correctly recognized and converted into the DW_OP_addr
6 ##    in --garbage-collection case or correctly preserved in --no-garbage-collection case.
7 ## 3. DW_OP_constx is correctly recognized and converted into the DW_OP_const[*]u
8 ##    in --garbage-collection case or correctly preserved in --no-garbage-collection case.
10 # RUN: yaml2obj %s -o %t.o
12 # RUN: llvm-dwarfutil %t.o %t1
13 # RUN: llvm-dwarfdump -verify %t1 | FileCheck %s
14 # RUN: llvm-dwarfdump -a --verbose %t1 | FileCheck %s --check-prefix DWARF-CHECK
16 # RUN: llvm-dwarfutil --linker parallel %t.o %t1
17 # RUN: llvm-dwarfdump -verify %t1 | FileCheck %s
18 # RUN: llvm-dwarfdump -a --verbose %t1 | FileCheck %s --check-prefix DWARF-CHECK
20 # RUN: llvm-dwarfutil --no-garbage-collection %t.o %t1
21 # RUN: llvm-dwarfdump -verify %t1 | FileCheck %s
22 # RUN: llvm-dwarfdump -a --verbose %t1 | FileCheck %s --check-prefix UPD-DWARF-CHECK
24 # RUN: llvm-dwarfutil --linker parallel --no-garbage-collection %t.o %t1
25 # RUN: llvm-dwarfdump -verify %t1 | FileCheck %s
26 # RUN: llvm-dwarfdump -a --verbose %t1 | FileCheck %s --check-prefix UPD-DWARF-CHECK
28 # RUN: llvm-dwarfutil --no-garbage-collection --build-accelerator=DWARF %t.o %t1
29 # RUN: llvm-dwarfdump -verify %t1 | FileCheck %s
30 # RUN: llvm-dwarfdump -a --verbose %t1 | FileCheck %s --check-prefix UPD-DWARF-CHECK
32 # RUN: llvm-dwarfutil --linker parallel --no-garbage-collection --build-accelerator=DWARF %t.o %t1
33 # RUN: llvm-dwarfdump -verify %t1 | FileCheck %s
34 # RUN: llvm-dwarfdump -a --verbose %t1 | FileCheck %s --check-prefix UPD-DWARF-CHECK
36 #CHECK: No errors.
38 #DWARF-CHECK: DW_TAG_compile_unit
39 #DWARF-CHECK:   DW_AT_name [DW_FORM_strx]  {{.*}}     "CU1"
40 #DWARF-CHECK:   DW_AT_low_pc [DW_FORM_addrx]      (indexed (00000000) address = 0x0000000000001130)
41 #DWARF-CHECK:   DW_AT_high_pc [DW_FORM_data8]   (0x0000000000000060)
42 #DWARF-CHECK:   DW_AT_str_offsets_base [DW_FORM_sec_offset]
43 #DWARF-CHECK:   DW_TAG_subprogram
44 #DWARF-CHECK:     DW_AT_name  [DW_FORM_strx] {{.*}}   "foo1"
45 #DWARF-CHECK:     DW_AT_low_pc [DW_FORM_addrx]    (indexed (00000000) address = 0x0000000000001130)
46 #DWARF-CHECK:     DW_AT_high_pc [DW_FORM_data8]   (0x0000000000000010)
47 #DWARF-CHECK:   DW_TAG_subprogram
48 #DWARF-CHECK:     DW_AT_name  [DW_FORM_strx] {{.*}}   "foo2"
49 #DWARF-CHECK:     DW_AT_low_pc [DW_FORM_addrx]    (indexed (00000001) address = 0x0000000000001140)
50 #DWARF-CHECK:     DW_AT_high_pc [DW_FORM_data8]   (0x0000000000000010)
51 #DWARF-CHECK:   DW_TAG_subprogram
52 #DWARF-CHECK:     DW_AT_name  [DW_FORM_strx] {{.*}}   "foo3"
53 #DWARF-CHECK:     DW_AT_low_pc [DW_FORM_addrx]    (indexed (00000002) address = 0x0000000000001150)
54 #DWARF-CHECK:     DW_AT_high_pc [DW_FORM_data8]   (0x0000000000000010)
55 #DWARF-CHECK:   DW_TAG_subprogram
56 #DWARF-CHECK:     DW_AT_name  [DW_FORM_strx] {{.*}}   "foo4"
57 #DWARF-CHECK:     DW_AT_low_pc [DW_FORM_addrx]   (indexed (00000003) address = 0x0000000000001160)
58 #DWARF-CHECK:     DW_AT_high_pc [DW_FORM_data8]   (0x0000000000000010)
59 #DWARF-CHECK:   DW_TAG_subprogram
60 #DWARF-CHECK:     DW_AT_name  [DW_FORM_strx] {{.*}}   "foo5"
61 #DWARF-CHECK:     DW_AT_low_pc [DW_FORM_addrx]   (indexed (00000004) address = 0x0000000000001170)
62 #DWARF-CHECK:     DW_AT_high_pc [DW_FORM_data8]   (0x0000000000000010)
63 #DWARF-CHECK:   DW_TAG_subprogram
64 #DWARF-CHECK:     DW_AT_name  [DW_FORM_strx] {{.*}}   "foo6"
65 #DWARF-CHECK:     DW_AT_low_pc [DW_FORM_addrx]   (indexed (00000005) address = 0x0000000000001180)
66 #DWARF-CHECK:     DW_AT_high_pc [DW_FORM_data8]   (0x0000000000000010)
67 #DWARF-CHECK:   DW_TAG_variable
68 #DWARF-CHECK:     DW_AT_name  [DW_FORM_strx] {{.*}}   "var1"
69 #DWARF-CHECK:     DW_AT_location [DW_FORM_exprloc] (DW_OP_addr 0x2000)
70 #DWARF-CHECK:   DW_TAG_variable
71 #DWARF-CHECK:     DW_AT_name  [DW_FORM_strx] {{.*}}   "var2"
72 #DWARF-CHECK:     DW_AT_location [DW_FORM_exprloc] (DW_OP_addr 0x2000)
73 #DWARF-CHECK:   DW_TAG_variable
74 #DWARF-CHECK:     DW_AT_name [DW_FORM_strx]  {{.*}}   "var3"
75 #DWARF-CHECK:     DW_AT_location [DW_FORM_exprloc] (DW_OP_const8u 0x2000, DW_OP_form_tls_address)
76 #DWARF-CHECK:   DW_TAG_variable
77 #DWARF-CHECK:     DW_AT_name [DW_FORM_strx]  {{.*}}   "var4"
78 #DWARF-CHECK:     DW_AT_location [DW_FORM_exprloc] (DW_OP_const8u 0x2000, DW_OP_form_tls_address)
79 #DWARF-CHECK=NOT: .debug_addr contents:
81 #UPD-DWARF-CHECK: DW_TAG_compile_unit
82 #UPD-DWARF-CHECK:   DW_AT_name {{.*}}"CU1"
83 #UPD-DWARF-CHECK:   DW_AT_low_pc [DW_FORM_addrx]   (indexed (00000000) address = 0x0000000000001130)
84 #UPD-DWARF-CHECK:   DW_AT_high_pc [DW_FORM_data8]   (0x0000000000000060)
85 #UPD-DWARF-CHECK:   DW_TAG_subprogram
86 #UPD-DWARF-CHECK:     DW_AT_name  {{.*}}"foo1"
87 #UPD-DWARF-CHECK:     DW_AT_low_pc [DW_FORM_addrx]   (indexed (00000000) address = 0x0000000000001130)
88 #UPD-DWARF-CHECK:     DW_AT_high_pc [DW_FORM_data8]   (0x0000000000000010)
89 #UPD-DWARF-CHECK:   DW_TAG_subprogram
90 #UPD-DWARF-CHECK:     DW_AT_name  {{.*}}"foo2"
91 #UPD-DWARF-CHECK:     DW_AT_low_pc [DW_FORM_addrx]   (indexed (00000001) address = 0x0000000000001140)
92 #UPD-DWARF-CHECK:     DW_AT_high_pc [DW_FORM_data8]   (0x0000000000000010)
93 #UPD-DWARF-CHECK:   DW_TAG_subprogram
94 #UPD-DWARF-CHECK:     DW_AT_name  {{.*}}"foo3"
95 #UPD-DWARF-CHECK:     DW_AT_low_pc [DW_FORM_addrx]   (indexed (00000002) address = 0x0000000000001150)
96 #UPD-DWARF-CHECK:     DW_AT_high_pc [DW_FORM_data8]   (0x0000000000000010)
97 #UPD-DWARF-CHECK:   DW_TAG_subprogram
98 #UPD-DWARF-CHECK:     DW_AT_name  {{.*}}"foo4"
99 #UPD-DWARF-CHECK:     DW_AT_low_pc [DW_FORM_addrx1]   (indexed (00000003) address = 0x0000000000001160)
100 #UPD-DWARF-CHECK:     DW_AT_high_pc [DW_FORM_data8]   (0x0000000000000010)
101 #UPD-DWARF-CHECK:   DW_TAG_subprogram
102 #UPD-DWARF-CHECK:     DW_AT_name  {{.*}}"foo5"
103 #UPD-DWARF-CHECK:     DW_AT_low_pc [DW_FORM_addrx2]   (indexed (00000004) address = 0x0000000000001170)
104 #UPD-DWARF-CHECK:     DW_AT_high_pc [DW_FORM_data8]   (0x0000000000000010)
105 #UPD-DWARF-CHECK:   DW_TAG_subprogram
106 #UPD-DWARF-CHECK:     DW_AT_name  {{.*}}"foo6"
107 #UPD-DWARF-CHECK:     DW_AT_low_pc [DW_FORM_addrx4]   (indexed (00000005) address = 0x0000000000001180)
108 #UPD-DWARF-CHECK:     DW_AT_high_pc [DW_FORM_data8]   (0x0000000000000010)
109 #UPD-DWARF-CHECK:   DW_TAG_variable
110 #UPD-DWARF-CHECK:     DW_AT_name  {{.*}}"var1"
111 #UPD-DWARF-CHECK:     DW_AT_location [DW_FORM_exprloc]        (DW_OP_addrx 0x6)
112 #UPD-DWARF-CHECK:   DW_TAG_variable
113 #UPD-DWARF-CHECK:     DW_AT_name  {{.*}}"var2"
114 #UPD-DWARF-CHECK:     DW_AT_location [DW_FORM_exprloc]        (DW_OP_addr 0x2000)
115 #UPD-DWARF-CHECK:   DW_TAG_variable
116 #UPD-DWARF-CHECK:     DW_AT_name  {{.*}}"var3"
117 #UPD-DWARF-CHECK:     DW_AT_location [DW_FORM_exprloc] (DW_OP_constx 0x6, DW_OP_form_tls_address)
118 #UPD-DWARF-CHECK:   DW_TAG_variable
119 #UPD-DWARF-CHECK:     DW_AT_name  {{.*}}"var4"
120 #UPD-DWARF-CHECK:     DW_AT_location [DW_FORM_exprloc] (DW_OP_const8u 0x2000, DW_OP_form_tls_address)
121 #UPD-DWARF-CHECK: .debug_addr contents:
122 #UPD-DWARF-CHECK: 0x00000000: Address table header: length = 0x0000003c, format = DWARF32, version = 0x0005, addr_size = 0x08, seg_size = 0x00
123 #UPD-DWARF-CHECK: Addrs: [
124 #UPD-DWARF-CHECK: 0x0000000000001130
125 #UPD-DWARF-CHECK: 0x0000000000001140
126 #UPD-DWARF-CHECK: 0x0000000000001150
127 #UPD-DWARF-CHECK: 0x0000000000001160
128 #UPD-DWARF-CHECK: 0x0000000000001170
129 #UPD-DWARF-CHECK: 0x0000000000001180
130 #UPD-DWARF-CHECK: 0x0000000000002000
131 #UPD-DWARF-CHECK: ]
133 --- !ELF
134 FileHeader:
135   Class:    ELFCLASS64
136   Data:     ELFDATA2LSB
137   Type:     ET_REL
138   Machine:  EM_X86_64
139 Sections:
140   - Name:            .text
141     Type:            SHT_PROGBITS
142     Flags:           [ SHF_ALLOC, SHF_EXECINSTR ]
143     Address:         0x1130
144     Size:            0x1000
145 DWARF:
146   debug_abbrev:
147     - Table:
148       - Tag:      DW_TAG_compile_unit
149         Children: DW_CHILDREN_yes
150         Attributes:
151           - Attribute: DW_AT_producer
152             Form:      DW_FORM_string
153           - Attribute: DW_AT_language
154             Form:      DW_FORM_data2
155           - Attribute: DW_AT_name
156             Form:      DW_FORM_string
157           - Attribute: DW_AT_low_pc
158             Form:      DW_FORM_addrx
159           - Attribute: DW_AT_high_pc
160             Form:      DW_FORM_data8
161           - Attribute: DW_AT_addr_base
162             Form:      DW_FORM_sec_offset
163       - Tag:      DW_TAG_subprogram
164         Children: DW_CHILDREN_yes
165         Attributes:
166           - Attribute: DW_AT_name
167             Form:      DW_FORM_string
168           - Attribute: DW_AT_low_pc
169             Form:      DW_FORM_addrx
170           - Attribute: DW_AT_high_pc
171             Form:      DW_FORM_data8
172           - Attribute: DW_AT_type
173             Form:      DW_FORM_ref4
174       - Tag:      DW_TAG_subprogram
175         Children: DW_CHILDREN_yes
176         Attributes:
177           - Attribute: DW_AT_name
178             Form:      DW_FORM_string
179           - Attribute: DW_AT_low_pc
180             Form:      DW_FORM_addrx1
181           - Attribute: DW_AT_high_pc
182             Form:      DW_FORM_data8
183           - Attribute: DW_AT_type
184             Form:      DW_FORM_ref4
185       - Tag:      DW_TAG_subprogram
186         Children: DW_CHILDREN_yes
187         Attributes:
188           - Attribute: DW_AT_name
189             Form:      DW_FORM_string
190           - Attribute: DW_AT_low_pc
191             Form:      DW_FORM_addrx2
192           - Attribute: DW_AT_high_pc
193             Form:      DW_FORM_data8
194           - Attribute: DW_AT_type
195             Form:      DW_FORM_ref4
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_addrx4
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_base_type
208         Children: DW_CHILDREN_no
209         Attributes:
210           - Attribute: DW_AT_name
211             Form:      DW_FORM_string
212       - Tag:      DW_TAG_variable
213         Children: DW_CHILDREN_no
214         Attributes:
215           - Attribute: DW_AT_name
216             Form:      DW_FORM_string
217           - Attribute: DW_AT_type
218             Form:      DW_FORM_ref4
219           - Attribute: DW_AT_location
220             Form:      DW_FORM_exprloc
221   debug_info:
222     - Version: 5
223       UnitType:   DW_UT_compile
224       Entries:
225         - AbbrCode: 1
226           Values:
227             - CStr: by_hand
228             - Value:  0x04
229             - CStr: CU1
230             - Value:  0x0
231             - Value:  0x60
232             - Value:  0x8
233         - AbbrCode: 2
234           Values:
235             - CStr: foo1
236             - Value: 0x0
237             - Value: 0x10
238             - Value: 0xa4
239         - AbbrCode: 0
240         - AbbrCode: 2
241           Values:
242             - CStr: foo2
243             - Value: 0x01
244             - Value: 0x10
245             - Value: 0xa4
246         - AbbrCode: 0
247         - AbbrCode: 2
248           Values:
249             - CStr: foo3
250             - Value: 0x02
251             - Value: 0x10
252             - Value: 0xa4
253         - AbbrCode: 0
254         - AbbrCode: 3
255           Values:
256             - CStr: foo4
257             - Value: 0x03
258             - Value: 0x10
259             - Value: 0xa4
260         - AbbrCode: 0
261         - AbbrCode: 4
262           Values:
263             - CStr: foo5
264             - Value: 0x04
265             - Value: 0x10
266             - Value: 0xa4
267         - AbbrCode: 0
268         - AbbrCode: 5
269           Values:
270             - CStr: foo6
271             - Value: 0x05
272             - Value: 0x10
273             - Value: 0xa4
274         - AbbrCode: 0
275         - AbbrCode: 6
276           Values:
277             - CStr: int
278         - AbbrCode: 7
279           Values:
280             - CStr: var1
281             - Value: 0xa4
282             - BlockData:
283                 - 0xa1
284                 - 0x6
285         - AbbrCode: 7
286           Values:
287             - CStr: var2
288             - Value: 0xa4
289             - BlockData:
290                 - 0x03
291                 - 0x00
292                 - 0x20
293                 - 0x00
294                 - 0x00
295                 - 0x00
296                 - 0x00
297                 - 0x00
298                 - 0x00
299         - AbbrCode: 7
300           Values:
301             - CStr: var3
302             - Value: 0xa4
303             - BlockData:
304                 - 0xa2
305                 - 0x6
306                 - 0x9b
307         - AbbrCode: 7
308           Values:
309             - CStr: var4
310             - Value: 0xa4
311             - BlockData:
312                 - 0x0e
313                 - 0x00
314                 - 0x20
315                 - 0x00
316                 - 0x00
317                 - 0x00
318                 - 0x00
319                 - 0x00
320                 - 0x00
321                 - 0x9b
322         - AbbrCode: 0
323   debug_addr:
324     - Version: 5
325       AddressSize: 0x08
326       Entries:
327         - Address: 0x1130
328         - Address: 0x1140
329         - Address: 0x1150
330         - Address: 0x1160
331         - Address: 0x1170
332         - Address: 0x1180
333         - Address: 0x2000