xref: /llvm-project/bolt/test/X86/dwarf5-dwarf4-monolithic.test (revision 6aad62cf5b7f91f4b02266cf72469e2c8e28dbef)
1# REQUIRES: system-linux
2
3# RUN: llvm-mc -dwarf-version=5 -filetype=obj -triple x86_64-unknown-linux %p/Inputs/dwarf5-dwarf4-monolithic-main.s -o %tmain.o
4# RUN: llvm-mc -dwarf-version=4 -filetype=obj -triple x86_64-unknown-linux %p/Inputs/dwarf5-dwarf4-monolithic-helper0.s -o %t0.o
5# RUN: llvm-mc -dwarf-version=5 -filetype=obj -triple x86_64-unknown-linux %p/Inputs/dwarf5-dwarf4-monolithic-helper1.s -o %t1.o
6# RUN: llvm-mc -dwarf-version=4 -filetype=obj -triple x86_64-unknown-linux %p/Inputs/dwarf5-dwarf4-monolithic-helper2.s -o %t2.o
7# RUN: %clang %cflags -dwarf-5 %tmain.o %t0.o %t1.o %t2.o -o %t.exe -Wl,-q
8# RUN: llvm-bolt --always-convert-to-ranges %t.exe -o %t.bolt --update-debug-sections --debug-thread-count=4 --cu-processing-batch-size=4
9# RUN: llvm-dwarfdump --show-form --verbose --debug-info %t.exe | FileCheck --check-prefix=PRECHECK %s
10# RUN: llvm-dwarfdump --show-form --verbose --debug-line %t.exe > %t_line.txt
11# RUN: llvm-dwarfdump --show-form --verbose --debug-addr %t.bolt > %t.txt
12# RUN: llvm-dwarfdump --show-form --verbose --debug-info %t.bolt >> %t.txt
13# RUN: cat %t.txt | FileCheck --check-prefix=POSTCHECK %s
14# RUN: llvm-dwarfdump --show-form --verbose --debug-line %t.bolt >> %t_line.txt
15# RUN: FileCheck --check-prefix=CHECK-LINE %s --input-file %t_line.txt
16
17
18## Check BOLT handles monolithic mix of DWARF4 and DWARF5.
19
20# main.cpp
21# PRECHECK: version = 0x0005
22# PRECHECK: DW_TAG_compile_unit [1] *
23# PRECHECK-NEXT: DW_AT_producer [DW_FORM_strx1]  (indexed (00000000)
24# PRECHECK-NEXT: DW_AT_language
25# PRECHECK-NEXT: DW_AT_name
26# PRECHECK-NEXT: DW_AT_str_offsets_base [DW_FORM_sec_offset] (0x00000008)
27# PRECHECK-NEXT: DW_AT_stmt_list [DW_FORM_sec_offset]  (0x00000000)
28# PRECHECK-NEXT: DW_AT_comp_dir
29# PRECHECK-NEXT: DW_AT_low_pc
30# PRECHECK: DW_AT_ranges [DW_FORM_rnglistx] (indexed (0x1)
31# PRECHECK-NEXT: [0x
32# PRECHECK-NEXT: [0x
33# PRECHECK-NEXT: DW_AT_addr_base [DW_FORM_sec_offset]  (0x00000008)
34# PRECHECK-NEXT: DW_AT_rnglists_base [DW_FORM_sec_offset]  (0x0000000c)
35# PRECHECK-NEXT: DW_AT_loclists_base [DW_FORM_sec_offset]  (0x0000000c)
36# PRECHECK: DW_TAG_subprogram [2] * (0x0000000c)
37# PRECHECK-NEXT: DW_AT_low_pc [DW_FORM_addrx]  (indexed (00000000)
38# PRECHECK-NEXT: DW_AT_high_pc [DW_FORM_data4]
39# PRECHECK: DW_TAG_subprogram [8]
40# PRECHECK-NEXT: DW_AT_low_pc [DW_FORM_addrx]  (indexed (00000001)
41# PRECHECK-NEXT: DW_AT_high_pc [DW_FORM_data4]
42# PRECHECK: DW_TAG_formal_parameter [9]
43# PRECHECK-NEXT: DW_AT_location [DW_FORM_loclistx] (indexed (0x0) loclist = 0x00000018
44# PRECHECK: DW_TAG_formal_parameter [9]
45# PRECHECK-NEXT: DW_AT_location [DW_FORM_loclistx] (indexed (0x1) loclist = 0x00000028
46# PRECHECK: DW_TAG_variable
47# PRECHECK-NEXT: DW_AT_location [DW_FORM_loclistx] (indexed (0x2) loclist = 0x00000038
48# PRECHECK: DW_TAG_inlined_subroutine [12]
49# PRECHECK-NEXT: DW_AT_abstract_origin
50# PRECHECK-NEXT: DW_AT_ranges [DW_FORM_rnglistx] (indexed (0x0) rangelist = 0x00000014
51
52# helper0.cpp
53# PRECHECK: version = 0x0004
54# PRECHECK: DW_TAG_compile_unit
55# PRECHECK-NEXT: DW_AT_producer
56# PRECHECK-NEXT: DW_AT_language
57# PRECHECK-NEXT: DW_AT_name
58# PRECHECK-NEXT: DW_AT_stmt_list
59# PRECHECK-NEXT: DW_AT_comp_dir
60# PRECHECK-NEXT: DW_AT_low_pc [DW_FORM_addr]
61# PRECHECK-NEXT: DW_AT_high_pc
62# PRECHECK: DW_TAG_subprogram [7]
63# PRECHECK-NEXT: DW_AT_low_pc [DW_FORM_addr]
64# PRECHECK-NEXT: DW_AT_high_pc
65# PRECHECK: DW_TAG_variable [9]
66# PRECHECK-NEXT: DW_AT_location [DW_FORM_sec_offset] (0x00000000:
67# PRECHECK: DW_TAG_inlined_subroutine [10]
68# PRECHECK-NEXT: DW_AT_abstract_origin
69# PRECHECK-NEXT: DW_AT_low_pc [DW_FORM_addr]
70# PRECHECK-NEXT: DW_AT_high_pc
71
72# helper1.cpp
73# PRECHECK: version = 0x0005
74# PRECHECK: DW_TAG_compile_unit [1] *
75# PRECHECK-NEXT: DW_AT_producer
76# PRECHECK-NEXT: DW_AT_language
77# PRECHECK-NEXT: DW_AT_name
78# PRECHECK-NEXT: DW_AT_str_offsets_base [DW_FORM_sec_offset] (0x00000058)
79# PRECHECK-NEXT: DW_AT_stmt_list
80# PRECHECK-NEXT: DW_AT_comp_dir
81# PRECHECK-NEXT: DW_AT_low_pc [DW_FORM_addrx]  (indexed (00000001)
82# PRECHECK-NEXT: DW_AT_high_pc [DW_FORM_data4]
83# PRECHECK-NEXT: DW_AT_addr_base [DW_FORM_sec_offset]  (0x00000038)
84# PRECHECK-NEXT: DW_AT_loclists_base [DW_FORM_sec_offset]  (0x00000051)
85# PRECHECK: DW_TAG_variable [2]
86# PRECHECK-NEXT: DW_AT_name
87# PRECHECK-NEXT: DW_AT_type
88# PRECHECK-NEXT: DW_AT_external
89# PRECHECK-NEXT: DW_AT_decl_file
90# PRECHECK-NEXT: DW_AT_decl_line
91# PRECHECK: DW_AT_location [DW_FORM_exprloc]  (DW_OP_addrx 0x0)
92# PRECHECK: DW_TAG_subprogram [7]
93# PRECHECK-NEXT: DW_AT_low_pc [DW_FORM_addrx]  (indexed (00000001)
94# PRECHECK-NEXT: DW_AT_high_pc [DW_FORM_data4]
95# PRECHECK: DW_TAG_variable [9]
96# PRECHECK-NEXT: DW_AT_location [DW_FORM_loclistx] (indexed (0x0)
97# PRECHECK: DW_TAG_inlined_subroutine [10]
98# PRECHECK-NEXT: DW_AT_abstract_origin
99# PRECHECK-NEXT: DW_AT_low_pc [DW_FORM_addrx]  (indexed (00000001)
100# PRECHECK-NEXT: DW_AT_high_pc [DW_FORM_data4]
101
102# helper2.cpp
103# PRECHECK: version = 0x0004
104# PRECHECK: DW_TAG_compile_unit [1] *
105# PRECHECK-NEXT: DW_AT_producer
106# PRECHECK-NEXT: DW_AT_language
107# PRECHECK-NEXT: DW_AT_name
108# PRECHECK-NEXT: DW_AT_stmt_list
109# PRECHECK-NEXT: DW_AT_comp_dir
110# PRECHECK-NEXT: DW_AT_low_pc [DW_FORM_addr]
111# PRECHECK-NEXT: DW_AT_high_pc [DW_FORM_data4]
112# PRECHECK: DW_TAG_subprogram [7]
113# PRECHECK-NEXT: DW_AT_low_pc [DW_FORM_addr]
114# PRECHECK-NEXT: DW_AT_high_pc [DW_FORM_data4]
115# PRECHECK: DW_TAG_variable [9]
116# PRECHECK-NEXT: DW_AT_location [DW_FORM_sec_offset]
117# PRECHECK: DW_TAG_inlined_subroutine [10]
118# PRECHECK-NEXT: DW_AT_abstract_origin
119# PRECHECK-NEXT: DW_AT_low_pc [DW_FORM_addr]
120# PRECHECK-NEXT: DW_AT_high_pc
121
122# Checking debug line.
123
124# CHECK-LINE: debug_line[
125# CHECK-LINE: version: 5
126# CHECK-LINE: include_directories[  0] =  .debug_line_str[0x[[#%.8x,TEST_DEBUG_LINE:]]] = "/test"
127# CHECK-LINE-NEXT: file_names[  0]:
128# CHECK-LINE-NEXT: name:  .debug_line_str[0x[[#%.8x,MAIN_DEBUG_LINE:]]] = "main.cpp"
129# CHECK-LINE-NEXT: dir_index: 0
130# CHECK-LINE-NEXT: md5_checksum: e3a18fae8565a087d09d6076b542cdab
131
132# CHECK-LINE: debug_line[
133# CHECK-LINE: version: 4
134# CHECK-LINE: include_directories[  1] = "/test"
135# CHECK-LINE-NEXT: file_names[  1]:
136# CHECK-LINE-NEXT: name: "helper0.cpp"
137# CHECK-LINE-NEXT: dir_index: 1
138# CHECK-LINE-NEXT: mod_time:
139# CHECK-LINE-NEXT: length:
140
141# CHECK-LINE: debug_line[
142# CHECK-LINE: version: 5
143# CHECK-LINE: include_directories[  0] =  .debug_line_str[0x[[#TEST_DEBUG_LINE]]] = "/test"
144# CHECK-LINE-NEXT: file_names[  0]:
145# CHECK-LINE-NEXT: name:  .debug_line_str[0x[[#%.8x,HELPER_DEBUG_LINE:]]] = "helper1.cpp"
146# CHECK-LINE-NEXT: dir_index: 0
147# CHECK-LINE-NEXT: md5_checksum: e6dbd773fdf80bfea332cdf8284cddce
148
149# CHECK-LINE: debug_line[
150# CHECK-LINE: version: 4
151# CHECK-LINE: include_directories[  1] = "/test"
152# CHECK-LINE-NEXT: file_names[  1]:
153# CHECK-LINE-NEXT: name: "helper2.cpp"
154# CHECK-LINE-NEXT: dir_index: 1
155# CHECK-LINE-NEXT: mod_time:
156# CHECK-LINE-NEXT: length:
157
158
159# POST BOLT.
160
161# POSTCHECK: Addrs: [
162# POSTCHECK-NEXT: 0x[[#%.16x,ADDR:]]
163# POSTCHECK-NEXT: 0x[[#%.16x,ADDR1:]]
164# POSTCHECK-NEXT: 0x[[#%.16x,ADDR2:]]
165# POSTCHECK-NEXT: 0x[[#%.16x,ADDR3:]]
166# POSTCHECK-NEXT: 0x[[#%.16x,ADDR4:]]
167# POSTCHECK-NEXT: 0x[[#%.16x,ADDR5:]]
168# POSTCHECK-NEXT: 0x[[#%.16x,ADDR6:]]
169
170# POSTCHECK: Addrs: [
171# POSTCHECK-NEXT: 0x[[#%.16x,ADDRB:]]
172# POSTCHECK-NEXT: 0x[[#%.16x,ADDRB1:]]
173# POSTCHECK-NEXT: 0x[[#%.16x,ADDRB2:]]
174
175
176# main.cpp
177# POSTCHECK: version = 0x0005
178# POSTCHECK: DW_TAG_compile_unit [1] *
179# POSTCHECK-NEXT: DW_AT_producer [DW_FORM_strx1]  (indexed (00000000)
180# POSTCHECK-NEXT: DW_AT_language
181# POSTCHECK-NEXT: DW_AT_name
182# POSTCHECK-NEXT: DW_AT_str_offsets_base [DW_FORM_sec_offset] (0x00000008)
183# POSTCHECK-NEXT: DW_AT_stmt_list [DW_FORM_sec_offset]  (0x00000000)
184# POSTCHECK-NEXT: DW_AT_comp_dir
185# POSTCHECK-NEXT: DW_AT_low_pc
186# POSTCHECK: DW_AT_ranges [DW_FORM_rnglistx] (indexed (0x0)
187# POSTCHECK-NEXT: [0x[[#ADDR]], 0x[[#ADDR + 0x7]]
188# POSTCHECK-NEXT: [0x[[#ADDR1]], 0x[[#ADDR1 + 0x51]]
189# POSTCHECK-NEXT: DW_AT_addr_base [DW_FORM_sec_offset]  (0x00000008)
190# POSTCHECK-NEXT: DW_AT_rnglists_base [DW_FORM_sec_offset]  (0x0000000c)
191# POSTCHECK-NEXT: DW_AT_loclists_base [DW_FORM_sec_offset]  (0x0000000c)
192# POSTCHECK: DW_TAG_subprogram [2]
193# POSTCHECK-NEXT: DW_AT_ranges [DW_FORM_rnglistx] (indexed (0x1) rangelist
194# POSTCHECK-NEXT: [0x[[#ADDR]], 0x[[#ADDR + 0x7]]
195# POSTCHECK: DW_TAG_subprogram [8]
196# POSTCHECK-NEXT: DW_AT_ranges [DW_FORM_rnglistx] (indexed (0x2) rangelist = 0x00000029
197# POSTCHECK-NEXT: [0x[[#ADDR1]], 0x[[#ADDR1 + 0x51]]
198# POSTCHECK: DW_TAG_formal_parameter [9]
199# POSTCHECK-NEXT: DW_AT_location [DW_FORM_loclistx] (indexed (0x0) loclist = 0x00000018
200# POSTCHECK-NEXT: [0x[[#ADDR1]], 0x[[#ADDR1 + 0x22]]
201# POSTCHECK-NEXT: [0x[[#ADDR1 + 0x22]], 0x[[#ADDR1 + 0x51]]
202# POSTCHECK: DW_TAG_formal_parameter [9]
203# POSTCHECK-NEXT: DW_AT_location [DW_FORM_loclistx] (indexed (0x1) loclist = 0x00000028
204# POSTCHECK-NEXT: [0x[[#ADDR1]], 0x[[#ADDR1 + 0x27]]
205# POSTCHECK-NEXT: [0x[[#ADDR1 + 0x27]], 0x[[#ADDR1 + 0x51]]
206# POSTCHECK: DW_TAG_variable
207# POSTCHECK-NEXT: DW_AT_location [DW_FORM_loclistx] (indexed (0x2) loclist = 0x00000038
208# POSTCHECK-NEXT: [0x[[#ADDR2]], 0x[[#ADDR2 + 0x6]]
209# POSTCHECK-NEXT: [0x[[#ADDR2 + 0x6]], 0x[[#ADDR2 + 0x46]]
210# POSTCHECK: DW_TAG_inlined_subroutine [12]
211# POSTCHECK-NEXT: DW_AT_abstract_origin
212# POSTCHECK-NEXT: DW_AT_ranges [DW_FORM_rnglistx] (indexed (0x3) rangelist =  0x0000002d
213# POSTCHECK-NEXT: [0x[[#ADDR3]], 0x[[#ADDR3 + 0x4]]
214# POSTCHECK-NEXT: [0x[[#ADDR3 + 0x10]], 0x[[#ADDR3 + 0x16]]
215
216# helper0.cpp
217# POSTCHECK: version = 0x0004
218# POSTCHECK: DW_TAG_compile_unit
219# POSTCHECK-NEXT: DW_AT_producer
220# POSTCHECK-NEXT: DW_AT_language
221# POSTCHECK-NEXT: DW_AT_name
222# POSTCHECK-NEXT: DW_AT_stmt_list
223# POSTCHECK-NEXT: DW_AT_comp_dir
224# POSTCHECK-NEXT: DW_AT_low_pc [DW_FORM_addr] (0x0000000000000000)
225# POSTCHECK-NEXT: DW_AT_ranges [DW_FORM_sec_offset]
226# POSTCHECK-NEXT: [0x
227# POSTCHECK: DW_TAG_subprogram [22]
228# POSTCHECK-NEXT: DW_AT_ranges [DW_FORM_sec_offset]
229# POSTCHECK-NEXT: [0x
230# POSTCHECK: DW_TAG_variable [24]
231# POSTCHECK-NEXT: DW_AT_location [DW_FORM_sec_offset]
232# POSTCHECK-NEXT: [0x
233# POSTCHECK-NEXT: [0x
234# POSTCHECK: DW_TAG_inlined_subroutine [25]
235# POSTCHECK-NEXT: DW_AT_abstract_origin
236# POSTCHECK-NEXT: DW_AT_ranges [DW_FORM_sec_offset]
237# POSTCHECK-NEXT: [0x
238
239# helper1.cpp
240# POSTCHECK: version = 0x0005
241# POSTCHECK: DW_TAG_compile_unit [26] *
242# POSTCHECK-NEXT: DW_AT_producer
243# POSTCHECK-NEXT: DW_AT_language
244# POSTCHECK-NEXT: DW_AT_name
245# POSTCHECK-NEXT: DW_AT_str_offsets_base [DW_FORM_sec_offset] (0x00000058)
246# POSTCHECK-NEXT: DW_AT_stmt_list
247# POSTCHECK-NEXT: DW_AT_comp_dir
248# POSTCHECK-NEXT: DW_AT_low_pc [DW_FORM_addrx]  (indexed (00000001)
249# POSTCHECK-NEXT: DW_AT_ranges [DW_FORM_rnglistx] (indexed (0x0)
250# POSTCHECK-NEXT: [0x[[#ADDRB]], 0x[[#ADDRB + 0x4]]
251# POSTCHECK-NEXT: DW_AT_addr_base [DW_FORM_sec_offset]
252# POSTCHECK-NEXT: DW_AT_loclists_base [DW_FORM_sec_offset]
253# POSTCHECK-NEXT: DW_AT_rnglists_base [DW_FORM_sec_offset]
254# POSTCHECK: DW_TAG_variable [27]
255# POSTCHECK-NEXT: DW_AT_name
256# POSTCHECK-NEXT: DW_AT_type
257# POSTCHECK-NEXT: DW_AT_external
258# POSTCHECK-NEXT: DW_AT_decl_file
259# POSTCHECK-NEXT: DW_AT_decl_line
260# POSTCHECK: DW_AT_location [DW_FORM_exprloc]  (DW_OP_addrx 0x2)
261# POSTCHECK: DW_TAG_subprogram [29]
262# POSTCHECK-NEXT: DW_AT_ranges [DW_FORM_rnglistx] (indexed (0x1)
263# POSTCHECK-NEXT: [0x[[#ADDRB]], 0x[[#ADDRB + 0x4]]
264# POSTCHECK: DW_TAG_variable [10]
265# POSTCHECK-NEXT: DW_AT_location [DW_FORM_loclistx] (indexed (0x0)
266# POSTCHECK-NEXT: [0x[[#ADDRB]], 0x[[#ADDRB + 0x3]]
267# POSTCHECK-NEXT: [0x[[#ADDRB + 0x3]], 0x[[#ADDRB + 0x4]]
268# POSTCHECK: DW_TAG_inlined_subroutine
269# POSTCHECK-NEXT: DW_AT_abstract_origin
270# POSTCHECK-NEXT: DW_AT_ranges [DW_FORM_rnglistx] (indexed (0x2) rangelist
271# POSTCHECK-NEXT: [0x[[#ADDRB]], 0x[[#ADDRB + 0x3]]
272
273# helper2.cpp
274# POSTCHECK: version = 0x0004
275# POSTCHECK: DW_TAG_compile_unit [17] *
276# POSTCHECK-NEXT: DW_AT_producer
277# POSTCHECK-NEXT: DW_AT_language
278# POSTCHECK-NEXT: DW_AT_name
279# POSTCHECK-NEXT: DW_AT_stmt_list
280# POSTCHECK-NEXT: DW_AT_comp_dir
281# POSTCHECK-NEXT: DW_AT_low_pc [DW_FORM_addr] (0x0000000000000000)
282# POSTCHECK-NEXT: DW_AT_ranges [DW_FORM_sec_offset]
283# POSTCHECK-NEXT: [0x
284# POSTCHECK: DW_TAG_subprogram [22]
285# POSTCHECK-NEXT: DW_AT_ranges [DW_FORM_sec_offset]
286# POSTCHECK-NEXT: [0x
287# POSTCHECK: DW_TAG_variable [24]
288# POSTCHECK-NEXT: DW_AT_location [DW_FORM_sec_offset]
289# POSTCHECK-NEXT: [0x
290# POSTCHECK-NEXT: [0x
291# POSTCHECK: DW_TAG_inlined_subroutine [25]
292# POSTCHECK-NEXT: DW_AT_abstract_origin
293# POSTCHECK-NEXT: DW_AT_ranges [DW_FORM_sec_offset]
294# POSTCHECK-NEXT: [0x
295
296
297# Checking debug line.
298
299# CHECK-LINE: debug_line[
300# CHECK-LINE: version: 5
301# CHECK-LINE: include_directories[  0] =  .debug_line_str[0x[[#TEST_DEBUG_LINE]]] = "/test"
302# CHECK-LINE-NEXT: file_names[  0]:
303# CHECK-LINE-NEXT: name:  .debug_line_str[0x[[#MAIN_DEBUG_LINE]]] = "main.cpp"
304# CHECK-LINE-NEXT: dir_index: 0
305# CHECK-LINE-NEXT: md5_checksum: e3a18fae8565a087d09d6076b542cdab
306
307# CHECK-LINE: debug_line[
308# CHECK-LINE: version: 4
309# CHECK-LINE: include_directories[  1] = "/test"
310# CHECK-LINE-NEXT: file_names[  1]:
311# CHECK-LINE-NEXT: name: "helper0.cpp"
312# CHECK-LINE-NEXT: dir_index: 1
313# CHECK-LINE-NEXT: mod_time:
314# CHECK-LINE-NEXT: length:
315
316# CHECK-LINE: debug_line[
317# CHECK-LINE: version: 5
318# CHECK-LINE: include_directories[  0] =  .debug_line_str[0x[[#TEST_DEBUG_LINE]]] = "/test"
319# CHECK-LINE-NEXT: file_names[  0]:
320# CHECK-LINE-NEXT: name:  .debug_line_str[0x[[#HELPER_DEBUG_LINE]]] = "helper1.cpp"
321# CHECK-LINE-NEXT: dir_index: 0
322# CHECK-LINE-NEXT: md5_checksum: e6dbd773fdf80bfea332cdf8284cddce
323
324# CHECK-LINE: debug_line[
325# CHECK-LINE: version: 4
326# CHECK-LINE: include_directories[  1] = "/test"
327# CHECK-LINE-NEXT: file_names[  1]:
328# CHECK-LINE-NEXT: name: "helper2.cpp"
329# CHECK-LINE-NEXT: dir_index: 1
330# CHECK-LINE-NEXT: mod_time:
331# CHECK-LINE-NEXT: length:
332