301 lines · plain
1# Test handling of forward-declared (DW_AT_declaration) structures. These types2# can be produced due to vtable-based type homing, or other -flimit-debug-info3# optimizations.4 5# RUN: split-file %s %t6# RUN: llvm-mc --triple x86_64-pc-linux %t/asm --filetype=obj -o %t.o7# RUN: %lldb -o "settings set interpreter.stop-command-source-on-error false" \8# RUN: -s %t/commands -o exit %t.o 2>&1 | FileCheck %s9 10#--- commands11# Type A should be treated as a forward-declaration even though it has a child.12target var a13# CHECK-LABEL: target var a14# FIXME: This should also produce some kind of an error.15# CHECK: (A) a = <incomplete type "A">16expr a17# CHECK-LABEL: expr a18# CHECK: incomplete type 'A' where a complete type is required19 20# Parsing B::B1 should not crash even though B is incomplete. Note that in this21# case B must be forcefully completed.22target var b123# CHECK-LABEL: target var b124# CHECK: (B::B1) b1 = (ptr = 0x00000000baadf00d)25expr b126# CHECK-LABEL: expr b127# CHECK: (B::B1) $0 = (ptr = 0x00000000baadf00d)28 29target var c130# CHECK-LABEL: target var c131# CHECK: (C::C1) c1 = 42474232 33expr c134# CHECK-LABEL: expr c135# CHECK: (C::C1) $1 = 42474236#--- asm37 .text38_ZN1AC2Ev:39 retq40.LZN1AC2Ev_end:41 42 .data43 .p2align 444a:45 .quad _ZTV1A+1646 .quad 0xdeadbeef47 48b1:49 .quad 0xbaadf00d50c1:51 .long 4247424752 53 .section .debug_abbrev,"",@progbits54 .byte 1 # Abbreviation Code55 .byte 17 # DW_TAG_compile_unit56 .byte 1 # DW_CHILDREN_yes57 .byte 37 # DW_AT_producer58 .byte 8 # DW_FORM_string59 .byte 17 # DW_AT_low_pc60 .byte 1 # DW_FORM_addr61 .byte 18 # DW_AT_high_pc62 .byte 6 # DW_FORM_data463 .byte 0 # EOM(1)64 .byte 0 # EOM(2)65 .byte 2 # Abbreviation Code66 .byte 52 # DW_TAG_variable67 .byte 0 # DW_CHILDREN_no68 .byte 3 # DW_AT_name69 .byte 8 # DW_FORM_string70 .byte 73 # DW_AT_type71 .byte 19 # DW_FORM_ref472 .byte 2 # DW_AT_location73 .byte 24 # DW_FORM_exprloc74 .byte 0 # EOM(1)75 .byte 0 # EOM(2)76 .byte 3 # Abbreviation Code77 .byte 19 # DW_TAG_structure_type78 .byte 1 # DW_CHILDREN_yes79 .byte 3 # DW_AT_name80 .byte 8 # DW_FORM_string81 .byte 60 # DW_AT_declaration82 .byte 25 # DW_FORM_flag_present83 .byte 0 # EOM(1)84 .byte 0 # EOM(2)85 .byte 4 # Abbreviation Code86 .byte 46 # DW_TAG_subprogram87 .byte 1 # DW_CHILDREN_yes88 .byte 3 # DW_AT_name89 .byte 8 # DW_FORM_string90 .byte 60 # DW_AT_declaration91 .byte 25 # DW_FORM_flag_present92 .byte 0 # EOM(1)93 .byte 0 # EOM(2)94 .byte 5 # Abbreviation Code95 .byte 5 # DW_TAG_formal_parameter96 .byte 0 # DW_CHILDREN_no97 .byte 73 # DW_AT_type98 .byte 19 # DW_FORM_ref499 .byte 52 # DW_AT_artificial100 .byte 25 # DW_FORM_flag_present101 .byte 0 # EOM(1)102 .byte 0 # EOM(2)103 .byte 6 # Abbreviation Code104 .byte 2 # DW_TAG_class_type105 .byte 1 # DW_CHILDREN_yes106 .byte 3 # DW_AT_name107 .byte 8 # DW_FORM_string108 .byte 11 # DW_AT_byte_size109 .byte 11 # DW_FORM_data1110 .byte 0 # EOM(1)111 .byte 0 # EOM(2)112 .byte 7 # Abbreviation Code113 .byte 13 # DW_TAG_member114 .byte 0 # DW_CHILDREN_no115 .byte 3 # DW_AT_name116 .byte 8 # DW_FORM_string117 .byte 73 # DW_AT_type118 .byte 19 # DW_FORM_ref4119 .byte 56 # DW_AT_data_member_location120 .byte 11 # DW_FORM_data1121 .byte 0 # EOM(1)122 .byte 0 # EOM(2)123 .byte 8 # Abbreviation Code124 .byte 15 # DW_TAG_pointer_type125 .byte 0 # DW_CHILDREN_no126 .byte 73 # DW_AT_type127 .byte 19 # DW_FORM_ref4128 .byte 0 # EOM(1)129 .byte 0 # EOM(2)130 .byte 9 # Abbreviation Code131 .byte 36 # DW_TAG_base_type132 .byte 0 # DW_CHILDREN_no133 .byte 3 # DW_AT_name134 .byte 8 # DW_FORM_string135 .byte 62 # DW_AT_encoding136 .byte 11 # DW_FORM_data1137 .byte 11 # DW_AT_byte_size138 .byte 11 # DW_FORM_data1139 .byte 0 # EOM(1)140 .byte 0 # EOM(2)141 .byte 10 # Abbreviation Code142 .byte 46 # DW_TAG_subprogram143 .byte 1 # DW_CHILDREN_yes144 .byte 17 # DW_AT_low_pc145 .byte 1 # DW_FORM_addr146 .byte 18 # DW_AT_high_pc147 .byte 6 # DW_FORM_data4148 .byte 64 # DW_AT_frame_base149 .byte 24 # DW_FORM_exprloc150 .byte 100 # DW_AT_object_pointer151 .byte 19 # DW_FORM_ref4152 .byte 71 # DW_AT_specification153 .byte 19 # DW_FORM_ref4154 .byte 0 # EOM(1)155 .byte 0 # EOM(2)156 .byte 11 # Abbreviation Code157 .byte 5 # DW_TAG_formal_parameter158 .byte 0 # DW_CHILDREN_no159 .byte 2 # DW_AT_location160 .byte 24 # DW_FORM_exprloc161 .byte 3 # DW_AT_name162 .byte 8 # DW_FORM_string163 .byte 73 # DW_AT_type164 .byte 19 # DW_FORM_ref4165 .byte 52 # DW_AT_artificial166 .byte 25 # DW_FORM_flag_present167 .byte 0 # EOM(1)168 .byte 0 # EOM(2)169 .byte 12 # Abbreviation Code170 .byte 22 # DW_TAG_typedef171 .byte 0 # DW_CHILDREN_no172 .byte 73 # DW_AT_type173 .byte 19 # DW_FORM_ref4174 .byte 3 # DW_AT_name175 .byte 8 # DW_FORM_string176 .byte 0 # EOM(1)177 .byte 0 # EOM(2)178 .byte 0 # EOM(3)179 .section .debug_info,"",@progbits180.Lcu_begin0:181 .long .Ldebug_info_end0-.Ldebug_info_start0 # Length of Unit182.Ldebug_info_start0:183 .short 4 # DWARF version number184 .long .debug_abbrev # Offset Into Abbrev. Section185 .byte 8 # Address Size (in bytes)186 .byte 1 # Abbrev [1] DW_TAG_compile_unit187 .asciz "Hand-written DWARF" # DW_AT_producer188 .quad _ZN1AC2Ev # DW_AT_low_pc189 .long .LZN1AC2Ev_end-_ZN1AC2Ev # DW_AT_high_pc190 191# Case 1: The compiler has omitted the declaration of the type, but it still192# produces an entry for its implicit constructor instantiated in this compile193# unit.194# Roughly corresponds to this:195# struct A {196# virtual ~A(); // not defined here197# // implicit A() {}198# } a;199 .byte 2 # Abbrev [2] DW_TAG_variable200 .asciz "a" # DW_AT_name201 .long .LA-.Lcu_begin0 # DW_AT_type202 .byte 9 # DW_AT_location203 .byte 3204 .quad a205.LA:206 .byte 3 # Abbrev [3] DW_TAG_structure_type207 .asciz "A" # DW_AT_name208 # DW_AT_declaration209.LA_A:210 .byte 4 # Abbrev [4] DW_TAG_subprogram211 .asciz "A" # DW_AT_name212 # DW_AT_declaration213 .byte 5 # Abbrev [5] DW_TAG_formal_parameter214 .long .LAptr-.Lcu_begin0 # DW_AT_type215 # DW_AT_artificial216 .byte 0 # End Of Children Mark217 .byte 0 # End Of Children Mark218.LAptr:219 .byte 8 # Abbrev [8] DW_TAG_pointer_type220 .long .LA-.Lcu_begin0 # DW_AT_type221 .byte 10 # Abbrev [10] DW_TAG_subprogram222 .quad _ZN1AC2Ev # DW_AT_low_pc223 .long .LZN1AC2Ev_end-_ZN1AC2Ev # DW_AT_high_pc224 .byte 1 # DW_AT_frame_base225 .byte 86226 .long .Lthis-.Lcu_begin0 # DW_AT_object_pointer227 .long .LA_A-.Lcu_begin0 # DW_AT_specification228.Lthis:229 .byte 11 # Abbrev [11] DW_TAG_formal_parameter230 .byte 2 # DW_AT_location231 .byte 145232 .byte 120233 .asciz "this" # DW_AT_name234 .long .LAptr-.Lcu_begin0 # DW_AT_type235 # DW_AT_artificial236 .byte 0 # End Of Children Mark237 238# Case 2: A structure has been emitted as a declaration only, but it contains a239# nested class, which has a full definition present.240# Rougly corresponds to this:241# struct B {242# virtual ~B(); // not defined here243# class B1 {244# A* ptr;245# };246# };247# B::B1 b1;248# Note that it is important that the inner type is a class (not struct) as that249# triggers a clang assertion.250 .byte 3 # Abbrev [3] DW_TAG_structure_type251 .asciz "B" # DW_AT_name252 # DW_AT_declaration253.LB1:254 .byte 6 # Abbrev [6] DW_TAG_class_type255 .asciz "B1" # DW_AT_name256 .byte 8 # DW_AT_byte_size257 .byte 7 # Abbrev [5] 0x58:0xc DW_TAG_member258 .asciz "ptr" # DW_AT_name259 .long .LAptr # DW_AT_type260 .byte 0 # DW_AT_data_member_location261 .byte 0 # End Of Children Mark262 .byte 0 # End Of Children Mark263 264 .byte 2 # Abbrev [2] DW_TAG_variable265 .asciz "b1" # DW_AT_name266 .long .LB1-.Lcu_begin0 # DW_AT_type267 .byte 9 # DW_AT_location268 .byte 3269 .quad b1270 271# Case 3: A typedef in DW_AT_declaration struct.272# C++ equivalent:273# struct C {274# virtual ~C(); // not defined here275# typedef int C1;276# };277# C::C1 c1;278.Lint:279 .byte 9 # Abbrev [9] DW_TAG_base_type280 .asciz "int" # DW_AT_name281 .byte 5 # DW_AT_encoding282 .byte 4 # DW_AT_byte_size283 .byte 3 # Abbrev [3] DW_TAG_structure_type284 .asciz "C" # DW_AT_name285 # DW_AT_declaration286.LC1:287 .byte 12 # Abbrev [12] DW_TAG_typedef288 .long .Lint-.Lcu_begin0 # DW_AT_type289 .asciz "C1" # DW_AT_name290 .byte 0 # End Of Children Mark291 292 .byte 2 # Abbrev [2] DW_TAG_variable293 .asciz "c1" # DW_AT_name294 .long .LC1-.Lcu_begin0 # DW_AT_type295 .byte 9 # DW_AT_location296 .byte 3297 .quad c1298 299 .byte 0 # End Of Children Mark300.Ldebug_info_end0:301