1## Check that the --debug-vars option works for simple register locations, when 2## using DWARF4 debug info, with multiple functions in one section. 3 4## Generated with this compile command and source code: 5## clang --target=arm--none-eabi -march=armv7-a -c debug.c -O1 -gdwarf-3 -S -o - 6 7## clang --target=powerpc64-unknown-linux -c debug.c -O1 -S -o - 8 9## int foo(int a, int b, int c) { 10## int x = a + b; 11## int y = x + c; 12## return y; 13## } 14## 15## int bar(int a) { 16## a++; 17## return a; 18## } 19 20# RUN: llvm-mc -triple powerpc64-unknown-linux < %s -filetype=obj | \ 21# RUN: llvm-objdump - -d --debug-vars --no-show-raw-insn | \ 22# RUN: FileCheck %s 23 24# CHECK: Disassembly of section .text: 25# CHECK-EMPTY: 26# CHECK-NEXT: 0000000000000000 <.text>: 27# CHECK-NEXT: ┠─ a = S3 28# CHECK-NEXT: ┃ ┠─ b = S4 29# CHECK-NEXT: ┃ ┃ ┠─ c = S5 30# CHECK-NEXT: ┃ ┃ ┃ ┌─ x = S3 31# CHECK-NEXT: 0: add 3, 4, 3 ┻ ┃ ┃ ╈ 32# CHECK-NEXT: ┌─ y = S3 33# CHECK-NEXT: 4: add 3, 3, 5 ╈ ┃ ┃ ┻ 34# CHECK-NEXT: 8: extsw 3, 3 ┻ ┃ ┃ 35# CHECK-NEXT: c: blr ┃ ┃ 36# CHECK-NEXT: ... 37# CHECK-NEXT: ┠─ a = S3 38# CHECK-NEXT: 1c: addi 3, 3, 1 ┃ 39# CHECK-NEXT: 20: extsw 3, 3 ┻ 40# CHECK-NEXT: 24: blr 41# CHECK-NEXT: ... 42 43 .text 44 .file "debug.c" 45 .globl foo # -- Begin function foo 46 .p2align 2 47 .type foo,@function 48 .section .opd,"aw",@progbits 49foo: # @foo 50 .p2align 3 51 .quad .Lfunc_begin0 52 .quad .TOC.@tocbase 53 .quad 0 54 .text 55.Lfunc_begin0: 56 .file 1 "/work" "llvm/src/llvm/test/tools/llvm-objdump/ARM/Inputs/debug.c" 57 .loc 1 1 0 # llvm/src/llvm/test/tools/llvm-objdump/ARM/Inputs/debug.c:1:0 58 .cfi_sections .debug_frame 59 .cfi_startproc 60# %bb.0: # %entry 61 #DEBUG_VALUE: foo:a <- $x3 62 #DEBUG_VALUE: foo:a <- $r3 63 #DEBUG_VALUE: foo:b <- $x4 64 #DEBUG_VALUE: foo:b <- $x4 65 #DEBUG_VALUE: foo:b <- $r4 66 #DEBUG_VALUE: foo:c <- $x5 67 #DEBUG_VALUE: foo:c <- $x5 68 #DEBUG_VALUE: foo:c <- $r5 69 .loc 1 2 13 prologue_end # llvm/src/llvm/test/tools/llvm-objdump/ARM/Inputs/debug.c:2:13 70 add 3, 4, 3 71.Ltmp0: 72 #DEBUG_VALUE: foo:x <- $r3 73 .loc 1 3 13 # llvm/src/llvm/test/tools/llvm-objdump/ARM/Inputs/debug.c:3:13 74 add 3, 3, 5 75.Ltmp1: 76 #DEBUG_VALUE: foo:y <- $r3 77 .loc 1 4 3 # llvm/src/llvm/test/tools/llvm-objdump/ARM/Inputs/debug.c:4:3 78 extsw 3, 3 79.Ltmp2: 80 blr 81.Ltmp3: 82 .long 0 83 .quad 0 84.Lfunc_end0: 85 .size foo, .Lfunc_end0-.Lfunc_begin0 86 .cfi_endproc 87 # -- End function 88 .globl bar # -- Begin function bar 89 .p2align 2 90 .type bar,@function 91 .section .opd,"aw",@progbits 92bar: # @bar 93 .p2align 3 94 .quad .Lfunc_begin1 95 .quad .TOC.@tocbase 96 .quad 0 97 .text 98.Lfunc_begin1: 99 .loc 1 7 0 # llvm/src/llvm/test/tools/llvm-objdump/ARM/Inputs/debug.c:7:0 100 .cfi_startproc 101# %bb.0: # %entry 102 #DEBUG_VALUE: bar:a <- $x3 103 #DEBUG_VALUE: bar:a <- $r3 104 .loc 1 8 4 prologue_end # llvm/src/llvm/test/tools/llvm-objdump/ARM/Inputs/debug.c:8:4 105 addi 3, 3, 1 106.Ltmp4: 107 #DEBUG_VALUE: bar:a <- $r3 108 .loc 1 9 3 # llvm/src/llvm/test/tools/llvm-objdump/ARM/Inputs/debug.c:9:3 109 extsw 3, 3 110.Ltmp5: 111 blr 112.Ltmp6: 113 .long 0 114 .quad 0 115.Lfunc_end1: 116 .size bar, .Lfunc_end1-.Lfunc_begin1 117 .cfi_endproc 118 # -- End function 119 .section .debug_str,"MS",@progbits,1 120.Linfo_string0: 121 .asciz "clang version 10.0.0 (git@github.com:llvm/llvm-project.git e73f78acd34360f7450b81167d9dc858ccddc262)" # string offset=0 122.Linfo_string1: 123 .asciz "/work/llvm/src/llvm/test/tools/llvm-objdump/ARM/Inputs/debug.c" # string offset=101 124.Linfo_string2: 125 .asciz "/work/scratch" # string offset=164 126.Linfo_string3: 127 .asciz "foo" # string offset=178 128.Linfo_string4: 129 .asciz "int" # string offset=182 130.Linfo_string5: 131 .asciz "bar" # string offset=186 132.Linfo_string6: 133 .asciz "a" # string offset=190 134.Linfo_string7: 135 .asciz "b" # string offset=192 136.Linfo_string8: 137 .asciz "c" # string offset=194 138.Linfo_string9: 139 .asciz "x" # string offset=196 140.Linfo_string10: 141 .asciz "y" # string offset=198 142 .section .debug_loc,"",@progbits 143.Ldebug_loc0: 144 .quad .Lfunc_begin0-.Lfunc_begin0 145 .quad .Ltmp0-.Lfunc_begin0 146 .short 3 # Loc expr size 147 .byte 144 # super-register DW_OP_regx 148 .byte 179 # 1203 149 .byte 9 # 150 .quad 0 151 .quad 0 152.Ldebug_loc1: 153 .quad .Ltmp0-.Lfunc_begin0 154 .quad .Ltmp1-.Lfunc_begin0 155 .short 3 # Loc expr size 156 .byte 144 # super-register DW_OP_regx 157 .byte 179 # 1203 158 .byte 9 # 159 .quad 0 160 .quad 0 161.Ldebug_loc2: 162 .quad .Ltmp1-.Lfunc_begin0 163 .quad .Ltmp2-.Lfunc_begin0 164 .short 3 # Loc expr size 165 .byte 144 # super-register DW_OP_regx 166 .byte 179 # 1203 167 .byte 9 # 168 .quad 0 169 .quad 0 170.Ldebug_loc3: 171 .quad .Lfunc_begin1-.Lfunc_begin0 172 .quad .Ltmp5-.Lfunc_begin0 173 .short 3 # Loc expr size 174 .byte 144 # super-register DW_OP_regx 175 .byte 179 # 1203 176 .byte 9 # 177 .quad 0 178 .quad 0 179 .section .debug_abbrev,"",@progbits 180 .byte 1 # Abbreviation Code 181 .byte 17 # DW_TAG_compile_unit 182 .byte 1 # DW_CHILDREN_yes 183 .byte 37 # DW_AT_producer 184 .byte 14 # DW_FORM_strp 185 .byte 19 # DW_AT_language 186 .byte 5 # DW_FORM_data2 187 .byte 3 # DW_AT_name 188 .byte 14 # DW_FORM_strp 189 .byte 16 # DW_AT_stmt_list 190 .byte 23 # DW_FORM_sec_offset 191 .byte 27 # DW_AT_comp_dir 192 .byte 14 # DW_FORM_strp 193 .byte 17 # DW_AT_low_pc 194 .byte 1 # DW_FORM_addr 195 .byte 18 # DW_AT_high_pc 196 .byte 6 # DW_FORM_data4 197 .byte 0 # EOM(1) 198 .byte 0 # EOM(2) 199 .byte 2 # Abbreviation Code 200 .byte 46 # DW_TAG_subprogram 201 .byte 1 # DW_CHILDREN_yes 202 .byte 17 # DW_AT_low_pc 203 .byte 1 # DW_FORM_addr 204 .byte 18 # DW_AT_high_pc 205 .byte 6 # DW_FORM_data4 206 .byte 64 # DW_AT_frame_base 207 .byte 24 # DW_FORM_exprloc 208 .ascii "\227B" # DW_AT_GNU_all_call_sites 209 .byte 25 # DW_FORM_flag_present 210 .byte 3 # DW_AT_name 211 .byte 14 # DW_FORM_strp 212 .byte 58 # DW_AT_decl_file 213 .byte 11 # DW_FORM_data1 214 .byte 59 # DW_AT_decl_line 215 .byte 11 # DW_FORM_data1 216 .byte 39 # DW_AT_prototyped 217 .byte 25 # DW_FORM_flag_present 218 .byte 73 # DW_AT_type 219 .byte 19 # DW_FORM_ref4 220 .byte 63 # DW_AT_external 221 .byte 25 # DW_FORM_flag_present 222 .byte 0 # EOM(1) 223 .byte 0 # EOM(2) 224 .byte 3 # Abbreviation Code 225 .byte 5 # DW_TAG_formal_parameter 226 .byte 0 # DW_CHILDREN_no 227 .byte 2 # DW_AT_location 228 .byte 23 # DW_FORM_sec_offset 229 .byte 3 # DW_AT_name 230 .byte 14 # DW_FORM_strp 231 .byte 58 # DW_AT_decl_file 232 .byte 11 # DW_FORM_data1 233 .byte 59 # DW_AT_decl_line 234 .byte 11 # DW_FORM_data1 235 .byte 73 # DW_AT_type 236 .byte 19 # DW_FORM_ref4 237 .byte 0 # EOM(1) 238 .byte 0 # EOM(2) 239 .byte 4 # Abbreviation Code 240 .byte 5 # DW_TAG_formal_parameter 241 .byte 0 # DW_CHILDREN_no 242 .byte 2 # DW_AT_location 243 .byte 24 # DW_FORM_exprloc 244 .byte 3 # DW_AT_name 245 .byte 14 # DW_FORM_strp 246 .byte 58 # DW_AT_decl_file 247 .byte 11 # DW_FORM_data1 248 .byte 59 # DW_AT_decl_line 249 .byte 11 # DW_FORM_data1 250 .byte 73 # DW_AT_type 251 .byte 19 # DW_FORM_ref4 252 .byte 0 # EOM(1) 253 .byte 0 # EOM(2) 254 .byte 5 # Abbreviation Code 255 .byte 52 # DW_TAG_variable 256 .byte 0 # DW_CHILDREN_no 257 .byte 2 # DW_AT_location 258 .byte 23 # DW_FORM_sec_offset 259 .byte 3 # DW_AT_name 260 .byte 14 # DW_FORM_strp 261 .byte 58 # DW_AT_decl_file 262 .byte 11 # DW_FORM_data1 263 .byte 59 # DW_AT_decl_line 264 .byte 11 # DW_FORM_data1 265 .byte 73 # DW_AT_type 266 .byte 19 # DW_FORM_ref4 267 .byte 0 # EOM(1) 268 .byte 0 # EOM(2) 269 .byte 6 # Abbreviation Code 270 .byte 36 # DW_TAG_base_type 271 .byte 0 # DW_CHILDREN_no 272 .byte 3 # DW_AT_name 273 .byte 14 # DW_FORM_strp 274 .byte 62 # DW_AT_encoding 275 .byte 11 # DW_FORM_data1 276 .byte 11 # DW_AT_byte_size 277 .byte 11 # DW_FORM_data1 278 .byte 0 # EOM(1) 279 .byte 0 # EOM(2) 280 .byte 0 # EOM(3) 281 .section .debug_info,"",@progbits 282.Lcu_begin0: 283 .long .Ldebug_info_end0-.Ldebug_info_start0 # Length of Unit 284.Ldebug_info_start0: 285 .short 4 # DWARF version number 286 .long .debug_abbrev # Offset Into Abbrev. Section 287 .byte 8 # Address Size (in bytes) 288 .byte 1 # Abbrev [1] 0xb:0xb5 DW_TAG_compile_unit 289 .long .Linfo_string0 # DW_AT_producer 290 .short 12 # DW_AT_language 291 .long .Linfo_string1 # DW_AT_name 292 .long .Lline_table_start0 # DW_AT_stmt_list 293 .long .Linfo_string2 # DW_AT_comp_dir 294 .quad .Lfunc_begin0 # DW_AT_low_pc 295 .long .Lfunc_end1-.Lfunc_begin0 # DW_AT_high_pc 296 .byte 2 # Abbrev [2] 0x2a:0x65 DW_TAG_subprogram 297 .quad .Lfunc_begin0 # DW_AT_low_pc 298 .long .Lfunc_end0-.Lfunc_begin0 # DW_AT_high_pc 299 .byte 1 # DW_AT_frame_base 300 .byte 81 301 # DW_AT_GNU_all_call_sites 302 .long .Linfo_string3 # DW_AT_name 303 .byte 1 # DW_AT_decl_file 304 .byte 1 # DW_AT_decl_line 305 # DW_AT_prototyped 306 .long 184 # DW_AT_type 307 # DW_AT_external 308 .byte 3 # Abbrev [3] 0x43:0xf DW_TAG_formal_parameter 309 .long .Ldebug_loc0 # DW_AT_location 310 .long .Linfo_string6 # DW_AT_name 311 .byte 1 # DW_AT_decl_file 312 .byte 1 # DW_AT_decl_line 313 .long 184 # DW_AT_type 314 .byte 4 # Abbrev [4] 0x52:0xf DW_TAG_formal_parameter 315 .byte 3 # DW_AT_location 316 .byte 144 317 .ascii "\264\t" 318 .long .Linfo_string7 # DW_AT_name 319 .byte 1 # DW_AT_decl_file 320 .byte 1 # DW_AT_decl_line 321 .long 184 # DW_AT_type 322 .byte 4 # Abbrev [4] 0x61:0xf DW_TAG_formal_parameter 323 .byte 3 # DW_AT_location 324 .byte 144 325 .ascii "\265\t" 326 .long .Linfo_string8 # DW_AT_name 327 .byte 1 # DW_AT_decl_file 328 .byte 1 # DW_AT_decl_line 329 .long 184 # DW_AT_type 330 .byte 5 # Abbrev [5] 0x70:0xf DW_TAG_variable 331 .long .Ldebug_loc1 # DW_AT_location 332 .long .Linfo_string9 # DW_AT_name 333 .byte 1 # DW_AT_decl_file 334 .byte 2 # DW_AT_decl_line 335 .long 184 # DW_AT_type 336 .byte 5 # Abbrev [5] 0x7f:0xf DW_TAG_variable 337 .long .Ldebug_loc2 # DW_AT_location 338 .long .Linfo_string10 # DW_AT_name 339 .byte 1 # DW_AT_decl_file 340 .byte 3 # DW_AT_decl_line 341 .long 184 # DW_AT_type 342 .byte 0 # End Of Children Mark 343 .byte 2 # Abbrev [2] 0x8f:0x29 DW_TAG_subprogram 344 .quad .Lfunc_begin1 # DW_AT_low_pc 345 .long .Lfunc_end1-.Lfunc_begin1 # DW_AT_high_pc 346 .byte 1 # DW_AT_frame_base 347 .byte 81 348 # DW_AT_GNU_all_call_sites 349 .long .Linfo_string5 # DW_AT_name 350 .byte 1 # DW_AT_decl_file 351 .byte 7 # DW_AT_decl_line 352 # DW_AT_prototyped 353 .long 184 # DW_AT_type 354 # DW_AT_external 355 .byte 3 # Abbrev [3] 0xa8:0xf DW_TAG_formal_parameter 356 .long .Ldebug_loc3 # DW_AT_location 357 .long .Linfo_string6 # DW_AT_name 358 .byte 1 # DW_AT_decl_file 359 .byte 7 # DW_AT_decl_line 360 .long 184 # DW_AT_type 361 .byte 0 # End Of Children Mark 362 .byte 6 # Abbrev [6] 0xb8:0x7 DW_TAG_base_type 363 .long .Linfo_string4 # DW_AT_name 364 .byte 5 # DW_AT_encoding 365 .byte 4 # DW_AT_byte_size 366 .byte 0 # End Of Children Mark 367.Ldebug_info_end0: 368 .ident "clang version 10.0.0 (git@github.com:llvm/llvm-project.git e73f78acd34360f7450b81167d9dc858ccddc262)" 369 .section ".note.GNU-stack","",@progbits 370 .addrsig 371 .section .debug_line,"",@progbits 372.Lline_table_start0: 373