439 lines · plain
1# REQUIRES: system-linux2 3# RUN: llvm-mc -dwarf-version=5 -filetype=obj -triple x86_64-unknown-linux %s -o %t1.o4# RUN: %clang %cflags -dwarf-5 %t1.o -o %t.exe -Wl,-q5# RUN: llvm-bolt %t.exe -o %t.bolt --update-debug-sections6# RUN: llvm-dwarfdump --show-form --verbose --debug-info %t.exe | FileCheck --check-prefix=PRECHECK %s7# RUN: llvm-dwarfdump --show-form --verbose --debug-addr %t.bolt > %t.txt8# RUN: llvm-dwarfdump --show-form --verbose --debug-info %t.bolt >> %t.txt9# RUN: cat %t.txt | FileCheck --check-prefix=POSTCHECK %s10 11## This tests checks that re-writing of .debug_loclists is handled correctly.12 13# PRECHECK: version = 0x000514# PRECHECK: DW_AT_loclists_base [DW_FORM_sec_offset] (0x0000000c)15# PRECHECK-EMPTY:16# PRECHECK: DW_TAG_variable17# PRECHECK: DW_AT_location [DW_FORM_loclistx]18# PRECHECK-SAME: indexed (0x0)19# PRECHECK-SAME: loclist = 0x0000001020 21# POSTCHECK: Addrs: [22# POSTCHECK-NEXT: 0x23# POSTCHECK-NEXT: 0x24# POSTCHECK-NEXT: 0x[[#%.16x,ADDR:]]25# POSTCHECK: version = 0x000526# 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_variable29# POSTCHECK: DW_AT_location [DW_FORM_loclistx]30# POSTCHECK-SAME: indexed (0x0)31# POSTCHECK-SAME: loclist = 0x0000001032# POSTCHECK-NEXT: [0x[[#ADDR]]33# POSTCHECK-SAME: 0x[[#ADDR + 0x3]]34# POSTCHECK-NEXT: [0x[[#ADDR + 0x3]]35# POSTCHECK-SAME: 0x[[#ADDR + 0x4]]36 37# clang++ main.cpp -g -O2 -S38# void use(int * x) {39# *x += 4;40# }41#42# int main(int argc, char *argv[]) {43# int x = argc;44# use(&x);45# return x;46# }47 48 .text49 .file "main.cpp"50 .globl _Z3usePi # -- Begin function _Z3usePi51 .p2align 4, 0x9052 .type _Z3usePi,@function53_Z3usePi: # @_Z3usePi54.Lfunc_begin0:55 .file 0 "testLocList" "main.cpp" md5 0x95a77c95663d823a6228bf928825e8c756 .loc 0 1 0 # main.cpp:1:057 .cfi_startproc58# %bb.0: # %entry59 #DEBUG_VALUE: use:x <- $rdi60 .loc 0 2 4 prologue_end # main.cpp:2:461 addl $4, (%rdi)62 .loc 0 3 1 # main.cpp:3:163 retq64.Ltmp0:65.Lfunc_end0:66 .size _Z3usePi, .Lfunc_end0-_Z3usePi67 .cfi_endproc68 # -- End function69 .globl main # -- Begin function main70 .p2align 4, 0x9071 .type main,@function72main: # @main73.Lfunc_begin1:74 .loc 0 5 0 # main.cpp:5:075 .cfi_startproc76# %bb.0: # %entry77 #DEBUG_VALUE: main:argc <- $edi78 #DEBUG_VALUE: main:argv <- $rsi79 #DEBUG_VALUE: main:x <- $edi80 # kill: def $edi killed $edi def $rdi81 #DEBUG_VALUE: use:x <- undef82 .loc 0 2 4 prologue_end # main.cpp:2:483 leal 4(%rdi), %eax84.Ltmp1:85 #DEBUG_VALUE: main:x <- $eax86 .loc 0 8 4 # main.cpp:8:487 retq88.Ltmp2:89.Lfunc_end1:90 .size main, .Lfunc_end1-main91 .cfi_endproc92 # -- End function93 .section .debug_loclists,"",@progbits94 .long .Ldebug_list_header_end0-.Ldebug_list_header_start0 # Length95.Ldebug_list_header_start0:96 .short 5 # Version97 .byte 8 # Address size98 .byte 0 # Segment selector size99 .long 1 # Offset entry count100.Lloclists_table_base0:101 .long .Ldebug_loc0-.Lloclists_table_base0102.Ldebug_loc0:103 .byte 4 # DW_LLE_offset_pair104 .uleb128 .Lfunc_begin1-.Lfunc_begin0 # starting offset105 .uleb128 .Ltmp1-.Lfunc_begin0 # ending offset106 .byte 1 # Loc expr size107 .byte 85 # super-register DW_OP_reg5108 .byte 4 # DW_LLE_offset_pair109 .uleb128 .Ltmp1-.Lfunc_begin0 # starting offset110 .uleb128 .Lfunc_end1-.Lfunc_begin0 # ending offset111 .byte 1 # Loc expr size112 .byte 80 # super-register DW_OP_reg0113 .byte 0 # DW_LLE_end_of_list114.Ldebug_list_header_end0:115 .section .debug_abbrev,"",@progbits116 .byte 1 # Abbreviation Code117 .byte 17 # DW_TAG_compile_unit118 .byte 1 # DW_CHILDREN_yes119 .byte 37 # DW_AT_producer120 .byte 37 # DW_FORM_strx1121 .byte 19 # DW_AT_language122 .byte 5 # DW_FORM_data2123 .byte 3 # DW_AT_name124 .byte 37 # DW_FORM_strx1125 .byte 114 # DW_AT_str_offsets_base126 .byte 23 # DW_FORM_sec_offset127 .byte 16 # DW_AT_stmt_list128 .byte 23 # DW_FORM_sec_offset129 .byte 27 # DW_AT_comp_dir130 .byte 37 # DW_FORM_strx1131 .byte 17 # DW_AT_low_pc132 .byte 27 # DW_FORM_addrx133 .byte 18 # DW_AT_high_pc134 .byte 6 # DW_FORM_data4135 .byte 115 # DW_AT_addr_base136 .byte 23 # DW_FORM_sec_offset137 .ascii "\214\001" # DW_AT_loclists_base138 .byte 23 # DW_FORM_sec_offset139 .byte 0 # EOM(1)140 .byte 0 # EOM(2)141 .byte 2 # Abbreviation Code142 .byte 46 # DW_TAG_subprogram143 .byte 1 # DW_CHILDREN_yes144 .byte 17 # DW_AT_low_pc145 .byte 27 # DW_FORM_addrx146 .byte 18 # DW_AT_high_pc147 .byte 6 # DW_FORM_data4148 .byte 64 # DW_AT_frame_base149 .byte 24 # DW_FORM_exprloc150 .byte 122 # DW_AT_call_all_calls151 .byte 25 # DW_FORM_flag_present152 .byte 49 # DW_AT_abstract_origin153 .byte 19 # DW_FORM_ref4154 .byte 0 # EOM(1)155 .byte 0 # EOM(2)156 .byte 3 # Abbreviation Code157 .byte 5 # DW_TAG_formal_parameter158 .byte 0 # DW_CHILDREN_no159 .byte 2 # DW_AT_location160 .byte 24 # DW_FORM_exprloc161 .byte 49 # DW_AT_abstract_origin162 .byte 19 # DW_FORM_ref4163 .byte 0 # EOM(1)164 .byte 0 # EOM(2)165 .byte 4 # Abbreviation Code166 .byte 46 # DW_TAG_subprogram167 .byte 1 # DW_CHILDREN_yes168 .byte 110 # DW_AT_linkage_name169 .byte 37 # DW_FORM_strx1170 .byte 3 # DW_AT_name171 .byte 37 # DW_FORM_strx1172 .byte 58 # DW_AT_decl_file173 .byte 11 # DW_FORM_data1174 .byte 59 # DW_AT_decl_line175 .byte 11 # DW_FORM_data1176 .byte 63 # DW_AT_external177 .byte 25 # DW_FORM_flag_present178 .byte 32 # DW_AT_inline179 .byte 33 # DW_FORM_implicit_const180 .byte 1181 .byte 0 # EOM(1)182 .byte 0 # EOM(2)183 .byte 5 # Abbreviation Code184 .byte 5 # DW_TAG_formal_parameter185 .byte 0 # DW_CHILDREN_no186 .byte 3 # DW_AT_name187 .byte 37 # DW_FORM_strx1188 .byte 58 # DW_AT_decl_file189 .byte 11 # DW_FORM_data1190 .byte 59 # DW_AT_decl_line191 .byte 11 # DW_FORM_data1192 .byte 73 # DW_AT_type193 .byte 19 # DW_FORM_ref4194 .byte 0 # EOM(1)195 .byte 0 # EOM(2)196 .byte 6 # Abbreviation Code197 .byte 15 # DW_TAG_pointer_type198 .byte 0 # DW_CHILDREN_no199 .byte 73 # DW_AT_type200 .byte 19 # DW_FORM_ref4201 .byte 0 # EOM(1)202 .byte 0 # EOM(2)203 .byte 7 # Abbreviation Code204 .byte 36 # DW_TAG_base_type205 .byte 0 # DW_CHILDREN_no206 .byte 3 # DW_AT_name207 .byte 37 # DW_FORM_strx1208 .byte 62 # DW_AT_encoding209 .byte 11 # DW_FORM_data1210 .byte 11 # DW_AT_byte_size211 .byte 11 # DW_FORM_data1212 .byte 0 # EOM(1)213 .byte 0 # EOM(2)214 .byte 8 # Abbreviation Code215 .byte 46 # DW_TAG_subprogram216 .byte 1 # DW_CHILDREN_yes217 .byte 17 # DW_AT_low_pc218 .byte 27 # DW_FORM_addrx219 .byte 18 # DW_AT_high_pc220 .byte 6 # DW_FORM_data4221 .byte 64 # DW_AT_frame_base222 .byte 24 # DW_FORM_exprloc223 .byte 122 # DW_AT_call_all_calls224 .byte 25 # DW_FORM_flag_present225 .byte 3 # DW_AT_name226 .byte 37 # DW_FORM_strx1227 .byte 58 # DW_AT_decl_file228 .byte 11 # DW_FORM_data1229 .byte 59 # DW_AT_decl_line230 .byte 11 # DW_FORM_data1231 .byte 73 # DW_AT_type232 .byte 19 # DW_FORM_ref4233 .byte 63 # DW_AT_external234 .byte 25 # DW_FORM_flag_present235 .byte 0 # EOM(1)236 .byte 0 # EOM(2)237 .byte 9 # Abbreviation Code238 .byte 5 # DW_TAG_formal_parameter239 .byte 0 # DW_CHILDREN_no240 .byte 2 # DW_AT_location241 .byte 24 # DW_FORM_exprloc242 .byte 3 # DW_AT_name243 .byte 37 # DW_FORM_strx1244 .byte 58 # DW_AT_decl_file245 .byte 11 # DW_FORM_data1246 .byte 59 # DW_AT_decl_line247 .byte 11 # DW_FORM_data1248 .byte 73 # DW_AT_type249 .byte 19 # DW_FORM_ref4250 .byte 0 # EOM(1)251 .byte 0 # EOM(2)252 .byte 10 # Abbreviation Code253 .byte 52 # DW_TAG_variable254 .byte 0 # DW_CHILDREN_no255 .byte 2 # DW_AT_location256 .byte 34 # DW_FORM_loclistx257 .byte 3 # DW_AT_name258 .byte 37 # DW_FORM_strx1259 .byte 58 # DW_AT_decl_file260 .byte 11 # DW_FORM_data1261 .byte 59 # DW_AT_decl_line262 .byte 11 # DW_FORM_data1263 .byte 73 # DW_AT_type264 .byte 19 # DW_FORM_ref4265 .byte 0 # EOM(1)266 .byte 0 # EOM(2)267 .byte 11 # Abbreviation Code268 .byte 29 # DW_TAG_inlined_subroutine269 .byte 0 # DW_CHILDREN_no270 .byte 49 # DW_AT_abstract_origin271 .byte 19 # DW_FORM_ref4272 .byte 17 # DW_AT_low_pc273 .byte 27 # DW_FORM_addrx274 .byte 18 # DW_AT_high_pc275 .byte 6 # DW_FORM_data4276 .byte 88 # DW_AT_call_file277 .byte 11 # DW_FORM_data1278 .byte 89 # DW_AT_call_line279 .byte 11 # DW_FORM_data1280 .byte 87 # DW_AT_call_column281 .byte 11 # DW_FORM_data1282 .byte 0 # EOM(1)283 .byte 0 # EOM(2)284 .byte 0 # EOM(3)285 .section .debug_info,"",@progbits286.Lcu_begin0:287 .long .Ldebug_info_end0-.Ldebug_info_start0 # Length of Unit288.Ldebug_info_start0:289 .short 5 # DWARF version number290 .byte 1 # DWARF Unit Type291 .byte 8 # Address Size (in bytes)292 .long .debug_abbrev # Offset Into Abbrev. Section293 .byte 1 # Abbrev [1] 0xc:0x8f DW_TAG_compile_unit294 .byte 0 # DW_AT_producer295 .short 33 # DW_AT_language296 .byte 1 # DW_AT_name297 .long .Lstr_offsets_base0 # DW_AT_str_offsets_base298 .long .Lline_table_start0 # DW_AT_stmt_list299 .byte 2 # DW_AT_comp_dir300 .byte 0 # DW_AT_low_pc301 .long .Lfunc_end1-.Lfunc_begin0 # DW_AT_high_pc302 .long .Laddr_table_base0 # DW_AT_addr_base303 .long .Lloclists_table_base0 # DW_AT_loclists_base304 .byte 2 # Abbrev [2] 0x27:0x14 DW_TAG_subprogram305 .byte 0 # DW_AT_low_pc306 .long .Lfunc_end0-.Lfunc_begin0 # DW_AT_high_pc307 .byte 1 # DW_AT_frame_base308 .byte 87309 # DW_AT_call_all_calls310 .long 59 # DW_AT_abstract_origin311 .byte 3 # Abbrev [3] 0x33:0x7 DW_TAG_formal_parameter312 .byte 1 # DW_AT_location313 .byte 85314 .long 64 # DW_AT_abstract_origin315 .byte 0 # End Of Children Mark316 .byte 4 # Abbrev [4] 0x3b:0xe DW_TAG_subprogram317 .byte 3 # DW_AT_linkage_name318 .byte 4 # DW_AT_name319 .byte 0 # DW_AT_decl_file320 .byte 1 # DW_AT_decl_line321 # DW_AT_external322 # DW_AT_inline323 .byte 5 # Abbrev [5] 0x40:0x8 DW_TAG_formal_parameter324 .byte 5 # DW_AT_name325 .byte 0 # DW_AT_decl_file326 .byte 1 # DW_AT_decl_line327 .long 73 # DW_AT_type328 .byte 0 # End Of Children Mark329 .byte 6 # Abbrev [6] 0x49:0x5 DW_TAG_pointer_type330 .long 78 # DW_AT_type331 .byte 7 # Abbrev [7] 0x4e:0x4 DW_TAG_base_type332 .byte 6 # DW_AT_name333 .byte 5 # DW_AT_encoding334 .byte 4 # DW_AT_byte_size335 .byte 8 # Abbrev [8] 0x52:0x3a DW_TAG_subprogram336 .byte 1 # DW_AT_low_pc337 .long .Lfunc_end1-.Lfunc_begin1 # DW_AT_high_pc338 .byte 1 # DW_AT_frame_base339 .byte 87340 # DW_AT_call_all_calls341 .byte 7 # DW_AT_name342 .byte 0 # DW_AT_decl_file343 .byte 5 # DW_AT_decl_line344 .long 78 # DW_AT_type345 # DW_AT_external346 .byte 9 # Abbrev [9] 0x61:0xa DW_TAG_formal_parameter347 .byte 1 # DW_AT_location348 .byte 85349 .byte 8 # DW_AT_name350 .byte 0 # DW_AT_decl_file351 .byte 5 # DW_AT_decl_line352 .long 78 # DW_AT_type353 .byte 9 # Abbrev [9] 0x6b:0xa DW_TAG_formal_parameter354 .byte 1 # DW_AT_location355 .byte 84356 .byte 9 # DW_AT_name357 .byte 0 # DW_AT_decl_file358 .byte 5 # DW_AT_decl_line359 .long 140 # DW_AT_type360 .byte 10 # Abbrev [10] 0x75:0x9 DW_TAG_variable361 .byte 0 # DW_AT_location362 .byte 5 # DW_AT_name363 .byte 0 # DW_AT_decl_file364 .byte 6 # DW_AT_decl_line365 .long 78 # DW_AT_type366 .byte 11 # Abbrev [11] 0x7e:0xd DW_TAG_inlined_subroutine367 .long 59 # DW_AT_abstract_origin368 .byte 1 # DW_AT_low_pc369 .long .Ltmp1-.Lfunc_begin1 # DW_AT_high_pc370 .byte 0 # DW_AT_call_file371 .byte 7 # DW_AT_call_line372 .byte 4 # DW_AT_call_column373 .byte 0 # End Of Children Mark374 .byte 6 # Abbrev [6] 0x8c:0x5 DW_TAG_pointer_type375 .long 145 # DW_AT_type376 .byte 6 # Abbrev [6] 0x91:0x5 DW_TAG_pointer_type377 .long 150 # DW_AT_type378 .byte 7 # Abbrev [7] 0x96:0x4 DW_TAG_base_type379 .byte 10 # DW_AT_name380 .byte 6 # DW_AT_encoding381 .byte 1 # DW_AT_byte_size382 .byte 0 # End Of Children Mark383.Ldebug_info_end0:384 .section .debug_str_offsets,"",@progbits385 .long 48 # Length of String Offsets Set386 .short 5387 .short 0388.Lstr_offsets_base0:389 .section .debug_str,"MS",@progbits,1390.Linfo_string0:391 .asciz "clang version 15.0.0)" # string offset=0392.Linfo_string1:393 .asciz "main.cpp" # string offset=134394.Linfo_string2:395 .asciz "/testLocList" # string offset=143396.Linfo_string3:397 .asciz "_Z3usePi" # string offset=192398.Linfo_string4:399 .asciz "use" # string offset=201400.Linfo_string5:401 .asciz "x" # string offset=205402.Linfo_string6:403 .asciz "int" # string offset=207404.Linfo_string7:405 .asciz "main" # string offset=211406.Linfo_string8:407 .asciz "argc" # string offset=216408.Linfo_string9:409 .asciz "argv" # string offset=221410.Linfo_string10:411 .asciz "char" # string offset=226412 .section .debug_str_offsets,"",@progbits413 .long .Linfo_string0414 .long .Linfo_string1415 .long .Linfo_string2416 .long .Linfo_string3417 .long .Linfo_string4418 .long .Linfo_string5419 .long .Linfo_string6420 .long .Linfo_string7421 .long .Linfo_string8422 .long .Linfo_string9423 .long .Linfo_string10424 .section .debug_addr,"",@progbits425 .long .Ldebug_addr_end0-.Ldebug_addr_start0 # Length of contribution426.Ldebug_addr_start0:427 .short 5 # DWARF version number428 .byte 8 # Address size429 .byte 0 # Segment selector size430.Laddr_table_base0:431 .quad .Lfunc_begin0432 .quad .Lfunc_begin1433.Ldebug_addr_end0:434 .ident "clang version 15.0.0"435 .section ".note.GNU-stack","",@progbits436 .addrsig437 .section .debug_line,"",@progbits438.Lline_table_start0:439