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