1# Test location list handling, including the cases of invalid input. The exact 2# behavior in the invalid cases is not particularly important, but it should be 3# "reasonable". 4 5# RUN: llvm-mc -triple=x86_64-pc-linux -filetype=obj %s --defsym LOC=0 > %t 6# RUN: %lldb %t -o "image lookup -v -a 0" -o "image lookup -v -a 2" \ 7# RUN: -o "image dump symfile" -o exit | FileCheck %s 8 9# RUN: %lldb %t -o "image lookup -v -a 0 -show-variable-ranges" -o \ 10# RUN: "image lookup -v -a 2 -show-variable-ranges" \ 11# RUN: -o exit | FileCheck %s --check-prefix=ALL-RANGES 12 13# RUN: llvm-mc -triple=x86_64-pc-linux -filetype=obj %s --defsym LOCLISTS=0 > %t 14# RUN: %lldb %t -o "image lookup -v -a 0" -o "image lookup -v -a 2" \ 15# RUN: -o "image dump symfile" -o exit | FileCheck %s --check-prefix=CHECK --check-prefix=LOCLISTS 16 17# ALL-RANGES-LABEL: image lookup -v -a 0 -show-variable-ranges 18# ALL-RANGES: Variable: id = {{.*}}, name = "x0", type = "int", valid ranges = <block>, location = [0x0000000000000000, 0x0000000000000001) -> DW_OP_reg5 RDI, [0x0000000000000001, 0x0000000000000006) -> DW_OP_reg0 RAX 19# ALL-RANGES: Variable: id = {{.*}}, name = "x1", type = "int", valid ranges = <block>, location = <empty> 20# ALL-RANGES-LABEL: image lookup -v -a 2 -show-variable-ranges 21# ALL-RANGES: Variable: id = {{.*}}, name = "x0", type = "int", valid ranges = <block>, location = [0x0000000000000000, 0x0000000000000001) -> DW_OP_reg5 RDI, [0x0000000000000001, 0x0000000000000006) -> DW_OP_reg0 RAX 22# ALL-RANGES: Variable: id = {{.*}}, name = "x1", type = "int", valid ranges = <block>, location = <empty> 23# ALL-RANGES: Variable: id = {{.*}}, name = "x3", type = "int", valid ranges = <block>, location = [0x0000000000000002, 0x0000000000000003) -> DW_OP_reg1 RDX 24 25# CHECK-LABEL: image lookup -v -a 0 26# CHECK: Variable: {{.*}}, name = "x0", type = "int", valid ranges = <block>, location = [0x0000000000000000, 0x0000000000000001) -> DW_OP_reg5 RDI 27# CHECK: Variable: {{.*}}, name = "x1", type = "int", valid ranges = <block>, location = <empty>, 28 29# CHECK-LABEL: image lookup -v -a 2 30# CHECK: Variable: {{.*}}, name = "x0", type = "int", valid ranges = <block>, location = [0x0000000000000001, 0x0000000000000006) -> DW_OP_reg0 RAX 31# CHECK: Variable: {{.*}}, name = "x1", type = "int", valid ranges = <block>, location = <empty>, 32# CHECK: Variable: {{.*}}, name = "x3", type = "int", valid ranges = <block>, location = [0x0000000000000002, 0x0000000000000003) -> DW_OP_reg1 RDX 33 34# CHECK-LABEL: image dump symfile 35# CHECK: CompileUnit{0x00000000} 36# CHECK: Function{ 37# CHECK: Variable{{.*}}, name = "x0", {{.*}}, scope = parameter, location = 38# CHECK-NEXT: [0x0000000000000000, 0x0000000000000001): DW_OP_reg5 RDI 39# CHECK-NEXT: [0x0000000000000001, 0x0000000000000006): DW_OP_reg0 RAX 40# CHECK: Variable{{.*}}, name = "x1", {{.*}}, scope = parameter 41# CHECK: Variable{{.*}}, name = "x2", {{.*}}, scope = parameter 42# CHECK: Variable{{.*}}, name = "x3", {{.*}}, scope = parameter, location = 43# CHECK-NEXT: [0x0000000000000002, 0x0000000000000003): DW_OP_reg1 RDX 44# LOCLISTS: Variable{{.*}}, name = "x4", {{.*}}, scope = parameter 45# LOCLISTS-EMPTY: 46 47.ifdef LOC 48.macro OFFSET_PAIR lo hi 49 .quad \lo 50 .quad \hi 51.endm 52 53.macro BASE_ADDRESS base 54 .quad -1 55 .quad \base 56.endm 57 58.macro EXPR_SIZE sz 59 .short \sz 60.endm 61 62.macro END_OF_LIST 63 .quad 0 64 .quad 0 65.endm 66.endif 67 68.ifdef LOCLISTS 69.macro OFFSET_PAIR lo hi 70 .byte 4 # DW_LLE_offset_pair 71 .uleb128 \lo 72 .uleb128 \hi 73.endm 74 75.macro BASE_ADDRESS base 76 .byte 6 # DW_LLE_base_address 77 .quad \base 78.endm 79 80.macro EXPR_SIZE sz 81 .uleb128 \sz 82.endm 83 84.macro END_OF_LIST 85 .byte 0 # DW_LLE_end_of_list 86.endm 87.endif 88 89 .type f,@function 90f: # @f 91.Lfunc_begin0: 92 nop 93.Ltmp0: 94 nop 95.Ltmp1: 96 nop 97.Ltmp2: 98 nop 99.Ltmp3: 100 nop 101.Ltmp4: 102 nop 103.Lfunc_end0: 104 .size f, .Lfunc_end0-f 105 106 .section .debug_str,"MS",@progbits,1 107.Linfo_string0: 108 .asciz "Hand-written DWARF" 109.Linfo_string3: 110 .asciz "f" 111.Linfo_string4: 112 .asciz "int" 113 114.ifdef LOC 115 .section .debug_loc,"",@progbits 116.endif 117.ifdef LOCLISTS 118 .section .debug_loclists,"",@progbits 119 .long .Ldebug_loclist_table_end0-.Ldebug_loclist_table_start0 # Length 120.Ldebug_loclist_table_start0: 121 .short 5 # Version 122 .byte 8 # Address size 123 .byte 0 # Segment selector size 124 .long 0 # Offset entry count 125.endif 126.Ldebug_loc0: 127 OFFSET_PAIR .Lfunc_begin0-.Lfunc_begin0, .Ltmp0-.Lfunc_begin0 128 EXPR_SIZE 1 129 .byte 85 # super-register DW_OP_reg5 130 OFFSET_PAIR .Ltmp0-.Lfunc_begin0, .Lfunc_end0-.Lfunc_begin0 131 EXPR_SIZE 1 132 .byte 80 # super-register DW_OP_reg0 133 END_OF_LIST 134 135.Ldebug_loc3: 136 BASE_ADDRESS .Ltmp1 137 OFFSET_PAIR .Ltmp1-.Ltmp1, .Ltmp2-.Ltmp1 138 EXPR_SIZE 1 139 .byte 81 # super-register DW_OP_reg1 140 END_OF_LIST 141 142.ifdef LOCLISTS 143.Ldebug_loc4: 144 .byte 3 # DW_LLE_startx_length 145 .uleb128 0xdead 146 .uleb128 1 147 EXPR_SIZE 1 148 .byte 82 # super-register DW_OP_reg2 149 END_OF_LIST 150.endif 151 152.Ldebug_loc2: 153 OFFSET_PAIR .Lfunc_begin0-.Lfunc_begin0, .Lfunc_end0-.Lfunc_begin0 154 EXPR_SIZE 0xdead 155.Ldebug_loclist_table_end0: 156 157 .section .debug_abbrev,"",@progbits 158 .byte 1 # Abbreviation Code 159 .byte 17 # DW_TAG_compile_unit 160 .byte 1 # DW_CHILDREN_yes 161 .byte 37 # DW_AT_producer 162 .byte 14 # DW_FORM_strp 163 .byte 19 # DW_AT_language 164 .byte 5 # DW_FORM_data2 165 .byte 17 # DW_AT_low_pc 166 .byte 1 # DW_FORM_addr 167 .byte 18 # DW_AT_high_pc 168 .byte 6 # DW_FORM_data4 169 .byte 0 # EOM(1) 170 .byte 0 # EOM(2) 171 .byte 2 # Abbreviation Code 172 .byte 46 # DW_TAG_subprogram 173 .byte 1 # DW_CHILDREN_yes 174 .byte 17 # DW_AT_low_pc 175 .byte 1 # DW_FORM_addr 176 .byte 18 # DW_AT_high_pc 177 .byte 6 # DW_FORM_data4 178 .byte 3 # DW_AT_name 179 .byte 14 # DW_FORM_strp 180 .byte 73 # DW_AT_type 181 .byte 19 # DW_FORM_ref4 182 .byte 0 # EOM(1) 183 .byte 0 # EOM(2) 184 .byte 3 # Abbreviation Code 185 .byte 5 # DW_TAG_formal_parameter 186 .byte 0 # DW_CHILDREN_no 187 .byte 2 # DW_AT_location 188 .byte 23 # DW_FORM_sec_offset 189 .byte 3 # DW_AT_name 190 .byte 8 # DW_FORM_string 191 .byte 73 # DW_AT_type 192 .byte 19 # DW_FORM_ref4 193 .byte 0 # EOM(1) 194 .byte 0 # EOM(2) 195 .byte 4 # Abbreviation Code 196 .byte 36 # DW_TAG_base_type 197 .byte 0 # DW_CHILDREN_no 198 .byte 3 # DW_AT_name 199 .byte 14 # DW_FORM_strp 200 .byte 62 # DW_AT_encoding 201 .byte 11 # DW_FORM_data1 202 .byte 11 # DW_AT_byte_size 203 .byte 11 # DW_FORM_data1 204 .byte 0 # EOM(1) 205 .byte 0 # EOM(2) 206 .byte 0 # EOM(3) 207 208 .section .debug_info,"",@progbits 209.Lcu_begin0: 210 .long .Ldebug_info_end0-.Ldebug_info_start0 # Length of Unit 211.Ldebug_info_start0: 212.ifdef LOC 213 .short 4 # DWARF version number 214 .long .debug_abbrev # Offset Into Abbrev. Section 215 .byte 8 # Address Size (in bytes) 216.endif 217.ifdef LOCLISTS 218 .short 5 # DWARF version number 219 .byte 1 # DWARF Unit Type 220 .byte 8 # Address Size (in bytes) 221 .long .debug_abbrev # Offset Into Abbrev. Section 222.endif 223 .byte 1 # Abbrev [1] 0xb:0x50 DW_TAG_compile_unit 224 .long .Linfo_string0 # DW_AT_producer 225 .short 12 # DW_AT_language 226 .quad .Lfunc_begin0 # DW_AT_low_pc 227 .long .Lfunc_end0-.Lfunc_begin0 # DW_AT_high_pc 228 .byte 2 # Abbrev [2] 0x2a:0x29 DW_TAG_subprogram 229 .quad .Lfunc_begin0 # DW_AT_low_pc 230 .long .Lfunc_end0-.Lfunc_begin0 # DW_AT_high_pc 231 .long .Linfo_string3 # DW_AT_name 232 .long .Lint # DW_AT_type 233 .byte 3 # Abbrev [3] DW_TAG_formal_parameter 234 .long .Ldebug_loc0 # DW_AT_location 235 .asciz "x0" # DW_AT_name 236 .long .Lint-.Lcu_begin0 # DW_AT_type 237 .byte 3 # Abbrev [3] DW_TAG_formal_parameter 238 .long 0xdeadbeef # DW_AT_location 239 .asciz "x1" # DW_AT_name 240 .long .Lint-.Lcu_begin0 # DW_AT_type 241 .byte 3 # Abbrev [3] DW_TAG_formal_parameter 242 .long .Ldebug_loc2 # DW_AT_location 243 .asciz "x2" # DW_AT_name 244 .long .Lint-.Lcu_begin0 # DW_AT_type 245 .byte 3 # Abbrev [3] DW_TAG_formal_parameter 246 .long .Ldebug_loc3 # DW_AT_location 247 .asciz "x3" # DW_AT_name 248 .long .Lint-.Lcu_begin0 # DW_AT_type 249.ifdef LOCLISTS 250 .byte 3 # Abbrev [3] DW_TAG_formal_parameter 251 .long .Ldebug_loc4 # DW_AT_location 252 .asciz "x4" # DW_AT_name 253 .long .Lint-.Lcu_begin0 # DW_AT_type 254.endif 255 .byte 0 # End Of Children Mark 256.Lint: 257 .byte 4 # Abbrev [4] 0x53:0x7 DW_TAG_base_type 258 .long .Linfo_string4 # DW_AT_name 259 .byte 5 # DW_AT_encoding 260 .byte 4 # DW_AT_byte_size 261 .byte 0 # End Of Children Mark 262.Ldebug_info_end0: 263