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.
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
110 .byte 7 # Abbreviation Code
111 .byte 13 # DW_TAG_member
112 .byte 0 # DW_CHILDREN_no
114 .byte 8 # DW_FORM_string
115 .byte 73 # DW_AT_type
116 .byte 19 # DW_FORM_ref4
117 .byte 56 # DW_AT_data_member_location
118 .byte 11 # DW_FORM_data1
121 .byte 8 # Abbreviation Code
122 .byte 15 # DW_TAG_pointer_type
123 .byte 0 # DW_CHILDREN_no
124 .byte 73 # DW_AT_type
125 .byte 19 # DW_FORM_ref4
128 .byte 9 # Abbreviation Code
129 .byte 36 # DW_TAG_base_type
130 .byte 0 # DW_CHILDREN_no
132 .byte 8 # DW_FORM_string
133 .byte 62 # DW_AT_encoding
134 .byte 11 # DW_FORM_data1
135 .byte 11 # DW_AT_byte_size
136 .byte 11 # DW_FORM_data1
139 .byte 10 # Abbreviation Code
140 .byte 46 # DW_TAG_subprogram
141 .byte 1 # DW_CHILDREN_yes
142 .byte 17 # DW_AT_low_pc
143 .byte 1 # DW_FORM_addr
144 .byte 18 # DW_AT_high_pc
145 .byte 6 # DW_FORM_data4
146 .byte 64 # DW_AT_frame_base
147 .byte 24 # DW_FORM_exprloc
148 .byte 100 # DW_AT_object_pointer
149 .byte 19 # DW_FORM_ref4
150 .byte 71 # DW_AT_specification
151 .byte 19 # DW_FORM_ref4
154 .byte 11 # Abbreviation Code
155 .byte 5 # DW_TAG_formal_parameter
156 .byte 0 # DW_CHILDREN_no
157 .byte 2 # DW_AT_location
158 .byte 24 # DW_FORM_exprloc
160 .byte 8 # DW_FORM_string
161 .byte 73 # DW_AT_type
162 .byte 19 # DW_FORM_ref4
163 .byte 52 # DW_AT_artificial
164 .byte 25 # DW_FORM_flag_present
167 .byte 12 # Abbreviation Code
168 .byte 22 # DW_TAG_typedef
169 .byte 0 # DW_CHILDREN_no
170 .byte 73 # DW_AT_type
171 .byte 19 # DW_FORM_ref4
173 .byte 8 # DW_FORM_string
177 .section .debug_info,"",@progbits
179 .long .Ldebug_info_end0-.Ldebug_info_start0 # Length of Unit
181 .short 4 # DWARF version number
182 .long .debug_abbrev # Offset Into Abbrev. Section
183 .byte 8 # Address Size (in bytes)
184 .byte 1 # Abbrev [1] DW_TAG_compile_unit
185 .asciz "Hand-written DWARF" # DW_AT_producer
186 .quad _ZN1AC2Ev # DW_AT_low_pc
187 .long .LZN1AC2Ev_end-_ZN1AC2Ev # DW_AT_high_pc
189 # Case 1: The compiler has omitted the declaration of the type, but it still
190 # produces an entry for its implicit constructor instantiated in this compile
192 # Roughly corresponds to this:
194 # virtual ~A(); // not defined here
197 .byte 2 # Abbrev [2] DW_TAG_variable
198 .asciz "a" # DW_AT_name
199 .long .LA-.Lcu_begin0 # DW_AT_type
200 .byte 9 # DW_AT_location
204 .byte 3 # Abbrev [3] DW_TAG_structure_type
205 .asciz "A" # DW_AT_name
208 .byte 4 # Abbrev [4] DW_TAG_subprogram
209 .asciz "A" # DW_AT_name
211 .byte 5 # Abbrev [5] DW_TAG_formal_parameter
212 .long .LAptr-.Lcu_begin0 # DW_AT_type
214 .byte 0 # End Of Children Mark
215 .byte 0 # End Of Children Mark
217 .byte 8 # Abbrev [8] DW_TAG_pointer_type
218 .long .LA-.Lcu_begin0 # DW_AT_type
219 .byte 10 # Abbrev [10] DW_TAG_subprogram
220 .quad _ZN1AC2Ev # DW_AT_low_pc
221 .long .LZN1AC2Ev_end-_ZN1AC2Ev # DW_AT_high_pc
222 .byte 1 # DW_AT_frame_base
224 .long .Lthis-.Lcu_begin0 # DW_AT_object_pointer
225 .long .LA_A-.Lcu_begin0 # DW_AT_specification
227 .byte 11 # Abbrev [11] DW_TAG_formal_parameter
228 .byte 2 # DW_AT_location
231 .asciz "this" # DW_AT_name
232 .long .LAptr-.Lcu_begin0 # DW_AT_type
234 .byte 0 # End Of Children Mark
236 # Case 2: A structure has been emitted as a declaration only, but it contains a
237 # nested class, which has a full definition present.
238 # Rougly corresponds to this:
240 # virtual ~B(); // not defined here
246 # Note that it is important that the inner type is a class (not struct) as that
247 # triggers a clang assertion.
248 .byte 3 # Abbrev [3] DW_TAG_structure_type
249 .asciz "B" # DW_AT_name
252 .byte 6 # Abbrev [6] DW_TAG_class_type
253 .asciz "B1" # DW_AT_name
254 .byte 7 # Abbrev [5] 0x58:0xc DW_TAG_member
255 .asciz "ptr" # DW_AT_name
256 .long .LAptr # DW_AT_type
257 .byte 0 # DW_AT_data_member_location
258 .byte 0 # End Of Children Mark
259 .byte 0 # End Of Children Mark
261 .byte 2 # Abbrev [2] DW_TAG_variable
262 .asciz "b1" # DW_AT_name
263 .long .LB1-.Lcu_begin0 # DW_AT_type
264 .byte 9 # DW_AT_location
268 # Case 3: A typedef in DW_AT_declaration struct.
271 # virtual ~C(); // not defined here
276 .byte 9 # Abbrev [9] DW_TAG_base_type
277 .asciz "int" # DW_AT_name
278 .byte 5 # DW_AT_encoding
279 .byte 4 # DW_AT_byte_size
280 .byte 3 # Abbrev [3] DW_TAG_structure_type
281 .asciz "C" # DW_AT_name
284 .byte 12 # Abbrev [12] DW_TAG_typedef
285 .long .Lint-.Lcu_begin0 # DW_AT_type
286 .asciz "C1" # DW_AT_name
287 .byte 0 # End Of Children Mark
289 .byte 2 # Abbrev [2] DW_TAG_variable
290 .asciz "c1" # DW_AT_name
291 .long .LC1-.Lcu_begin0 # DW_AT_type
292 .byte 9 # DW_AT_location
296 .byte 0 # End Of Children Mark