1# Test handling of (optimized-out/location-less) variables whose value is 2# specified by DW_AT_const_value 3 4# RUN: llvm-mc -filetype=obj -triple x86_64-pc-linux %s -o %t 5# RUN: %lldb %t \ 6# RUN: -o "target variable udata data1 data2 data4 data8 string strp ref4 udata_ptr" \ 7# RUN: -o exit | FileCheck %s 8 9# CHECK-LABEL: target variable 10## Variable specified via DW_FORM_udata. This is typical for clang (10). 11# CHECK: (unsigned long) udata = 4742474247424742 12## Variables specified via fixed-size forms. This is typical for gcc (9). 13# CHECK: (unsigned long) data1 = 47 14# CHECK: (unsigned long) data2 = 4742 15# CHECK: (unsigned long) data4 = 47424742 16# CHECK: (unsigned long) data8 = 4742474247424742 17## Variables specified using string forms. This behavior purely speculative -- I 18## don't know of any compiler that would represent character strings this way. 19# CHECK: (char[7]) string = "string" 20# CHECK: (char[7]) strp = "strp\0\0" 21## Bogus attribute form. Let's make sure we don't crash at least. 22# CHECK: (char[7]) ref4 = <empty constant data> 23## A variable of pointer type. 24# CHECK: (unsigned long *) udata_ptr = 0xdeadbeefbaadf00d 25 26 .section .debug_abbrev,"",@progbits 27 .byte 1 # Abbreviation Code 28 .byte 17 # DW_TAG_compile_unit 29 .byte 1 # DW_CHILDREN_yes 30 .byte 37 # DW_AT_producer 31 .byte 8 # DW_FORM_string 32 .byte 3 # DW_AT_name 33 .byte 8 # DW_FORM_string 34 .byte 0 # EOM(1) 35 .byte 0 # EOM(2) 36 .byte 2 # Abbreviation Code 37 .byte 15 # DW_TAG_pointer_type 38 .byte 0 # DW_CHILDREN_no 39 .byte 73 # DW_AT_type 40 .byte 19 # DW_FORM_ref4 41 .byte 0 # EOM(1) 42 .byte 0 # EOM(2) 43 .byte 4 # Abbreviation Code 44 .byte 1 # DW_TAG_array_type 45 .byte 1 # DW_CHILDREN_yes 46 .byte 73 # DW_AT_type 47 .byte 19 # DW_FORM_ref4 48 .byte 0 # EOM(1) 49 .byte 0 # EOM(2) 50 .byte 5 # Abbreviation Code 51 .byte 33 # DW_TAG_subrange_type 52 .byte 0 # DW_CHILDREN_no 53 .byte 73 # DW_AT_type 54 .byte 19 # DW_FORM_ref4 55 .byte 55 # DW_AT_count 56 .byte 11 # DW_FORM_data1 57 .byte 0 # EOM(1) 58 .byte 0 # EOM(2) 59 .byte 6 # Abbreviation Code 60 .byte 36 # DW_TAG_base_type 61 .byte 0 # DW_CHILDREN_no 62 .byte 3 # DW_AT_name 63 .byte 8 # DW_FORM_string 64 .byte 11 # DW_AT_byte_size 65 .byte 11 # DW_FORM_data1 66 .byte 62 # DW_AT_encoding 67 .byte 11 # DW_FORM_data1 68 .byte 0 # EOM(1) 69 .byte 0 # EOM(2) 70.macro var code, form 71 .byte \code # Abbreviation Code 72 .byte 52 # DW_TAG_variable 73 .byte 0 # DW_CHILDREN_no 74 .byte 3 # DW_AT_name 75 .byte 8 # DW_FORM_string 76 .byte 73 # DW_AT_type 77 .byte 19 # DW_FORM_ref4 78 .byte 28 # DW_AT_const_value 79 .byte \form 80 .byte 0 # EOM(1) 81 .byte 0 # EOM(2) 82.endm 83 var 10, 0xf # DW_FORM_udata 84 var 11, 0xb # DW_FORM_data1 85 var 12, 0x5 # DW_FORM_data2 86 var 13, 0x6 # DW_FORM_data4 87 var 14, 0x7 # DW_FORM_data8 88 var 15, 0x8 # DW_FORM_string 89 var 16, 0xe # DW_FORM_strp 90 var 17, 0x13 # DW_FORM_ref4 91 .byte 0 # EOM(3) 92 .section .debug_info,"",@progbits 93.Lcu_begin0: 94 .long .Ldebug_info_end0-.Ldebug_info_start0 # Length of Unit 95.Ldebug_info_start0: 96 .short 4 # DWARF version number 97 .long .debug_abbrev # Offset Into Abbrev. Section 98 .byte 8 # Address Size (in bytes) 99 .byte 1 # Abbrev DW_TAG_compile_unit 100 .asciz "Hand-written DWARF" # DW_AT_producer 101 .asciz "const.c" # DW_AT_name 102.Lchar_arr: 103 .byte 4 # Abbrev DW_TAG_array_type 104 .long .Lchar-.Lcu_begin0 # DW_AT_type 105 .byte 5 # Abbrev DW_TAG_subrange_type 106 .long .Lulong-.Lcu_begin0 # DW_AT_type 107 .byte 7 # DW_AT_count 108 .byte 0 # End Of Children Mark 109.Lchar: 110 .byte 6 # Abbrev DW_TAG_base_type 111 .asciz "char" # DW_AT_name 112 .byte 1 # DW_AT_byte_size 113 .byte 6 # DW_AT_encoding 114.Lulong: 115 .byte 6 # Abbrev DW_TAG_base_type 116 .asciz "unsigned long" # DW_AT_name 117 .byte 8 # DW_AT_byte_size 118 .byte 7 # DW_AT_encoding 119.Lulong_ptr: 120 .byte 2 # Abbrev DW_TAG_pointer_type 121 .long .Lulong-.Lcu_begin0 # DW_AT_type 122 123 .byte 10 # Abbrev DW_TAG_variable 124 .asciz "udata" # DW_AT_name 125 .long .Lulong-.Lcu_begin0 # DW_AT_type 126 .uleb128 4742474247424742 # DW_AT_const_value 127 128 .byte 11 # Abbrev DW_TAG_variable 129 .asciz "data1" # DW_AT_name 130 .long .Lulong-.Lcu_begin0 # DW_AT_type 131 .byte 47 # DW_AT_const_value 132 133 .byte 12 # Abbrev DW_TAG_variable 134 .asciz "data2" # DW_AT_name 135 .long .Lulong-.Lcu_begin0 # DW_AT_type 136 .word 4742 # DW_AT_const_value 137 138 .byte 13 # Abbrev DW_TAG_variable 139 .asciz "data4" # DW_AT_name 140 .long .Lulong-.Lcu_begin0 # DW_AT_type 141 .long 47424742 # DW_AT_const_value 142 143 .byte 14 # Abbrev DW_TAG_variable 144 .asciz "data8" # DW_AT_name 145 .long .Lulong-.Lcu_begin0 # DW_AT_type 146 .quad 4742474247424742 # DW_AT_const_value 147 148 .byte 15 # Abbrev DW_TAG_variable 149 .asciz "string" # DW_AT_name 150 .long .Lchar_arr-.Lcu_begin0 # DW_AT_type 151 .asciz "string" # DW_AT_const_value 152 153 .byte 16 # Abbrev DW_TAG_variable 154 .asciz "strp" # DW_AT_name 155 .long .Lchar_arr-.Lcu_begin0 # DW_AT_type 156 .long .Lstrp # DW_AT_const_value 157 158 .byte 17 # Abbrev DW_TAG_variable 159 .asciz "ref4" # DW_AT_name 160 .long .Lchar_arr-.Lcu_begin0 # DW_AT_type 161 .long .Lulong-.Lcu_begin0 # DW_AT_const_value 162 163 .byte 10 # Abbrev DW_TAG_variable 164 .asciz "udata_ptr" # DW_AT_name 165 .long .Lulong_ptr-.Lcu_begin0 # DW_AT_type 166 .uleb128 0xdeadbeefbaadf00d # DW_AT_const_value 167 168 .byte 0 # End Of Children Mark 169.Ldebug_info_end0: 170 171 .section .debug_str,"MS",@progbits,1 172.Lstrp: 173 .asciz "strp" 174