1 # REQUIRES: system-linux
7 # RUN: llvm-mc -dwarf-version=5 -filetype=obj -triple x86_64-unknown-linux -split-dwarf-file=main.dwo %p/Inputs/dwarf5-split-dwarf4-monolithic-main.s -o main.o
8 # RUN: llvm-mc -dwarf-version=4 -filetype=obj -triple x86_64-unknown-linux %p/Inputs/dwarf5-dwarf4-monolithic-helper0.s -o helper0.o
9 # RUN: llvm-mc -dwarf-version=5 -filetype=obj -triple x86_64-unknown-linux -split-dwarf-file=helper1.dwo %p/Inputs/dwarf5-split-dwarf4-monolithic-helper1.s -o helper1.o
10 # RUN: llvm-mc -dwarf-version=4 -filetype=obj -triple x86_64-unknown-linux %p/Inputs/dwarf5-dwarf4-monolithic-helper2.s -o helper2.o
11 # RUN: %clang %cflags -dwarf-5 main.o helper0.o helper1.o helper2.o -o main.exe -Wl,-q
12 # RUN: llvm-bolt --always-convert-to-ranges main.exe -o main.bolt --update-debug-sections
13 # RUN: llvm-dwarfdump --show-form --verbose --debug-info main.exe | FileCheck --check-prefix=PRECHECK %s
14 # RUN: llvm-dwarfdump --show-form --verbose --debug-line main.exe | FileCheck --check-prefix=PRECHECK-LINE %s
15 # RUN: llvm-dwarfdump --show-form --verbose --debug-addr main.bolt > boltout.txt
16 # RUN: llvm-dwarfdump --show-form --verbose --debug-info main.bolt >> boltout.txt
17 # RUN: cat boltout.txt | FileCheck --check-prefix=POSTCHECK %s
18 # RUN: llvm-dwarfdump --show-form --verbose --debug-info main.dwo.dwo | FileCheck --check-prefix=POSTCHECK-DWO-MAIN %s
19 # RUN: llvm-dwarfdump --show-form --verbose --debug-info helper1.dwo.dwo | FileCheck --check-prefix=POSTCHECK-DWO-HELPER1 %s
20 # RUN: llvm-dwarfdump --show-form --verbose --debug-line main.bolt | FileCheck --check-prefix=POSTCHECK-LINE %s
23 # Check BOLT handles monolithic mix of DWARF4 and DWARF5.
26 # PRECHECK: version = 0x0005
27 # PRECHECK: DW_TAG_skeleton_unit
28 # PRECHECK-NEXT: DW_AT_stmt_list
29 # PRECHECK-NEXT: DW_AT_str_offsets_base
30 # PRECHECK-NEXT: DW_AT_comp_dir
31 # PRECHECK-NEXT: DW_AT_GNU_pubnames [DW_FORM_flag_present] (true)
32 # PRECHECK-NEXT: DW_AT_dwo_name [DW_FORM_strx1] (indexed (00000001) string = "main.dwo")
33 # PRECHECK-NEXT: DW_AT_low_pc
34 # PRECHECK-NEXT: DW_AT_ranges [DW_FORM_rnglistx] (indexed (0x0) rangelist = 0x00000010
37 # PRECHECK-NEXT: DW_AT_addr_base
38 # PRECHECK-NEXT: DW_AT_rnglists_base
41 # PRECHECK: version = 0x0004
42 # PRECHECK: DW_TAG_compile_unit
43 # PRECHECK-NEXT: DW_AT_producer
44 # PRECHECK-NEXT: DW_AT_language
45 # PRECHECK-NEXT: DW_AT_name
46 # PRECHECK-NEXT: DW_AT_stmt_list
47 # PRECHECK-NEXT: DW_AT_comp_dir
48 # PRECHECK-NEXT: DW_AT_low_pc [DW_FORM_addr]
49 # PRECHECK-NEXT: DW_AT_high_pc
50 # PRECHECK: DW_TAG_subprogram [7]
51 # PRECHECK-NEXT: DW_AT_low_pc [DW_FORM_addr]
52 # PRECHECK-NEXT: DW_AT_high_pc
53 # PRECHECK: DW_TAG_variable [9]
54 # PRECHECK-NEXT: DW_AT_location [DW_FORM_sec_offset] (0x00000000:
55 # PRECHECK: DW_TAG_inlined_subroutine [10]
56 # PRECHECK-NEXT: DW_AT_abstract_origin
57 # PRECHECK-NEXT: DW_AT_low_pc [DW_FORM_addr]
58 # PRECHECK-NEXT: DW_AT_high_pc
61 # PRECHECK: version = 0x0005
62 # PRECHECK: DW_TAG_skeleton_unit [1]
63 # PRECHECK-NEXT: DW_AT_stmt_list
64 # PRECHECK-NEXT: DW_AT_str_offsets_base
65 # PRECHECK-NEXT: DW_AT_comp_dir
66 # PRECHECK-NEXT: DW_AT_GNU_pubnames
67 # PRECHECK-NEXT: DW_AT_dwo_name [DW_FORM_strx1] (indexed (00000001) string = "helper1.dwo")
68 # PRECHECK-NEXT: DW_AT_low_pc [DW_FORM_addrx] (indexed (00000001) address
69 # PRECHECK-NEXT: DW_AT_high_pc [DW_FORM_data4]
70 # PRECHECK-NEXT: DW_AT_addr_base
73 # PRECHECK: version = 0x0004
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_stmt_list
79 # PRECHECK-NEXT: DW_AT_comp_dir
80 # PRECHECK-NEXT: DW_AT_low_pc [DW_FORM_addr]
81 # PRECHECK-NEXT: DW_AT_high_pc [DW_FORM_data4]
82 # PRECHECK: DW_TAG_subprogram [7]
83 # PRECHECK-NEXT: DW_AT_low_pc [DW_FORM_addr]
84 # PRECHECK-NEXT: DW_AT_high_pc [DW_FORM_data4]
85 # PRECHECK: DW_TAG_variable [9]
86 # PRECHECK-NEXT: DW_AT_location [DW_FORM_sec_offset]
87 # PRECHECK: DW_TAG_inlined_subroutine [10]
88 # PRECHECK-NEXT: DW_AT_abstract_origin
89 # PRECHECK-NEXT: DW_AT_low_pc [DW_FORM_addr]
90 # PRECHECK-NEXT: DW_AT_high_pc
92 # Checking debug line.
94 # PRECHECK-LINE: debug_line[
95 # PRECHECK-LINE: version: 5
96 # PRECHECK-LINE: include_directories[ 0] = .debug_line_str[0x[[#%.8x,LINE:]]] = "."
97 # PRECHECK-LINE-NEXT: file_names[ 0]:
98 # PRECHECK-LINE-NEXT: name: .debug_line_str[0x[[#%.8x,LINE:]]] = "main.cpp"
99 # PRECHECK-LINE-NEXT: dir_index: 0
100 # PRECHECK-LINE-NEXT: md5_checksum: e3a18fae8565a087d09d6076b542cdab
102 # PRECHECK-LINE: debug_line[
103 # PRECHECK-LINE: version: 4
104 # PRECHECK-LINE: include_directories[ 1] = "/test"
105 # PRECHECK-LINE-NEXT: file_names[ 1]:
106 # PRECHECK-LINE-NEXT: name: "helper0.cpp"
107 # PRECHECK-LINE-NEXT: dir_index: 1
108 # PRECHECK-LINE-NEXT: mod_time:
109 # PRECHECK-LINE-NEXT: length:
111 # PRECHECK-LINE: debug_line[
112 # PRECHECK-LINE: version: 5
113 # PRECHECK-LINE: include_directories[ 0] = .debug_line_str[0x[[#%.8x,LINE:]]] = "."
114 # PRECHECK-LINE-NEXT: file_names[ 0]:
115 # PRECHECK-LINE-NEXT: name: .debug_line_str[0x[[#%.8x,LINE:]]] = "helper1.cpp"
116 # PRECHECK-LINE-NEXT: dir_index: 0
117 # PRECHECK-LINE-NEXT: md5_checksum: e6dbd773fdf80bfea332cdf8284cddce
120 # PRECHECK-LINE: debug_line[
121 # PRECHECK-LINE: version: 4
122 # PRECHECK-LINE: include_directories[ 1] = "/test"
123 # PRECHECK-LINE-NEXT: file_names[ 1]:
124 # PRECHECK-LINE-NEXT: name: "helper2.cpp"
125 # PRECHECK-LINE-NEXT: dir_index: 1
126 # PRECHECK-LINE-NEXT: mod_time:
127 # PRECHECK-LINE-NEXT: length:
132 # POSTCHECK: Addrs: [
133 # POSTCHECK-NEXT: 0x[[#%.16x,ADDR:]]
134 # POSTCHECK-NEXT: 0x[[#%.16x,ADDR1:]]
135 # POSTCHECK-NEXT: 0x[[#%.16x,ADDR2:]]
136 # POSTCHECK-NEXT: 0x[[#%.16x,ADDR3:]]
137 # POSTCHECK-NEXT: 0x[[#%.16x,ADDR4:]]
138 # POSTCHECK-NEXT: 0x[[#%.16x,ADDR5:]]
139 # POSTCHECK-NEXT: 0x[[#%.16x,ADDR6:]]
141 # POSTCHECK: Addrs: [
142 # POSTCHECK-NEXT: 0x[[#%.16x,ADDRB:]]
143 # POSTCHECK-NEXT: 0x[[#%.16x,ADDRB1:]]
144 # POSTCHECK-NEXT: 0x[[#%.16x,ADDRB2:]]
148 # POSTCHECK: version = 0x0005
149 # POSTCHECK: DW_AT_stmt_list [DW_FORM_sec_offset] (0x00000000)
150 # POSTCHECK-NEXT: DW_AT_str_offsets_base [DW_FORM_sec_offset] (0x00000008)
151 # POSTCHECK-NEXT: DW_AT_comp_dir [DW_FORM_strx1] (indexed (00000000) string = ".")
152 # POSTCHECK-NEXT: DW_AT_GNU_pubnames [DW_FORM_flag_present] (true)
153 # POSTCHECK-NEXT: DW_AT_dwo_name [DW_FORM_strx1] (indexed (00000001) string = "main.dwo.dwo")
154 # POSTCHECK-NEXT: DW_AT_low_pc
155 # POSTCHECK-NEXT: DW_AT_ranges [DW_FORM_rnglistx] (indexed (0x0)
156 # POSTCHECK-NEXT: [0x[[#ADDR]], 0x[[#ADDR + 0x7]]
157 # POSTCHECK-NEXT: [0x[[#ADDR1]], 0x[[#ADDR1 + 0x51]]
158 # POSTCHECK-NEXT: DW_AT_addr_base [DW_FORM_sec_offset]
159 # POSTCHECK-NEXT: DW_AT_rnglists_base [DW_FORM_sec_offset]
162 # POSTCHECK: version = 0x0004
163 # POSTCHECK: DW_TAG_compile_unit
164 # POSTCHECK-NEXT: DW_AT_producer
165 # POSTCHECK-NEXT: DW_AT_language
166 # POSTCHECK-NEXT: DW_AT_name
167 # POSTCHECK-NEXT: DW_AT_stmt_list
168 # POSTCHECK-NEXT: DW_AT_comp_dir
169 # POSTCHECK-NEXT: DW_AT_low_pc [DW_FORM_addr] (0x0000000000000000)
170 # POSTCHECK-NEXT: DW_AT_ranges [DW_FORM_sec_offset]
171 # POSTCHECK-NEXT: [0x
172 # POSTCHECK: DW_TAG_subprogram [8]
173 # POSTCHECK-NEXT: DW_AT_ranges [DW_FORM_sec_offset]
174 # POSTCHECK-NEXT: [0x
175 # POSTCHECK: DW_TAG_variable [10]
176 # POSTCHECK-NEXT: DW_AT_location [DW_FORM_sec_offset]
177 # POSTCHECK-NEXT: [0x
178 # POSTCHECK-NEXT: [0x
179 # POSTCHECK: DW_TAG_inlined_subroutine [11]
180 # POSTCHECK-NEXT: DW_AT_abstract_origin
181 # POSTCHECK-NEXT: DW_AT_ranges [DW_FORM_sec_offset]
182 # POSTCHECK-NEXT: [0x
185 # POSTCHECK: version = 0x0005
186 # POSTCHECK: DW_TAG_skeleton_unit [12]
187 # POSTCHECK-NEXT: DW_AT_stmt_list [DW_FORM_sec_offset] (0x000000fe)
188 # POSTCHECK-NEXT: DW_AT_str_offsets_base [DW_FORM_sec_offset] (0x00000018)
189 # POSTCHECK-NEXT: DW_AT_comp_dir [DW_FORM_strx1] (indexed (00000000) string = ".")
190 # POSTCHECK-NEXT: DW_AT_GNU_pubnames [DW_FORM_flag_present] (true)
191 # POSTCHECK-NEXT: DW_AT_dwo_name [DW_FORM_strx1] (indexed (00000001) string = "helper1.dwo.dwo")
192 # POSTCHECK-NEXT: DW_AT_low_pc [DW_FORM_addrx] (indexed (00000002)
193 # POSTCHECK-NEXT: DW_AT_ranges [DW_FORM_rnglistx] (indexed (0x0)
194 # POSTCHECK-NEXT: [0x[[#ADDRB1]], 0x[[#ADDRB1 + 0x4]]
195 # POSTCHECK-NEXT: DW_AT_addr_base [DW_FORM_sec_offset]
196 # POSTCHECK-NEXT: DW_AT_rnglists_base [DW_FORM_sec_offset]
199 # POSTCHECK: version = 0x0004
200 # POSTCHECK: DW_TAG_compile_unit [2] *
201 # POSTCHECK-NEXT: DW_AT_producer
202 # POSTCHECK-NEXT: DW_AT_language
203 # POSTCHECK-NEXT: DW_AT_name
204 # POSTCHECK-NEXT: DW_AT_stmt_list
205 # POSTCHECK-NEXT: DW_AT_comp_dir
206 # POSTCHECK-NEXT: DW_AT_low_pc [DW_FORM_addr] (0x0000000000000000)
207 # POSTCHECK-NEXT: DW_AT_ranges [DW_FORM_sec_offset]
208 # POSTCHECK-NEXT: [0x
209 # POSTCHECK: DW_TAG_subprogram [8]
210 # POSTCHECK-NEXT: DW_AT_ranges [DW_FORM_sec_offset]
211 # POSTCHECK-NEXT: [0x
212 # POSTCHECK: DW_TAG_variable [10]
213 # POSTCHECK-NEXT: DW_AT_location [DW_FORM_sec_offset]
214 # POSTCHECK-NEXT: [0x
215 # POSTCHECK-NEXT: [0x
216 # POSTCHECK: DW_TAG_inlined_subroutine [11]
217 # POSTCHECK-NEXT: DW_AT_abstract_origin
218 # POSTCHECK-NEXT: DW_AT_ranges [DW_FORM_sec_offset]
219 # POSTCHECK-NEXT: [0x
221 # POSTCHECK-DWO-MAIN: version = 0x0005
222 # POSTCHECK-DWO-MAIN: DW_TAG_compile_unit
223 # POSTCHECK-DWO-MAIN: DW_TAG_subprogram [2]
224 # POSTCHECK-DWO-MAIN-NEXT: DW_AT_ranges [DW_FORM_rnglistx] (indexed (0x0) rangelist = 0x00000018
225 # POSTCHECK-DWO-MAIN-NEXT: [0x0000000000000000, 0x0000000000000007))
226 # POSTCHECK-DWO-MAIN: DW_TAG_subprogram [8]
227 # POSTCHECK-DWO-MAIN-NEXT: DW_AT_ranges [DW_FORM_rnglistx] (indexed (0x1) rangelist = 0x0000001c
228 # POSTCHECK-DWO-MAIN-NEXT: [0x0000000000000000, 0x0000000000000051))
229 # POSTCHECK-DWO-MAIN: DW_TAG_formal_parameter [9]
230 # POSTCHECK-DWO-MAIN-NEXT: DW_AT_location [DW_FORM_loclistx] (indexed (0x0) loclist = 0x00000018:
231 # POSTCHECK-DWO-MAIN-NEXT: DW_LLE_base_addressx (0x0000000000000001)
232 # POSTCHECK-DWO-MAIN-NEXT: DW_LLE_offset_pair (0x0000000000000000, 0x0000000000000022): DW_OP_reg5 RDI
233 # POSTCHECK-DWO-MAIN-NEXT: DW_LLE_offset_pair (0x0000000000000022, 0x0000000000000051): DW_OP_entry_value(DW_OP_reg5 RDI), DW_OP_stack_value)
234 # POSTCHECK-DWO-MAIN: DW_TAG_formal_parameter [9]
235 # POSTCHECK-DWO-MAIN-NEXT: DW_AT_location [DW_FORM_loclistx] (indexed (0x1) loclist = 0x00000028:
236 # POSTCHECK-DWO-MAIN-NEXT: DW_LLE_base_addressx (0x0000000000000001)
237 # POSTCHECK-DWO-MAIN-NEXT: DW_LLE_offset_pair (0x0000000000000000, 0x0000000000000027): DW_OP_reg4 RSI
238 # POSTCHECK-DWO-MAIN-NEXT: DW_LLE_offset_pair (0x0000000000000027, 0x0000000000000051): DW_OP_entry_value(DW_OP_reg4 RSI), DW_OP_stack_value)
239 # POSTCHECK-DWO-MAIN: DW_TAG_variable [10]
240 # POSTCHECK-DWO-MAIN-NEXT: DW_AT_location [DW_FORM_loclistx] (indexed (0x2) loclist = 0x00000038:
241 # POSTCHECK-DWO-MAIN-NEXT: DW_LLE_base_addressx (0x0000000000000002)
242 # POSTCHECK-DWO-MAIN-NEXT: DW_LLE_offset_pair (0x0000000000000000, 0x0000000000000006): DW_OP_reg5 RDI
243 # POSTCHECK-DWO-MAIN-NEXT: DW_LLE_offset_pair (0x0000000000000006, 0x0000000000000046): DW_OP_reg14 R14)
244 # POSTCHECK-DWO-MAIN: DW_TAG_inlined_subroutine [12]
245 # POSTCHECK-DWO-MAIN-NEXT: DW_AT_abstract_origin [DW_FORM_ref4]
246 # POSTCHECK-DWO-MAIN-NEXT: DW_AT_ranges [DW_FORM_rnglistx] (indexed (0x2) rangelist = 0x00000020
247 # Encoded as a pair. So it's offset from base address.
248 # POSTCHECK-DWO-MAIN-NEXT: [0x0000000000000003, 0x0000000000000007)
249 # POSTCHECK-DWO-MAIN-NEXT: [0x0000000000000013, 0x0000000000000019))
251 # POSTCHECK-DWO-HELPER1: version = 0x0005
252 # POSTCHECK-DWO-HELPER1: DW_TAG_subprogram [7]
253 # POSTCHECK-DWO-HELPER1-NEXT: DW_AT_ranges [DW_FORM_rnglistx] (indexed (0x0) rangelist = 0x00000014
254 # POSTCHECK-DWO-HELPER1-NEXT: [0x0000000000000000, 0x0000000000000004))
255 # POSTCHECK-DWO-HELPER1: DW_TAG_variable [9]
256 # POSTCHECK-DWO-HELPER1-NEXT: DW_AT_location [DW_FORM_loclistx] (indexed (0x0) loclist = 0x00000010:
257 # POSTCHECK-DWO-HELPER1-NEXT: DW_LLE_base_addressx (0x0000000000000001)
258 # POSTCHECK-DWO-HELPER1-NEXT: DW_LLE_offset_pair (0x0000000000000000, 0x0000000000000003): DW_OP_reg5 RDI
259 # POSTCHECK-DWO-HELPER1-NEXT: DW_LLE_offset_pair (0x0000000000000003, 0x0000000000000004): DW_OP_reg0 RAX)
260 # POSTCHECK-DWO-HELPER1: DW_TAG_inlined_subroutine [10]
261 # POSTCHECK-DWO-HELPER1-NEXT: DW_AT_abstract_origin
262 # POSTCHECK-DWO-HELPER1-NEXT: DW_AT_ranges [DW_FORM_rnglistx] (indexed (0x1) rangelist = 0x00000018
263 # POSTCHECK-DWO-HELPER1-NEXT: [0x0000000000000000, 0x0000000000000003))
265 # Checking debug line.
267 # POSTCHECK-LINE: debug_line[
268 # POSTCHECK-LINE: version: 5
269 # POSTCHECK-LINE: include_directories[ 0] = .debug_line_str[0x[[#%.8x,LINE:]]] = "."
270 # POSTCHECK-LINE-NEXT: file_names[ 0]:
271 # POSTCHECK-LINE-NEXT: name: .debug_line_str[0x[[#%.8x,LINE:]]] = "main.cpp"
272 # POSTCHECK-LINE-NEXT: dir_index: 0
273 # POSTCHECK-LINE-NEXT: md5_checksum: e3a18fae8565a087d09d6076b542cdab
275 # POSTCHECK-LINE: debug_line[
276 # POSTCHECK-LINE: version: 4
277 # POSTCHECK-LINE: include_directories[ 1] = "/test"
278 # POSTCHECK-LINE-NEXT: file_names[ 1]:
279 # POSTCHECK-LINE-NEXT: name: "helper0.cpp"
280 # POSTCHECK-LINE-NEXT: dir_index: 1
281 # POSTCHECK-LINE-NEXT: mod_time:
282 # POSTCHECK-LINE-NEXT: length:
284 # POSTCHECK-LINE: debug_line[
285 # POSTCHECK-LINE: version: 5
286 # POSTCHECK-LINE: include_directories[ 0] = .debug_line_str[0x[[#%.8x,LINE:]]] = "."
287 # POSTCHECK-LINE-NEXT: file_names[ 0]:
288 # POSTCHECK-LINE-NEXT: name: .debug_line_str[0x[[#%.8x,LINE:]]] = "helper1.cpp"
289 # POSTCHECK-LINE-NEXT: dir_index: 0
290 # POSTCHECK-LINE-NEXT: md5_checksum: e6dbd773fdf80bfea332cdf8284cddce
292 # POSTCHECK-LINE: debug_line[
293 # POSTCHECK-LINE: version: 4
294 # POSTCHECK-LINE: include_directories[ 1] = "/test"
295 # POSTCHECK-LINE-NEXT: file_names[ 1]:
296 # POSTCHECK-LINE-NEXT: name: "helper2.cpp"
297 # POSTCHECK-LINE-NEXT: dir_index: 1
298 # POSTCHECK-LINE-NEXT: mod_time:
299 # POSTCHECK-LINE-NEXT: length: