2 # REQUIRES: system-linux
4 # RUN: llvm-mc -dwarf-version=5 -filetype=obj -triple x86_64-unknown-linux %s -o %tmain.o
5 # RUN: %clang %cflags -dwarf-5 %tmain.o -o %t.exe -Wl,-q
6 # RUN: llvm-bolt %t.exe -o %t.bolt --update-debug-sections
7 # RUN: llvm-dwarfdump --show-form --verbose --debug-info %t.exe | FileCheck --check-prefix=PRECHECK %s
9 # RUN: llvm-dwarfdump --show-form --verbose --debug-addr %t.bolt > %t.txt
10 # RUN: llvm-dwarfdump --show-form --verbose --debug-info %t.bolt >> %t.txt
11 # RUN: llvm-objdump -d %t.bolt >> %t.txt
12 # RUN: cat %t.txt | FileCheck --check-prefix=POSTCHECK %s
14 ## This test checks that we correctly handle DW_AT_low_pc [DW_FORM_addrx] that is part of DW_TAG_label.
16 # PRECHECK: version = 0x0005
17 # PRECHECK: DW_TAG_label
18 # PRECHECK-NEXT: DW_AT_name
19 # PRECHECK-NEXT: DW_AT_decl_file
20 # PRECHECK-NEXT: DW_AT_decl_line
21 # PRECHECK-NEXT:DW_AT_low_pc [DW_FORM_addrx] (indexed (00000001)
22 # PRECHECK: DW_TAG_label
23 # PRECHECK-NEXT: DW_AT_name
24 # PRECHECK-NEXT: DW_AT_decl_file
25 # PRECHECK-NEXT: DW_AT_decl_line
26 # PRECHECK-NEXT:DW_AT_low_pc [DW_FORM_addrx] (indexed (00000002)
32 # POSTCHECK-NEXT: 0x[[ADDR:[1-9a-f]*]]
33 # POSTCHECK-NEXT: 0x[[ADDR2:[1-9a-f]*]]
35 # POSTCHECK: version = 0x0005
36 # POSTCHECK: DW_TAG_label
37 # POSTCHECK-NEXT: DW_AT_name
38 # POSTCHECK-NEXT: DW_AT_decl_file
39 # POSTCHECK-NEXT: DW_AT_decl_line
40 # POSTCHECK-NEXT:DW_AT_low_pc [DW_FORM_addrx] (indexed (00000002)
41 # POSTCHECK-SAME: 0x[[ADDR]]
42 # POSTCHECK: DW_TAG_label
43 # POSTCHECK-NEXT: DW_AT_name
44 # POSTCHECK-NEXT: DW_AT_decl_file
45 # POSTCHECK-NEXT: DW_AT_decl_line
46 # POSTCHECK-NEXT:DW_AT_low_pc [DW_FORM_addrx] (indexed (00000003)
47 # POSTCHECK-SAME: 0x[[ADDR2]]
49 # POSTCHECK: [[ADDR]]: 8b 45 f8
50 # POSTCHECK: [[ADDR2]]: 8b 45 f8
52 ## clang++ main.cpp -g -S
66 .globl main # -- Begin function main
71 .file 0 "/testLabel" "main.cpp" md5 0xa0bd66020d06f1303de7008e3c542050
72 .loc 0 1 0 # main.cpp:1:0
76 .cfi_def_cfa_offset 16
79 .cfi_def_cfa_register %rbp
82 .loc 0 2 7 prologue_end # main.cpp:2:7
85 .loc 0 3 9 # main.cpp:3:9
88 .loc 0 3 7 is_stmt 0 # main.cpp:3:7
92 .loc 0 4 5 is_stmt 1 # main.cpp:4:5
95 .loc 0 6 5 # main.cpp:6:5
99 #DEBUG_LABEL: main:LABEL1
100 .loc 0 7 11 # main.cpp:7:11
106 #DEBUG_LABEL: main:LABEL2
107 .loc 0 8 11 # main.cpp:8:11
111 .loc 0 9 3 # main.cpp:9:3
118 .size main, .Lfunc_end0-main
121 .section .debug_abbrev,"",@progbits
122 .byte 1 # Abbreviation Code
123 .byte 17 # DW_TAG_compile_unit
124 .byte 1 # DW_CHILDREN_yes
125 .byte 37 # DW_AT_producer
126 .byte 37 # DW_FORM_strx1
127 .byte 19 # DW_AT_language
128 .byte 5 # DW_FORM_data2
130 .byte 37 # DW_FORM_strx1
131 .byte 114 # DW_AT_str_offsets_base
132 .byte 23 # DW_FORM_sec_offset
133 .byte 16 # DW_AT_stmt_list
134 .byte 23 # DW_FORM_sec_offset
135 .byte 27 # DW_AT_comp_dir
136 .byte 37 # DW_FORM_strx1
137 .byte 17 # DW_AT_low_pc
138 .byte 27 # DW_FORM_addrx
139 .byte 18 # DW_AT_high_pc
140 .byte 6 # DW_FORM_data4
141 .byte 115 # DW_AT_addr_base
142 .byte 23 # DW_FORM_sec_offset
145 .byte 2 # Abbreviation Code
146 .byte 46 # DW_TAG_subprogram
147 .byte 1 # DW_CHILDREN_yes
148 .byte 17 # DW_AT_low_pc
149 .byte 27 # DW_FORM_addrx
150 .byte 18 # DW_AT_high_pc
151 .byte 6 # DW_FORM_data4
152 .byte 64 # DW_AT_frame_base
153 .byte 24 # DW_FORM_exprloc
155 .byte 37 # DW_FORM_strx1
156 .byte 58 # DW_AT_decl_file
157 .byte 11 # DW_FORM_data1
158 .byte 59 # DW_AT_decl_line
159 .byte 11 # DW_FORM_data1
160 .byte 73 # DW_AT_type
161 .byte 19 # DW_FORM_ref4
162 .byte 63 # DW_AT_external
163 .byte 25 # DW_FORM_flag_present
166 .byte 3 # Abbreviation Code
167 .byte 52 # DW_TAG_variable
168 .byte 0 # DW_CHILDREN_no
169 .byte 2 # DW_AT_location
170 .byte 24 # DW_FORM_exprloc
172 .byte 37 # DW_FORM_strx1
173 .byte 58 # DW_AT_decl_file
174 .byte 11 # DW_FORM_data1
175 .byte 59 # DW_AT_decl_line
176 .byte 11 # DW_FORM_data1
177 .byte 73 # DW_AT_type
178 .byte 19 # DW_FORM_ref4
181 .byte 4 # Abbreviation Code
182 .byte 10 # DW_TAG_label
183 .byte 0 # DW_CHILDREN_no
185 .byte 37 # DW_FORM_strx1
186 .byte 58 # DW_AT_decl_file
187 .byte 11 # DW_FORM_data1
188 .byte 59 # DW_AT_decl_line
189 .byte 11 # DW_FORM_data1
190 .byte 17 # DW_AT_low_pc
191 .byte 27 # DW_FORM_addrx
194 .byte 5 # Abbreviation Code
195 .byte 36 # DW_TAG_base_type
196 .byte 0 # DW_CHILDREN_no
198 .byte 37 # DW_FORM_strx1
199 .byte 62 # DW_AT_encoding
200 .byte 11 # DW_FORM_data1
201 .byte 11 # DW_AT_byte_size
202 .byte 11 # DW_FORM_data1
206 .section .debug_info,"",@progbits
208 .long .Ldebug_info_end0-.Ldebug_info_start0 # Length of Unit
210 .short 5 # DWARF version number
211 .byte 1 # DWARF Unit Type
212 .byte 8 # Address Size (in bytes)
213 .long .debug_abbrev # Offset Into Abbrev. Section
214 .byte 1 # Abbrev [1] 0xc:0x41 DW_TAG_compile_unit
215 .byte 0 # DW_AT_producer
216 .short 33 # DW_AT_language
218 .long .Lstr_offsets_base0 # DW_AT_str_offsets_base
219 .long .Lline_table_start0 # DW_AT_stmt_list
220 .byte 2 # DW_AT_comp_dir
221 .byte 0 # DW_AT_low_pc
222 .long .Lfunc_end0-.Lfunc_begin0 # DW_AT_high_pc
223 .long .Laddr_table_base0 # DW_AT_addr_base
224 .byte 2 # Abbrev [2] 0x23:0x25 DW_TAG_subprogram
225 .byte 0 # DW_AT_low_pc
226 .long .Lfunc_end0-.Lfunc_begin0 # DW_AT_high_pc
227 .byte 1 # DW_AT_frame_base
230 .byte 0 # DW_AT_decl_file
231 .byte 1 # DW_AT_decl_line
232 .long 72 # DW_AT_type
234 .byte 3 # Abbrev [3] 0x32:0xb DW_TAG_variable
235 .byte 2 # DW_AT_location
239 .byte 0 # DW_AT_decl_file
240 .byte 2 # DW_AT_decl_line
241 .long 72 # DW_AT_type
242 .byte 4 # Abbrev [4] 0x3d:0x5 DW_TAG_label
244 .byte 0 # DW_AT_decl_file
245 .byte 7 # DW_AT_decl_line
246 .byte 1 # DW_AT_low_pc
247 .byte 4 # Abbrev [4] 0x42:0x5 DW_TAG_label
249 .byte 0 # DW_AT_decl_file
250 .byte 8 # DW_AT_decl_line
251 .byte 2 # DW_AT_low_pc
252 .byte 0 # End Of Children Mark
253 .byte 5 # Abbrev [5] 0x48:0x4 DW_TAG_base_type
255 .byte 5 # DW_AT_encoding
256 .byte 4 # DW_AT_byte_size
257 .byte 0 # End Of Children Mark
259 .section .debug_str_offsets,"",@progbits
260 .long 36 # Length of String Offsets Set
264 .section .debug_str,"MS",@progbits,1
266 .asciz "clang version 15.0.0" # string offset=0
268 .asciz "main.cpp" # string offset=134
270 .asciz "/testLabel" # string offset=143
272 .asciz "main" # string offset=190
274 .asciz "int" # string offset=195
276 .asciz "a" # string offset=199
278 .asciz "LABEL1" # string offset=201
280 .asciz "LABEL2" # string offset=208
281 .section .debug_str_offsets,"",@progbits
290 .section .debug_addr,"",@progbits
291 .long .Ldebug_addr_end0-.Ldebug_addr_start0 # Length of contribution
293 .short 5 # DWARF version number
294 .byte 8 # Address size
295 .byte 0 # Segment selector size
301 .ident "clang version 15.0.0"
302 .section ".note.GNU-stack","",@progbits
304 .section .debug_line,"",@progbits