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