1 # REQUIRES: system-linux
3 # RUN: llvm-mc -dwarf-version=5 -filetype=obj -triple x86_64-unknown-linux %s -o %t1.o
4 # RUN: %clang %cflags -dwarf-5 %t1.o -o %t.exe -Wl,-q
5 # RUN: llvm-bolt %t.exe -o %t.bolt --update-debug-sections
6 # RUN: llvm-dwarfdump --show-form --verbose --debug-info %t.exe | FileCheck --check-prefix=PRECHECK %s
7 # RUN: llvm-dwarfdump --show-form --verbose --debug-addr %t.bolt > %t.txt
8 # RUN: llvm-dwarfdump --show-form --verbose --debug-info %t.bolt >> %t.txt
9 # RUN: cat %t.txt | FileCheck --check-prefix=POSTCHECK %s
11 # This tests checks that re-writing of .debug_loclists is handled correctly.
13 # PRECHECK: version = 0x0005
14 # PRECHECK: DW_AT_loclists_base [DW_FORM_sec_offset] (0x0000000c)
16 # PRECHECK: DW_TAG_variable
17 # PRECHECK: DW_AT_location [DW_FORM_loclistx]
18 # PRECHECK-SAME: indexed (0x0)
19 # PRECHECK-SAME: loclist = 0x00000010
24 # POSTCHECK-NEXT: 0x[[#%.16x,ADDR:]]
25 # POSTCHECK: version = 0x0005
26 # POSTCHECK: DW_AT_loclists_base [DW_FORM_sec_offset] (0x0000000c)
27 # POSTCHECK: DW_AT_rnglists_base [DW_FORM_sec_offset] (0x0000000c)
28 # POSTCHECK: DW_TAG_variable
29 # POSTCHECK: DW_AT_location [DW_FORM_loclistx]
30 # POSTCHECK-SAME: indexed (0x0)
31 # POSTCHECK-SAME: loclist = 0x00000010
32 # POSTCHECK-NEXT: [0x[[#ADDR]]
33 # POSTCHECK-SAME: 0x[[#ADDR + 0x3]]
34 # POSTCHECK-NEXT: [0x[[#ADDR + 0x3]]
35 # POSTCHECK-SAME: 0x[[#ADDR + 0x4]]
37 # clang++ main.cpp -g -O2 -S
42 # int main(int argc, char *argv[]) {
50 .globl _Z3usePi # -- Begin function _Z3usePi
52 .type _Z3usePi,@function
55 .file 0 "testLocList" "main.cpp" md5 0x95a77c95663d823a6228bf928825e8c7
56 .loc 0 1 0 # main.cpp:1:0
59 #DEBUG_VALUE: use:x <- $rdi
60 .loc 0 2 4 prologue_end # main.cpp:2:4
62 .loc 0 3 1 # main.cpp:3:1
66 .size _Z3usePi, .Lfunc_end0-_Z3usePi
69 .globl main # -- Begin function main
74 .loc 0 5 0 # main.cpp:5:0
77 #DEBUG_VALUE: main:argc <- $edi
78 #DEBUG_VALUE: main:argv <- $rsi
79 #DEBUG_VALUE: main:x <- $edi
80 # kill: def $edi killed $edi def $rdi
81 #DEBUG_VALUE: use:x <- undef
82 .loc 0 2 4 prologue_end # main.cpp:2:4
85 #DEBUG_VALUE: main:x <- $eax
86 .loc 0 8 4 # main.cpp:8:4
90 .size main, .Lfunc_end1-main
93 .section .debug_loclists,"",@progbits
94 .long .Ldebug_list_header_end0-.Ldebug_list_header_start0 # Length
95 .Ldebug_list_header_start0:
97 .byte 8 # Address size
98 .byte 0 # Segment selector size
99 .long 1 # Offset entry count
100 .Lloclists_table_base0:
101 .long .Ldebug_loc0-.Lloclists_table_base0
103 .byte 4 # DW_LLE_offset_pair
104 .uleb128 .Lfunc_begin1-.Lfunc_begin0 # starting offset
105 .uleb128 .Ltmp1-.Lfunc_begin0 # ending offset
106 .byte 1 # Loc expr size
107 .byte 85 # super-register DW_OP_reg5
108 .byte 4 # DW_LLE_offset_pair
109 .uleb128 .Ltmp1-.Lfunc_begin0 # starting offset
110 .uleb128 .Lfunc_end1-.Lfunc_begin0 # ending offset
111 .byte 1 # Loc expr size
112 .byte 80 # super-register DW_OP_reg0
113 .byte 0 # DW_LLE_end_of_list
114 .Ldebug_list_header_end0:
115 .section .debug_abbrev,"",@progbits
116 .byte 1 # Abbreviation Code
117 .byte 17 # DW_TAG_compile_unit
118 .byte 1 # DW_CHILDREN_yes
119 .byte 37 # DW_AT_producer
120 .byte 37 # DW_FORM_strx1
121 .byte 19 # DW_AT_language
122 .byte 5 # DW_FORM_data2
124 .byte 37 # DW_FORM_strx1
125 .byte 114 # DW_AT_str_offsets_base
126 .byte 23 # DW_FORM_sec_offset
127 .byte 16 # DW_AT_stmt_list
128 .byte 23 # DW_FORM_sec_offset
129 .byte 27 # DW_AT_comp_dir
130 .byte 37 # DW_FORM_strx1
131 .byte 17 # DW_AT_low_pc
132 .byte 27 # DW_FORM_addrx
133 .byte 18 # DW_AT_high_pc
134 .byte 6 # DW_FORM_data4
135 .byte 115 # DW_AT_addr_base
136 .byte 23 # DW_FORM_sec_offset
137 .ascii "\214\001" # DW_AT_loclists_base
138 .byte 23 # DW_FORM_sec_offset
141 .byte 2 # Abbreviation Code
142 .byte 46 # DW_TAG_subprogram
143 .byte 1 # DW_CHILDREN_yes
144 .byte 17 # DW_AT_low_pc
145 .byte 27 # DW_FORM_addrx
146 .byte 18 # DW_AT_high_pc
147 .byte 6 # DW_FORM_data4
148 .byte 64 # DW_AT_frame_base
149 .byte 24 # DW_FORM_exprloc
150 .byte 122 # DW_AT_call_all_calls
151 .byte 25 # DW_FORM_flag_present
152 .byte 49 # DW_AT_abstract_origin
153 .byte 19 # DW_FORM_ref4
156 .byte 3 # Abbreviation Code
157 .byte 5 # DW_TAG_formal_parameter
158 .byte 0 # DW_CHILDREN_no
159 .byte 2 # DW_AT_location
160 .byte 24 # DW_FORM_exprloc
161 .byte 49 # DW_AT_abstract_origin
162 .byte 19 # DW_FORM_ref4
165 .byte 4 # Abbreviation Code
166 .byte 46 # DW_TAG_subprogram
167 .byte 1 # DW_CHILDREN_yes
168 .byte 110 # DW_AT_linkage_name
169 .byte 37 # DW_FORM_strx1
171 .byte 37 # DW_FORM_strx1
172 .byte 58 # DW_AT_decl_file
173 .byte 11 # DW_FORM_data1
174 .byte 59 # DW_AT_decl_line
175 .byte 11 # DW_FORM_data1
176 .byte 63 # DW_AT_external
177 .byte 25 # DW_FORM_flag_present
178 .byte 32 # DW_AT_inline
179 .byte 33 # DW_FORM_implicit_const
183 .byte 5 # Abbreviation Code
184 .byte 5 # DW_TAG_formal_parameter
185 .byte 0 # DW_CHILDREN_no
187 .byte 37 # DW_FORM_strx1
188 .byte 58 # DW_AT_decl_file
189 .byte 11 # DW_FORM_data1
190 .byte 59 # DW_AT_decl_line
191 .byte 11 # DW_FORM_data1
192 .byte 73 # DW_AT_type
193 .byte 19 # DW_FORM_ref4
196 .byte 6 # Abbreviation Code
197 .byte 15 # DW_TAG_pointer_type
198 .byte 0 # DW_CHILDREN_no
199 .byte 73 # DW_AT_type
200 .byte 19 # DW_FORM_ref4
203 .byte 7 # Abbreviation Code
204 .byte 36 # DW_TAG_base_type
205 .byte 0 # DW_CHILDREN_no
207 .byte 37 # DW_FORM_strx1
208 .byte 62 # DW_AT_encoding
209 .byte 11 # DW_FORM_data1
210 .byte 11 # DW_AT_byte_size
211 .byte 11 # DW_FORM_data1
214 .byte 8 # Abbreviation Code
215 .byte 46 # DW_TAG_subprogram
216 .byte 1 # DW_CHILDREN_yes
217 .byte 17 # DW_AT_low_pc
218 .byte 27 # DW_FORM_addrx
219 .byte 18 # DW_AT_high_pc
220 .byte 6 # DW_FORM_data4
221 .byte 64 # DW_AT_frame_base
222 .byte 24 # DW_FORM_exprloc
223 .byte 122 # DW_AT_call_all_calls
224 .byte 25 # DW_FORM_flag_present
226 .byte 37 # DW_FORM_strx1
227 .byte 58 # DW_AT_decl_file
228 .byte 11 # DW_FORM_data1
229 .byte 59 # DW_AT_decl_line
230 .byte 11 # DW_FORM_data1
231 .byte 73 # DW_AT_type
232 .byte 19 # DW_FORM_ref4
233 .byte 63 # DW_AT_external
234 .byte 25 # DW_FORM_flag_present
237 .byte 9 # Abbreviation Code
238 .byte 5 # DW_TAG_formal_parameter
239 .byte 0 # DW_CHILDREN_no
240 .byte 2 # DW_AT_location
241 .byte 24 # DW_FORM_exprloc
243 .byte 37 # DW_FORM_strx1
244 .byte 58 # DW_AT_decl_file
245 .byte 11 # DW_FORM_data1
246 .byte 59 # DW_AT_decl_line
247 .byte 11 # DW_FORM_data1
248 .byte 73 # DW_AT_type
249 .byte 19 # DW_FORM_ref4
252 .byte 10 # Abbreviation Code
253 .byte 52 # DW_TAG_variable
254 .byte 0 # DW_CHILDREN_no
255 .byte 2 # DW_AT_location
256 .byte 34 # DW_FORM_loclistx
258 .byte 37 # DW_FORM_strx1
259 .byte 58 # DW_AT_decl_file
260 .byte 11 # DW_FORM_data1
261 .byte 59 # DW_AT_decl_line
262 .byte 11 # DW_FORM_data1
263 .byte 73 # DW_AT_type
264 .byte 19 # DW_FORM_ref4
267 .byte 11 # Abbreviation Code
268 .byte 29 # DW_TAG_inlined_subroutine
269 .byte 0 # DW_CHILDREN_no
270 .byte 49 # DW_AT_abstract_origin
271 .byte 19 # DW_FORM_ref4
272 .byte 17 # DW_AT_low_pc
273 .byte 27 # DW_FORM_addrx
274 .byte 18 # DW_AT_high_pc
275 .byte 6 # DW_FORM_data4
276 .byte 88 # DW_AT_call_file
277 .byte 11 # DW_FORM_data1
278 .byte 89 # DW_AT_call_line
279 .byte 11 # DW_FORM_data1
280 .byte 87 # DW_AT_call_column
281 .byte 11 # DW_FORM_data1
285 .section .debug_info,"",@progbits
287 .long .Ldebug_info_end0-.Ldebug_info_start0 # Length of Unit
289 .short 5 # DWARF version number
290 .byte 1 # DWARF Unit Type
291 .byte 8 # Address Size (in bytes)
292 .long .debug_abbrev # Offset Into Abbrev. Section
293 .byte 1 # Abbrev [1] 0xc:0x8f DW_TAG_compile_unit
294 .byte 0 # DW_AT_producer
295 .short 33 # DW_AT_language
297 .long .Lstr_offsets_base0 # DW_AT_str_offsets_base
298 .long .Lline_table_start0 # DW_AT_stmt_list
299 .byte 2 # DW_AT_comp_dir
300 .byte 0 # DW_AT_low_pc
301 .long .Lfunc_end1-.Lfunc_begin0 # DW_AT_high_pc
302 .long .Laddr_table_base0 # DW_AT_addr_base
303 .long .Lloclists_table_base0 # DW_AT_loclists_base
304 .byte 2 # Abbrev [2] 0x27:0x14 DW_TAG_subprogram
305 .byte 0 # DW_AT_low_pc
306 .long .Lfunc_end0-.Lfunc_begin0 # DW_AT_high_pc
307 .byte 1 # DW_AT_frame_base
309 # DW_AT_call_all_calls
310 .long 59 # DW_AT_abstract_origin
311 .byte 3 # Abbrev [3] 0x33:0x7 DW_TAG_formal_parameter
312 .byte 1 # DW_AT_location
314 .long 64 # DW_AT_abstract_origin
315 .byte 0 # End Of Children Mark
316 .byte 4 # Abbrev [4] 0x3b:0xe DW_TAG_subprogram
317 .byte 3 # DW_AT_linkage_name
319 .byte 0 # DW_AT_decl_file
320 .byte 1 # DW_AT_decl_line
323 .byte 5 # Abbrev [5] 0x40:0x8 DW_TAG_formal_parameter
325 .byte 0 # DW_AT_decl_file
326 .byte 1 # DW_AT_decl_line
327 .long 73 # DW_AT_type
328 .byte 0 # End Of Children Mark
329 .byte 6 # Abbrev [6] 0x49:0x5 DW_TAG_pointer_type
330 .long 78 # DW_AT_type
331 .byte 7 # Abbrev [7] 0x4e:0x4 DW_TAG_base_type
333 .byte 5 # DW_AT_encoding
334 .byte 4 # DW_AT_byte_size
335 .byte 8 # Abbrev [8] 0x52:0x3a DW_TAG_subprogram
336 .byte 1 # DW_AT_low_pc
337 .long .Lfunc_end1-.Lfunc_begin1 # DW_AT_high_pc
338 .byte 1 # DW_AT_frame_base
340 # DW_AT_call_all_calls
342 .byte 0 # DW_AT_decl_file
343 .byte 5 # DW_AT_decl_line
344 .long 78 # DW_AT_type
346 .byte 9 # Abbrev [9] 0x61:0xa DW_TAG_formal_parameter
347 .byte 1 # DW_AT_location
350 .byte 0 # DW_AT_decl_file
351 .byte 5 # DW_AT_decl_line
352 .long 78 # DW_AT_type
353 .byte 9 # Abbrev [9] 0x6b:0xa DW_TAG_formal_parameter
354 .byte 1 # DW_AT_location
357 .byte 0 # DW_AT_decl_file
358 .byte 5 # DW_AT_decl_line
359 .long 140 # DW_AT_type
360 .byte 10 # Abbrev [10] 0x75:0x9 DW_TAG_variable
361 .byte 0 # DW_AT_location
363 .byte 0 # DW_AT_decl_file
364 .byte 6 # DW_AT_decl_line
365 .long 78 # DW_AT_type
366 .byte 11 # Abbrev [11] 0x7e:0xd DW_TAG_inlined_subroutine
367 .long 59 # DW_AT_abstract_origin
368 .byte 1 # DW_AT_low_pc
369 .long .Ltmp1-.Lfunc_begin1 # DW_AT_high_pc
370 .byte 0 # DW_AT_call_file
371 .byte 7 # DW_AT_call_line
372 .byte 4 # DW_AT_call_column
373 .byte 0 # End Of Children Mark
374 .byte 6 # Abbrev [6] 0x8c:0x5 DW_TAG_pointer_type
375 .long 145 # DW_AT_type
376 .byte 6 # Abbrev [6] 0x91:0x5 DW_TAG_pointer_type
377 .long 150 # DW_AT_type
378 .byte 7 # Abbrev [7] 0x96:0x4 DW_TAG_base_type
379 .byte 10 # DW_AT_name
380 .byte 6 # DW_AT_encoding
381 .byte 1 # DW_AT_byte_size
382 .byte 0 # End Of Children Mark
384 .section .debug_str_offsets,"",@progbits
385 .long 48 # Length of String Offsets Set
389 .section .debug_str,"MS",@progbits,1
391 .asciz "clang version 15.0.0)" # string offset=0
393 .asciz "main.cpp" # string offset=134
395 .asciz "/testLocList" # string offset=143
397 .asciz "_Z3usePi" # string offset=192
399 .asciz "use" # string offset=201
401 .asciz "x" # string offset=205
403 .asciz "int" # string offset=207
405 .asciz "main" # string offset=211
407 .asciz "argc" # string offset=216
409 .asciz "argv" # string offset=221
411 .asciz "char" # string offset=226
412 .section .debug_str_offsets,"",@progbits
423 .long .Linfo_string10
424 .section .debug_addr,"",@progbits
425 .long .Ldebug_addr_end0-.Ldebug_addr_start0 # Length of contribution
427 .short 5 # DWARF version number
428 .byte 8 # Address size
429 .byte 0 # Segment selector size
434 .ident "clang version 15.0.0"
435 .section ".note.GNU-stack","",@progbits
437 .section .debug_line,"",@progbits