1 # Test handling of forward-declared (DW_AT_declaration) structures. These types
2 # can be produced due to vtable-based type homing, or other -flimit-debug-info
5 # RUN: split-file %s %t
6 # RUN: llvm-mc --triple x86_64-pc-linux %t/asm --filetype=obj -o %t.o
7 # RUN: %lldb -o "settings set interpreter.stop-command-source-on-error false" \
8 # RUN: -s %t/commands -o exit %t.o 2>&1 | FileCheck %s
11 # Type A should be treated as a forward-declaration even though it has a child.
13 # CHECK-LABEL: target var a
14 # FIXME: This should also produce some kind of an error.
15 # CHECK: (A) a = <incomplete type "A">
18 # CHECK: incomplete type 'A' where a complete type is required
20 # Parsing B::B1 should not crash even though B is incomplete. Note that in this
21 # case B must be forcefully completed.
23 # CHECK-LABEL: target var b1
24 # CHECK: (B::B1) b1 = (ptr = 0x00000000baadf00d)
26 # CHECK-LABEL: expr b1
27 # CHECK: (B::B1) $0 = (ptr = 0x00000000baadf00d)
30 # CHECK-LABEL: target var c1
31 # CHECK: (C::C1) c1 = 424742
34 # CHECK-LABEL: expr c1
35 # CHECK: (C::C1) $1 = 424742
53 .section .debug_abbrev,"",@progbits
54 .byte 1 # Abbreviation Code
55 .byte 17 # DW_TAG_compile_unit
56 .byte 1 # DW_CHILDREN_yes
57 .byte 37 # DW_AT_producer
58 .byte 8 # DW_FORM_string
59 .byte 17 # DW_AT_low_pc
60 .byte 1 # DW_FORM_addr
61 .byte 18 # DW_AT_high_pc
62 .byte 6 # DW_FORM_data4
65 .byte 2 # Abbreviation Code
66 .byte 52 # DW_TAG_variable
67 .byte 0 # DW_CHILDREN_no
69 .byte 8 # DW_FORM_string
71 .byte 19 # DW_FORM_ref4
72 .byte 2 # DW_AT_location
73 .byte 24 # DW_FORM_exprloc
76 .byte 3 # Abbreviation Code
77 .byte 19 # DW_TAG_structure_type
78 .byte 1 # DW_CHILDREN_yes
80 .byte 8 # DW_FORM_string
81 .byte 60 # DW_AT_declaration
82 .byte 25 # DW_FORM_flag_present
85 .byte 4 # Abbreviation Code
86 .byte 46 # DW_TAG_subprogram
87 .byte 1 # DW_CHILDREN_yes
89 .byte 8 # DW_FORM_string
90 .byte 60 # DW_AT_declaration
91 .byte 25 # DW_FORM_flag_present
94 .byte 5 # Abbreviation Code
95 .byte 5 # DW_TAG_formal_parameter
96 .byte 0 # DW_CHILDREN_no
98 .byte 19 # DW_FORM_ref4
99 .byte 52 # DW_AT_artificial
100 .byte 25 # DW_FORM_flag_present
103 .byte 6 # Abbreviation Code
104 .byte 2 # DW_TAG_class_type
105 .byte 1 # DW_CHILDREN_yes
107 .byte 8 # DW_FORM_string
108 .byte 11 # DW_AT_byte_size
109 .byte 11 # DW_FORM_data1
112 .byte 7 # Abbreviation Code
113 .byte 13 # DW_TAG_member
114 .byte 0 # DW_CHILDREN_no
116 .byte 8 # DW_FORM_string
117 .byte 73 # DW_AT_type
118 .byte 19 # DW_FORM_ref4
119 .byte 56 # DW_AT_data_member_location
120 .byte 11 # DW_FORM_data1
123 .byte 8 # Abbreviation Code
124 .byte 15 # DW_TAG_pointer_type
125 .byte 0 # DW_CHILDREN_no
126 .byte 73 # DW_AT_type
127 .byte 19 # DW_FORM_ref4
130 .byte 9 # Abbreviation Code
131 .byte 36 # DW_TAG_base_type
132 .byte 0 # DW_CHILDREN_no
134 .byte 8 # DW_FORM_string
135 .byte 62 # DW_AT_encoding
136 .byte 11 # DW_FORM_data1
137 .byte 11 # DW_AT_byte_size
138 .byte 11 # DW_FORM_data1
141 .byte 10 # Abbreviation Code
142 .byte 46 # DW_TAG_subprogram
143 .byte 1 # DW_CHILDREN_yes
144 .byte 17 # DW_AT_low_pc
145 .byte 1 # DW_FORM_addr
146 .byte 18 # DW_AT_high_pc
147 .byte 6 # DW_FORM_data4
148 .byte 64 # DW_AT_frame_base
149 .byte 24 # DW_FORM_exprloc
150 .byte 100 # DW_AT_object_pointer
151 .byte 19 # DW_FORM_ref4
152 .byte 71 # DW_AT_specification
153 .byte 19 # DW_FORM_ref4
156 .byte 11 # Abbreviation Code
157 .byte 5 # DW_TAG_formal_parameter
158 .byte 0 # DW_CHILDREN_no
159 .byte 2 # DW_AT_location
160 .byte 24 # DW_FORM_exprloc
162 .byte 8 # DW_FORM_string
163 .byte 73 # DW_AT_type
164 .byte 19 # DW_FORM_ref4
165 .byte 52 # DW_AT_artificial
166 .byte 25 # DW_FORM_flag_present
169 .byte 12 # Abbreviation Code
170 .byte 22 # DW_TAG_typedef
171 .byte 0 # DW_CHILDREN_no
172 .byte 73 # DW_AT_type
173 .byte 19 # DW_FORM_ref4
175 .byte 8 # DW_FORM_string
179 .section .debug_info,"",@progbits
181 .long .Ldebug_info_end0-.Ldebug_info_start0 # Length of Unit
183 .short 4 # DWARF version number
184 .long .debug_abbrev # Offset Into Abbrev. Section
185 .byte 8 # Address Size (in bytes)
186 .byte 1 # Abbrev [1] DW_TAG_compile_unit
187 .asciz "Hand-written DWARF" # DW_AT_producer
188 .quad _ZN1AC2Ev # DW_AT_low_pc
189 .long .LZN1AC2Ev_end-_ZN1AC2Ev # DW_AT_high_pc
191 # Case 1: The compiler has omitted the declaration of the type, but it still
192 # produces an entry for its implicit constructor instantiated in this compile
194 # Roughly corresponds to this:
196 # virtual ~A(); // not defined here
199 .byte 2 # Abbrev [2] DW_TAG_variable
200 .asciz "a" # DW_AT_name
201 .long .LA-.Lcu_begin0 # DW_AT_type
202 .byte 9 # DW_AT_location
206 .byte 3 # Abbrev [3] DW_TAG_structure_type
207 .asciz "A" # DW_AT_name
210 .byte 4 # Abbrev [4] DW_TAG_subprogram
211 .asciz "A" # DW_AT_name
213 .byte 5 # Abbrev [5] DW_TAG_formal_parameter
214 .long .LAptr-.Lcu_begin0 # DW_AT_type
216 .byte 0 # End Of Children Mark
217 .byte 0 # End Of Children Mark
219 .byte 8 # Abbrev [8] DW_TAG_pointer_type
220 .long .LA-.Lcu_begin0 # DW_AT_type
221 .byte 10 # Abbrev [10] DW_TAG_subprogram
222 .quad _ZN1AC2Ev # DW_AT_low_pc
223 .long .LZN1AC2Ev_end-_ZN1AC2Ev # DW_AT_high_pc
224 .byte 1 # DW_AT_frame_base
226 .long .Lthis-.Lcu_begin0 # DW_AT_object_pointer
227 .long .LA_A-.Lcu_begin0 # DW_AT_specification
229 .byte 11 # Abbrev [11] DW_TAG_formal_parameter
230 .byte 2 # DW_AT_location
233 .asciz "this" # DW_AT_name
234 .long .LAptr-.Lcu_begin0 # DW_AT_type
236 .byte 0 # End Of Children Mark
238 # Case 2: A structure has been emitted as a declaration only, but it contains a
239 # nested class, which has a full definition present.
240 # Rougly corresponds to this:
242 # virtual ~B(); // not defined here
248 # Note that it is important that the inner type is a class (not struct) as that
249 # triggers a clang assertion.
250 .byte 3 # Abbrev [3] DW_TAG_structure_type
251 .asciz "B" # DW_AT_name
254 .byte 6 # Abbrev [6] DW_TAG_class_type
255 .asciz "B1" # DW_AT_name
256 .byte 8 # DW_AT_byte_size
257 .byte 7 # Abbrev [5] 0x58:0xc DW_TAG_member
258 .asciz "ptr" # DW_AT_name
259 .long .LAptr # DW_AT_type
260 .byte 0 # DW_AT_data_member_location
261 .byte 0 # End Of Children Mark
262 .byte 0 # End Of Children Mark
264 .byte 2 # Abbrev [2] DW_TAG_variable
265 .asciz "b1" # DW_AT_name
266 .long .LB1-.Lcu_begin0 # DW_AT_type
267 .byte 9 # DW_AT_location
271 # Case 3: A typedef in DW_AT_declaration struct.
274 # virtual ~C(); // not defined here
279 .byte 9 # Abbrev [9] DW_TAG_base_type
280 .asciz "int" # DW_AT_name
281 .byte 5 # DW_AT_encoding
282 .byte 4 # DW_AT_byte_size
283 .byte 3 # Abbrev [3] DW_TAG_structure_type
284 .asciz "C" # DW_AT_name
287 .byte 12 # Abbrev [12] DW_TAG_typedef
288 .long .Lint-.Lcu_begin0 # DW_AT_type
289 .asciz "C1" # DW_AT_name
290 .byte 0 # End Of Children Mark
292 .byte 2 # Abbrev [2] DW_TAG_variable
293 .asciz "c1" # DW_AT_name
294 .long .LC1-.Lcu_begin0 # DW_AT_type
295 .byte 9 # DW_AT_location
299 .byte 0 # End Of Children Mark