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
12 # This test checks that we correctly handle DW_AT_low_pc [DW_FORM_addrx] that is part of DW_TAG_label.
14 # PRECHECK: version = 0x0005
15 # PRECHECK: DW_TAG_label
16 # PRECHECK-NEXT: DW_AT_name
17 # PRECHECK-NEXT: DW_AT_decl_file
18 # PRECHECK-NEXT: DW_AT_decl_line
19 # PRECHECK-NEXT:DW_AT_low_pc [DW_FORM_addrx] (indexed (00000001)
20 # PRECHECK: DW_TAG_label
21 # PRECHECK-NEXT: DW_AT_name
22 # PRECHECK-NEXT: DW_AT_decl_file
23 # PRECHECK-NEXT: DW_AT_decl_line
24 # PRECHECK-NEXT:DW_AT_low_pc [DW_FORM_addrx] (indexed (00000002)
30 # POSTCHECK-NEXT: 0x[[#%.16x,ADDR:]]
31 # POSTCHECK-NEXT: 0x[[#%.16x,ADDR2:]]
33 # POSTCHECK: version = 0x0005
34 # POSTCHECK: DW_TAG_label
35 # POSTCHECK-NEXT: DW_AT_name
36 # POSTCHECK-NEXT: DW_AT_decl_file
37 # POSTCHECK-NEXT: DW_AT_decl_line
39 # POSTCHECK-NEXT:DW_AT_low_pc [DW_FORM_addrx] (indexed (00000002)
40 # POSTCHECK-SAME: [0x[[#ADDR]]
41 # POSTCHECK: DW_TAG_label
42 # POSTCHECK-NEXT: DW_AT_name
43 # POSTCHECK-NEXT: DW_AT_decl_file
44 # POSTCHECK-NEXT: DW_AT_decl_line
46 # POSTCHECK-NEXT:DW_AT_low_pc [DW_FORM_addrx] (indexed (00000003)
47 # POSTCHECK-SAME: [0x[[#ADDR2]]
49 # clang++ main.cpp -g -S
63 .globl main # -- Begin function main
68 .file 0 "/testLabel" "main.cpp" md5 0xa0bd66020d06f1303de7008e3c542050
69 .loc 0 1 0 # main.cpp:1:0
73 .cfi_def_cfa_offset 16
76 .cfi_def_cfa_register %rbp
79 .loc 0 2 7 prologue_end # main.cpp:2:7
82 .loc 0 3 9 # main.cpp:3:9
85 .loc 0 3 7 is_stmt 0 # main.cpp:3:7
89 .loc 0 4 5 is_stmt 1 # main.cpp:4:5
92 .loc 0 6 5 # main.cpp:6:5
96 #DEBUG_LABEL: main:LABEL1
97 .loc 0 7 11 # main.cpp:7:11
103 #DEBUG_LABEL: main:LABEL2
104 .loc 0 8 11 # main.cpp:8:11
108 .loc 0 9 3 # main.cpp:9:3
115 .size main, .Lfunc_end0-main
118 .section .debug_abbrev,"",@progbits
119 .byte 1 # Abbreviation Code
120 .byte 17 # DW_TAG_compile_unit
121 .byte 1 # DW_CHILDREN_yes
122 .byte 37 # DW_AT_producer
123 .byte 37 # DW_FORM_strx1
124 .byte 19 # DW_AT_language
125 .byte 5 # DW_FORM_data2
127 .byte 37 # DW_FORM_strx1
128 .byte 114 # DW_AT_str_offsets_base
129 .byte 23 # DW_FORM_sec_offset
130 .byte 16 # DW_AT_stmt_list
131 .byte 23 # DW_FORM_sec_offset
132 .byte 27 # DW_AT_comp_dir
133 .byte 37 # DW_FORM_strx1
134 .byte 17 # DW_AT_low_pc
135 .byte 27 # DW_FORM_addrx
136 .byte 18 # DW_AT_high_pc
137 .byte 6 # DW_FORM_data4
138 .byte 115 # DW_AT_addr_base
139 .byte 23 # DW_FORM_sec_offset
142 .byte 2 # Abbreviation Code
143 .byte 46 # DW_TAG_subprogram
144 .byte 1 # DW_CHILDREN_yes
145 .byte 17 # DW_AT_low_pc
146 .byte 27 # DW_FORM_addrx
147 .byte 18 # DW_AT_high_pc
148 .byte 6 # DW_FORM_data4
149 .byte 64 # DW_AT_frame_base
150 .byte 24 # DW_FORM_exprloc
152 .byte 37 # DW_FORM_strx1
153 .byte 58 # DW_AT_decl_file
154 .byte 11 # DW_FORM_data1
155 .byte 59 # DW_AT_decl_line
156 .byte 11 # DW_FORM_data1
157 .byte 73 # DW_AT_type
158 .byte 19 # DW_FORM_ref4
159 .byte 63 # DW_AT_external
160 .byte 25 # DW_FORM_flag_present
163 .byte 3 # Abbreviation Code
164 .byte 52 # DW_TAG_variable
165 .byte 0 # DW_CHILDREN_no
166 .byte 2 # DW_AT_location
167 .byte 24 # DW_FORM_exprloc
169 .byte 37 # DW_FORM_strx1
170 .byte 58 # DW_AT_decl_file
171 .byte 11 # DW_FORM_data1
172 .byte 59 # DW_AT_decl_line
173 .byte 11 # DW_FORM_data1
174 .byte 73 # DW_AT_type
175 .byte 19 # DW_FORM_ref4
178 .byte 4 # Abbreviation Code
179 .byte 10 # DW_TAG_label
180 .byte 0 # DW_CHILDREN_no
182 .byte 37 # DW_FORM_strx1
183 .byte 58 # DW_AT_decl_file
184 .byte 11 # DW_FORM_data1
185 .byte 59 # DW_AT_decl_line
186 .byte 11 # DW_FORM_data1
187 .byte 17 # DW_AT_low_pc
188 .byte 27 # DW_FORM_addrx
191 .byte 5 # Abbreviation Code
192 .byte 36 # DW_TAG_base_type
193 .byte 0 # DW_CHILDREN_no
195 .byte 37 # DW_FORM_strx1
196 .byte 62 # DW_AT_encoding
197 .byte 11 # DW_FORM_data1
198 .byte 11 # DW_AT_byte_size
199 .byte 11 # DW_FORM_data1
203 .section .debug_info,"",@progbits
205 .long .Ldebug_info_end0-.Ldebug_info_start0 # Length of Unit
207 .short 5 # DWARF version number
208 .byte 1 # DWARF Unit Type
209 .byte 8 # Address Size (in bytes)
210 .long .debug_abbrev # Offset Into Abbrev. Section
211 .byte 1 # Abbrev [1] 0xc:0x41 DW_TAG_compile_unit
212 .byte 0 # DW_AT_producer
213 .short 33 # DW_AT_language
215 .long .Lstr_offsets_base0 # DW_AT_str_offsets_base
216 .long .Lline_table_start0 # DW_AT_stmt_list
217 .byte 2 # DW_AT_comp_dir
218 .byte 0 # DW_AT_low_pc
219 .long .Lfunc_end0-.Lfunc_begin0 # DW_AT_high_pc
220 .long .Laddr_table_base0 # DW_AT_addr_base
221 .byte 2 # Abbrev [2] 0x23:0x25 DW_TAG_subprogram
222 .byte 0 # DW_AT_low_pc
223 .long .Lfunc_end0-.Lfunc_begin0 # DW_AT_high_pc
224 .byte 1 # DW_AT_frame_base
227 .byte 0 # DW_AT_decl_file
228 .byte 1 # DW_AT_decl_line
229 .long 72 # DW_AT_type
231 .byte 3 # Abbrev [3] 0x32:0xb DW_TAG_variable
232 .byte 2 # DW_AT_location
236 .byte 0 # DW_AT_decl_file
237 .byte 2 # DW_AT_decl_line
238 .long 72 # DW_AT_type
239 .byte 4 # Abbrev [4] 0x3d:0x5 DW_TAG_label
241 .byte 0 # DW_AT_decl_file
242 .byte 7 # DW_AT_decl_line
243 .byte 1 # DW_AT_low_pc
244 .byte 4 # Abbrev [4] 0x42:0x5 DW_TAG_label
246 .byte 0 # DW_AT_decl_file
247 .byte 8 # DW_AT_decl_line
248 .byte 2 # DW_AT_low_pc
249 .byte 0 # End Of Children Mark
250 .byte 5 # Abbrev [5] 0x48:0x4 DW_TAG_base_type
252 .byte 5 # DW_AT_encoding
253 .byte 4 # DW_AT_byte_size
254 .byte 0 # End Of Children Mark
256 .section .debug_str_offsets,"",@progbits
257 .long 36 # Length of String Offsets Set
261 .section .debug_str,"MS",@progbits,1
263 .asciz "clang version 15.0.0" # string offset=0
265 .asciz "main.cpp" # string offset=134
267 .asciz "/testLabel" # string offset=143
269 .asciz "main" # string offset=190
271 .asciz "int" # string offset=195
273 .asciz "a" # string offset=199
275 .asciz "LABEL1" # string offset=201
277 .asciz "LABEL2" # string offset=208
278 .section .debug_str_offsets,"",@progbits
287 .section .debug_addr,"",@progbits
288 .long .Ldebug_addr_end0-.Ldebug_addr_start0 # Length of contribution
290 .short 5 # DWARF version number
291 .byte 8 # Address size
292 .byte 0 # Segment selector size
298 .ident "clang version 15.0.0"
299 .section ".note.GNU-stack","",@progbits
301 .section .debug_line,"",@progbits