409 lines · plain
1# RUN: llvm-mc -filetype=obj -o %t -triple x86_64-apple-macosx10.15.0 %s2# RUN: %lldb %t -o "target variable constant" -b | FileCheck %s3 4# CHECK: (lldb) target variable constant5# CHECK: (U) constant = {6# CHECK: raw = 16884697617# CHECK: = (a = 1, b = 1, c = 36, d = 2, e = 36, f = 1)8# CHECK: }9 10# This is testing when how ValueObjectVariable handles the case where the11# DWARFExpression holds the data that represents a constant value.12# Compile at -O1 allows us to capture this case. Below is the code used13# to generate the assembly:14#15# typedef union16# {17# unsigned raw;18# struct19# {20# unsigned a : 8;21# unsigned b : 8;22# unsigned c : 6;23# unsigned d : 2;24# unsigned e : 6;25# unsigned f : 2;26# } ;27# } U;28#29# static U __attribute__((used)) _type_anchor;30# static const int constant = 0x64A40101;31#32# int g() { return constant; }33#34# int main() {35# U u;36# u.raw = 0x64A40101;37# }38#39# Compiled as follows:40#41# clang -gdwarf-4 -O1 dw_at_const_value_bug.c -S -o dw_at_const_value_bug.s42#43# I was able to obtain a global of type U with DW_AT_const_value but was able44# to using int. This required modifying the DW_AT_type of constant to be type45# U. After that stripping as much of the assembly as possible to give us a46# smaller reproducer.47 48 49.zerofill __DATA,__bss,__type_anchor,4,2 ## @_type_anchor50 .no_dead_strip __type_anchor51 .section __DWARF,__debug_str,regular,debug52Linfo_string:53 .zero 9054 .asciz "constant" ## string offset=9055 .asciz "int" ## string offset=9956 .asciz "_type_anchor" ## string offset=10357 .asciz "U" ## string offset=11658 .asciz "raw" ## string offset=11859 .asciz "unsigned int" ## string offset=12260 .asciz "a" ## string offset=13561 .asciz "b" ## string offset=13762 .asciz "c" ## string offset=13963 .asciz "d" ## string offset=14164 .asciz "e" ## string offset=14365 .asciz "f" ## string offset=14566 .asciz "g" ## string offset=14767 .asciz "main" ## string offset=14968 .asciz "u" ## string offset=15469 .section __DWARF,__debug_abbrev,regular,debug70Lsection_abbrev:71 .byte 1 ## Abbreviation Code72 .byte 17 ## DW_TAG_compile_unit73 .byte 1 ## DW_CHILDREN_yes74 .byte 37 ## DW_AT_producer75 .byte 14 ## DW_FORM_strp76 .byte 19 ## DW_AT_language77 .byte 5 ## DW_FORM_data278 .byte 3 ## DW_AT_name79 .byte 14 ## DW_FORM_strp80 .byte 66 ## DW_AT_stmt_list81 .byte 23 ## DW_FORM_sec_offset82 .byte 27 ## DW_AT_comp_dir83 .byte 14 ## DW_FORM_strp84 .ascii "\264B" ## DW_AT_GNU_pubnames85 .byte 25 ## DW_FORM_flag_present86 .ascii "\341\177" ## DW_AT_APPLE_optimized87 .byte 25 ## DW_FORM_flag_present88 .byte 17 ## DW_AT_low_pc89 .byte 1 ## DW_FORM_addr90 .byte 18 ## DW_AT_high_pc91 .byte 6 ## DW_FORM_data492 .byte 0 ## EOM(1)93 .byte 0 ## EOM(2)94 .byte 2 ## Abbreviation Code95 .byte 52 ## DW_TAG_variable96 .byte 0 ## DW_CHILDREN_no97 .byte 3 ## DW_AT_name98 .byte 14 ## DW_FORM_strp99 .byte 73 ## DW_AT_type100 .byte 19 ## DW_FORM_ref4101 .byte 58 ## DW_AT_decl_file102 .byte 11 ## DW_FORM_data1103 .byte 59 ## DW_AT_decl_line104 .byte 11 ## DW_FORM_data1105 .byte 28 ## DW_AT_const_value106 .byte 15 ## DW_FORM_udata107 .byte 0 ## EOM(1)108 .byte 0 ## EOM(2)109 .byte 3 ## Abbreviation Code110 .byte 38 ## DW_TAG_const_type111 .byte 0 ## DW_CHILDREN_no112 .byte 73 ## DW_AT_type113 .byte 19 ## DW_FORM_ref4114 .byte 0 ## EOM(1)115 .byte 0 ## EOM(2)116 .byte 4 ## Abbreviation Code117 .byte 36 ## DW_TAG_base_type118 .byte 0 ## DW_CHILDREN_no119 .byte 3 ## DW_AT_name120 .byte 14 ## DW_FORM_strp121 .byte 62 ## DW_AT_encoding122 .byte 11 ## DW_FORM_data1123 .byte 11 ## DW_AT_byte_size124 .byte 11 ## DW_FORM_data1125 .byte 0 ## EOM(1)126 .byte 0 ## EOM(2)127 .byte 5 ## Abbreviation Code128 .byte 52 ## DW_TAG_variable129 .byte 0 ## DW_CHILDREN_no130 .byte 3 ## DW_AT_name131 .byte 14 ## DW_FORM_strp132 .byte 73 ## DW_AT_type133 .byte 19 ## DW_FORM_ref4134 .byte 58 ## DW_AT_decl_file135 .byte 11 ## DW_FORM_data1136 .byte 59 ## DW_AT_decl_line137 .byte 11 ## DW_FORM_data1138 .byte 2 ## DW_AT_location139 .byte 24 ## DW_FORM_exprloc140 .byte 0 ## EOM(1)141 .byte 0 ## EOM(2)142 .byte 6 ## Abbreviation Code143 .byte 22 ## DW_TAG_typedef144 .byte 0 ## DW_CHILDREN_no145 .byte 73 ## DW_AT_type146 .byte 19 ## DW_FORM_ref4147 .byte 3 ## DW_AT_name148 .byte 14 ## DW_FORM_strp149 .byte 58 ## DW_AT_decl_file150 .byte 11 ## DW_FORM_data1151 .byte 59 ## DW_AT_decl_line152 .byte 11 ## DW_FORM_data1153 .byte 0 ## EOM(1)154 .byte 0 ## EOM(2)155 .byte 7 ## Abbreviation Code156 .byte 23 ## DW_TAG_union_type157 .byte 1 ## DW_CHILDREN_yes158 .byte 11 ## DW_AT_byte_size159 .byte 11 ## DW_FORM_data1160 .byte 58 ## DW_AT_decl_file161 .byte 11 ## DW_FORM_data1162 .byte 59 ## DW_AT_decl_line163 .byte 11 ## DW_FORM_data1164 .byte 0 ## EOM(1)165 .byte 0 ## EOM(2)166 .byte 8 ## Abbreviation Code167 .byte 13 ## DW_TAG_member168 .byte 0 ## DW_CHILDREN_no169 .byte 3 ## DW_AT_name170 .byte 14 ## DW_FORM_strp171 .byte 73 ## DW_AT_type172 .byte 19 ## DW_FORM_ref4173 .byte 58 ## DW_AT_decl_file174 .byte 11 ## DW_FORM_data1175 .byte 59 ## DW_AT_decl_line176 .byte 11 ## DW_FORM_data1177 .byte 56 ## DW_AT_data_member_location178 .byte 11 ## DW_FORM_data1179 .byte 0 ## EOM(1)180 .byte 0 ## EOM(2)181 .byte 9 ## Abbreviation Code182 .byte 13 ## DW_TAG_member183 .byte 0 ## DW_CHILDREN_no184 .byte 73 ## DW_AT_type185 .byte 19 ## DW_FORM_ref4186 .byte 58 ## DW_AT_decl_file187 .byte 11 ## DW_FORM_data1188 .byte 59 ## DW_AT_decl_line189 .byte 11 ## DW_FORM_data1190 .byte 56 ## DW_AT_data_member_location191 .byte 11 ## DW_FORM_data1192 .byte 0 ## EOM(1)193 .byte 0 ## EOM(2)194 .byte 10 ## Abbreviation Code195 .byte 19 ## DW_TAG_structure_type196 .byte 1 ## DW_CHILDREN_yes197 .byte 11 ## DW_AT_byte_size198 .byte 11 ## DW_FORM_data1199 .byte 58 ## DW_AT_decl_file200 .byte 11 ## DW_FORM_data1201 .byte 59 ## DW_AT_decl_line202 .byte 11 ## DW_FORM_data1203 .byte 0 ## EOM(1)204 .byte 0 ## EOM(2)205 .byte 11 ## Abbreviation Code206 .byte 13 ## DW_TAG_member207 .byte 0 ## DW_CHILDREN_no208 .byte 3 ## DW_AT_name209 .byte 14 ## DW_FORM_strp210 .byte 73 ## DW_AT_type211 .byte 19 ## DW_FORM_ref4212 .byte 58 ## DW_AT_decl_file213 .byte 11 ## DW_FORM_data1214 .byte 59 ## DW_AT_decl_line215 .byte 11 ## DW_FORM_data1216 .byte 13 ## DW_AT_bit_size217 .byte 11 ## DW_FORM_data1218 .byte 107 ## DW_AT_data_bit_offset219 .byte 11 ## DW_FORM_data1220 .byte 0 ## EOM(1)221 .byte 0 ## EOM(2)222 .byte 12 ## Abbreviation Code223 .byte 46 ## DW_TAG_subprogram224 .byte 0 ## DW_CHILDREN_no225 .byte 17 ## DW_AT_low_pc226 .byte 1 ## DW_FORM_addr227 .byte 18 ## DW_AT_high_pc228 .byte 6 ## DW_FORM_data4229 .byte 64 ## DW_AT_frame_base230 .byte 24 ## DW_FORM_exprloc231 .byte 122 ## DW_AT_call_all_calls232 .byte 25 ## DW_FORM_flag_present233 .byte 3 ## DW_AT_name234 .byte 14 ## DW_FORM_strp235 .byte 58 ## DW_AT_decl_file236 .byte 11 ## DW_FORM_data1237 .byte 59 ## DW_AT_decl_line238 .byte 11 ## DW_FORM_data1239 .byte 73 ## DW_AT_type240 .byte 19 ## DW_FORM_ref4241 .byte 63 ## DW_AT_external242 .byte 25 ## DW_FORM_flag_present243 .ascii "\341\177" ## DW_AT_APPLE_optimized244 .byte 25 ## DW_FORM_flag_present245 .byte 0 ## EOM(1)246 .byte 0 ## EOM(2)247 .byte 13 ## Abbreviation Code248 .byte 46 ## DW_TAG_subprogram249 .byte 1 ## DW_CHILDREN_yes250 .byte 17 ## DW_AT_low_pc251 .byte 1 ## DW_FORM_addr252 .byte 18 ## DW_AT_high_pc253 .byte 6 ## DW_FORM_data4254 .byte 64 ## DW_AT_frame_base255 .byte 24 ## DW_FORM_exprloc256 .byte 122 ## DW_AT_call_all_calls257 .byte 25 ## DW_FORM_flag_present258 .byte 3 ## DW_AT_name259 .byte 14 ## DW_FORM_strp260 .byte 58 ## DW_AT_decl_file261 .byte 11 ## DW_FORM_data1262 .byte 59 ## DW_AT_decl_line263 .byte 11 ## DW_FORM_data1264 .byte 73 ## DW_AT_type265 .byte 19 ## DW_FORM_ref4266 .byte 63 ## DW_AT_external267 .byte 25 ## DW_FORM_flag_present268 .ascii "\341\177" ## DW_AT_APPLE_optimized269 .byte 25 ## DW_FORM_flag_present270 .byte 0 ## EOM(1)271 .byte 0 ## EOM(2)272 .byte 14 ## Abbreviation Code273 .byte 52 ## DW_TAG_variable274 .byte 0 ## DW_CHILDREN_no275 .byte 28 ## DW_AT_const_value276 .byte 15 ## DW_FORM_udata277 .byte 3 ## DW_AT_name278 .byte 14 ## DW_FORM_strp279 .byte 58 ## DW_AT_decl_file280 .byte 11 ## DW_FORM_data1281 .byte 59 ## DW_AT_decl_line282 .byte 11 ## DW_FORM_data1283 .byte 73 ## DW_AT_type284 .byte 19 ## DW_FORM_ref4285 .byte 0 ## EOM(1)286 .byte 0 ## EOM(2)287 .byte 0 ## EOM(3)288 .section __DWARF,__debug_info,regular,debug289Lsection_info:290Lcu_begin0:291.set Lset0, Ldebug_info_end0-Ldebug_info_start0 ## Length of Unit292 .long Lset0293Ldebug_info_start0:294 .short 4 ## DWARF version number295.set Lset1, Lsection_abbrev-Lsection_abbrev ## Offset Into Abbrev. Section296 .long Lset1297 .byte 8 ## Address Size (in bytes)298 .byte 1 ## Abbrev [1] 0xb:0x112 DW_TAG_compile_unit299 .long 0 ## DW_AT_producer300 .short 12 ## DW_AT_language301 .long 47 ## DW_AT_name302 .long 0 ## DW_AT_stmt_list303 .long 71 ## DW_AT_comp_dir304 ## DW_AT_GNU_pubnames305 ## DW_AT_APPLE_optimized306 .quad 0 ## DW_AT_low_pc307 .long 0308 .byte 2 ## Abbrev [2] 0x2a:0x10 DW_TAG_variable309 .long 90 ## DW_AT_name310 .long 91 ## DW_AT_type311 .byte 1 ## DW_AT_decl_file312 .byte 16 ## DW_AT_decl_line313 .ascii "\201\202\220\245\006" ## DW_AT_const_value314 .byte 3 ## Abbrev [3] 0x3a:0x5 DW_TAG_const_type315 .long 63 ## DW_AT_type316 .byte 4 ## Abbrev [4] 0x3f:0x7 DW_TAG_base_type317 .long 99 ## DW_AT_name318 .byte 5 ## DW_AT_encoding319 .byte 4 ## DW_AT_byte_size320 .byte 5 ## Abbrev [5] 0x46:0x15 DW_TAG_variable321 .long 103 ## DW_AT_name322 .long 91 ## DW_AT_type323 .byte 1 ## DW_AT_decl_file324 .byte 15 ## DW_AT_decl_line325 .byte 9 ## DW_AT_location326 .byte 3327 .quad __type_anchor328 .byte 6 ## Abbrev [6] 0x5b:0xb DW_TAG_typedef329 .long 102 ## DW_AT_type330 .long 116 ## DW_AT_name331 .byte 1 ## DW_AT_decl_file332 .byte 13 ## DW_AT_decl_line333 .byte 7 ## Abbrev [7] 0x66:0x6c DW_TAG_union_type334 .byte 4 ## DW_AT_byte_size335 .byte 1 ## DW_AT_decl_file336 .byte 1 ## DW_AT_decl_line337 .byte 8 ## Abbrev [8] 0x6a:0xc DW_TAG_member338 .long 118 ## DW_AT_name339 .long 210 ## DW_AT_type340 .byte 1 ## DW_AT_decl_file341 .byte 3 ## DW_AT_decl_line342 .byte 0 ## DW_AT_data_member_location343 .byte 9 ## Abbrev [9] 0x76:0x8 DW_TAG_member344 .long 126 ## DW_AT_type345 .byte 1 ## DW_AT_decl_file346 .byte 4 ## DW_AT_decl_line347 .byte 0 ## DW_AT_data_member_location348 .byte 10 ## Abbrev [10] 0x7e:0x53 DW_TAG_structure_type349 .byte 4 ## DW_AT_byte_size350 .byte 1 ## DW_AT_decl_file351 .byte 4 ## DW_AT_decl_line352 .byte 11 ## Abbrev [11] 0x82:0xd DW_TAG_member353 .long 135 ## DW_AT_name354 .long 210 ## DW_AT_type355 .byte 1 ## DW_AT_decl_file356 .byte 6 ## DW_AT_decl_line357 .byte 8 ## DW_AT_bit_size358 .byte 0 ## DW_AT_data_bit_offset359 .byte 11 ## Abbrev [11] 0x8f:0xd DW_TAG_member360 .long 137 ## DW_AT_name361 .long 210 ## DW_AT_type362 .byte 1 ## DW_AT_decl_file363 .byte 7 ## DW_AT_decl_line364 .byte 8 ## DW_AT_bit_size365 .byte 8 ## DW_AT_data_bit_offset366 .byte 11 ## Abbrev [11] 0x9c:0xd DW_TAG_member367 .long 139 ## DW_AT_name368 .long 210 ## DW_AT_type369 .byte 1 ## DW_AT_decl_file370 .byte 8 ## DW_AT_decl_line371 .byte 6 ## DW_AT_bit_size372 .byte 16 ## DW_AT_data_bit_offset373 .byte 11 ## Abbrev [11] 0xa9:0xd DW_TAG_member374 .long 141 ## DW_AT_name375 .long 210 ## DW_AT_type376 .byte 1 ## DW_AT_decl_file377 .byte 9 ## DW_AT_decl_line378 .byte 2 ## DW_AT_bit_size379 .byte 22 ## DW_AT_data_bit_offset380 .byte 11 ## Abbrev [11] 0xb6:0xd DW_TAG_member381 .long 143 ## DW_AT_name382 .long 210 ## DW_AT_type383 .byte 1 ## DW_AT_decl_file384 .byte 10 ## DW_AT_decl_line385 .byte 6 ## DW_AT_bit_size386 .byte 24 ## DW_AT_data_bit_offset387 .byte 11 ## Abbrev [11] 0xc3:0xd DW_TAG_member388 .long 145 ## DW_AT_name389 .long 210 ## DW_AT_type390 .byte 1 ## DW_AT_decl_file391 .byte 11 ## DW_AT_decl_line392 .byte 2 ## DW_AT_bit_size393 .byte 30 ## DW_AT_data_bit_offset394 .byte 0 ## End Of Children Mark395 .byte 0 ## End Of Children Mark396 .byte 4 ## Abbrev [4] 0xd2:0x7 DW_TAG_base_type397 .long 122 ## DW_AT_name398 .byte 7 ## DW_AT_encoding399 .byte 4 ## DW_AT_byte_size400 .byte 14 ## Abbrev [14] 0x10b:0x10 DW_TAG_variable401 .ascii "\201\202\220\245\006" ## DW_AT_const_value402 .long 154 ## DW_AT_name403 .byte 1 ## DW_AT_decl_file404 .byte 21 ## DW_AT_decl_line405 .long 91 ## DW_AT_type406 .byte 0 ## End Of Children Mark407 .byte 0 ## End Of Children Mark408Ldebug_info_end0:409