[clang] Add tracking source deduction guide for the explicitly-written
[llvm-project.git] / lldb / test / Shell / SymbolFile / DWARF / x86 / DW_AT_declaration-with-children.s
blob16bdbd3cfaad6e617be254eecb8939012c38d6f2
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
3 # optimizations.
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
10 #--- commands
11 # Type A should be treated as a forward-declaration even though it has a child.
12 target var a
13 # CHECK-LABEL: target var a
14 # FIXME: This should also produce some kind of an error.
15 # CHECK: (A) a = <incomplete type "A">
16 expr a
17 # CHECK-LABEL: expr 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.
22 target var b1
23 # CHECK-LABEL: target var b1
24 # CHECK: (B::B1) b1 = (ptr = 0x00000000baadf00d)
25 expr b1
26 # CHECK-LABEL: expr b1
27 # CHECK: (B::B1) $0 = (ptr = 0x00000000baadf00d)
29 target var c1
30 # CHECK-LABEL: target var c1
31 # CHECK: (C::C1) c1 = 424742
33 expr c1
34 # CHECK-LABEL: expr c1
35 # CHECK: (C::C1) $1 = 424742
36 #--- asm
37 .text
38 _ZN1AC2Ev:
39 retq
40 .LZN1AC2Ev_end:
42 .data
43 .p2align 4
45 .quad _ZTV1A+16
46 .quad 0xdeadbeef
48 b1:
49 .quad 0xbaadf00d
50 c1:
51 .long 42474247
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
63 .byte 0 # EOM(1)
64 .byte 0 # EOM(2)
65 .byte 2 # Abbreviation Code
66 .byte 52 # DW_TAG_variable
67 .byte 0 # DW_CHILDREN_no
68 .byte 3 # DW_AT_name
69 .byte 8 # DW_FORM_string
70 .byte 73 # DW_AT_type
71 .byte 19 # DW_FORM_ref4
72 .byte 2 # DW_AT_location
73 .byte 24 # DW_FORM_exprloc
74 .byte 0 # EOM(1)
75 .byte 0 # EOM(2)
76 .byte 3 # Abbreviation Code
77 .byte 19 # DW_TAG_structure_type
78 .byte 1 # DW_CHILDREN_yes
79 .byte 3 # DW_AT_name
80 .byte 8 # DW_FORM_string
81 .byte 60 # DW_AT_declaration
82 .byte 25 # DW_FORM_flag_present
83 .byte 0 # EOM(1)
84 .byte 0 # EOM(2)
85 .byte 4 # Abbreviation Code
86 .byte 46 # DW_TAG_subprogram
87 .byte 1 # DW_CHILDREN_yes
88 .byte 3 # DW_AT_name
89 .byte 8 # DW_FORM_string
90 .byte 60 # DW_AT_declaration
91 .byte 25 # DW_FORM_flag_present
92 .byte 0 # EOM(1)
93 .byte 0 # EOM(2)
94 .byte 5 # Abbreviation Code
95 .byte 5 # DW_TAG_formal_parameter
96 .byte 0 # DW_CHILDREN_no
97 .byte 73 # DW_AT_type
98 .byte 19 # DW_FORM_ref4
99 .byte 52 # DW_AT_artificial
100 .byte 25 # DW_FORM_flag_present
101 .byte 0 # EOM(1)
102 .byte 0 # EOM(2)
103 .byte 6 # Abbreviation Code
104 .byte 2 # DW_TAG_class_type
105 .byte 1 # DW_CHILDREN_yes
106 .byte 3 # DW_AT_name
107 .byte 8 # DW_FORM_string
108 .byte 11 # DW_AT_byte_size
109 .byte 11 # DW_FORM_data1
110 .byte 0 # EOM(1)
111 .byte 0 # EOM(2)
112 .byte 7 # Abbreviation Code
113 .byte 13 # DW_TAG_member
114 .byte 0 # DW_CHILDREN_no
115 .byte 3 # DW_AT_name
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
121 .byte 0 # EOM(1)
122 .byte 0 # EOM(2)
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
128 .byte 0 # EOM(1)
129 .byte 0 # EOM(2)
130 .byte 9 # Abbreviation Code
131 .byte 36 # DW_TAG_base_type
132 .byte 0 # DW_CHILDREN_no
133 .byte 3 # DW_AT_name
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
139 .byte 0 # EOM(1)
140 .byte 0 # EOM(2)
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
154 .byte 0 # EOM(1)
155 .byte 0 # EOM(2)
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
161 .byte 3 # DW_AT_name
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
167 .byte 0 # EOM(1)
168 .byte 0 # EOM(2)
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
174 .byte 3 # DW_AT_name
175 .byte 8 # DW_FORM_string
176 .byte 0 # EOM(1)
177 .byte 0 # EOM(2)
178 .byte 0 # EOM(3)
179 .section .debug_info,"",@progbits
180 .Lcu_begin0:
181 .long .Ldebug_info_end0-.Ldebug_info_start0 # Length of Unit
182 .Ldebug_info_start0:
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
193 # unit.
194 # Roughly corresponds to this:
195 # struct A {
196 # virtual ~A(); // not defined here
197 # // implicit A() {}
198 # } a;
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
203 .byte 3
204 .quad a
205 .LA:
206 .byte 3 # Abbrev [3] DW_TAG_structure_type
207 .asciz "A" # DW_AT_name
208 # DW_AT_declaration
209 .LA_A:
210 .byte 4 # Abbrev [4] DW_TAG_subprogram
211 .asciz "A" # DW_AT_name
212 # DW_AT_declaration
213 .byte 5 # Abbrev [5] DW_TAG_formal_parameter
214 .long .LAptr-.Lcu_begin0 # DW_AT_type
215 # DW_AT_artificial
216 .byte 0 # End Of Children Mark
217 .byte 0 # End Of Children Mark
218 .LAptr:
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
225 .byte 86
226 .long .Lthis-.Lcu_begin0 # DW_AT_object_pointer
227 .long .LA_A-.Lcu_begin0 # DW_AT_specification
228 .Lthis:
229 .byte 11 # Abbrev [11] DW_TAG_formal_parameter
230 .byte 2 # DW_AT_location
231 .byte 145
232 .byte 120
233 .asciz "this" # DW_AT_name
234 .long .LAptr-.Lcu_begin0 # DW_AT_type
235 # DW_AT_artificial
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:
241 # struct B {
242 # virtual ~B(); // not defined here
243 # 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 that
249 # triggers a clang assertion.
250 .byte 3 # Abbrev [3] DW_TAG_structure_type
251 .asciz "B" # DW_AT_name
252 # DW_AT_declaration
253 .LB1:
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
268 .byte 3
269 .quad b1
271 # Case 3: A typedef in DW_AT_declaration struct.
272 # C++ equivalent:
273 # struct C {
274 # virtual ~C(); // not defined here
275 # typedef int C1;
276 # };
277 # C::C1 c1;
278 .Lint:
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
285 # DW_AT_declaration
286 .LC1:
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
296 .byte 3
297 .quad c1
299 .byte 0 # End Of Children Mark
300 .Ldebug_info_end0: