Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / lldb / test / Shell / SymbolFile / DWARF / x86 / DW_AT_declaration-with-children.s
blobbc462ca32e9ce081fe4a2f48ebe393fccbdc43bc
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 = {}
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 0 # EOM(1)
109 .byte 0 # EOM(2)
110 .byte 7 # Abbreviation Code
111 .byte 13 # DW_TAG_member
112 .byte 0 # DW_CHILDREN_no
113 .byte 3 # DW_AT_name
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
119 .byte 0 # EOM(1)
120 .byte 0 # EOM(2)
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
126 .byte 0 # EOM(1)
127 .byte 0 # EOM(2)
128 .byte 9 # Abbreviation Code
129 .byte 36 # DW_TAG_base_type
130 .byte 0 # DW_CHILDREN_no
131 .byte 3 # DW_AT_name
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
137 .byte 0 # EOM(1)
138 .byte 0 # EOM(2)
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
152 .byte 0 # EOM(1)
153 .byte 0 # EOM(2)
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
159 .byte 3 # DW_AT_name
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
165 .byte 0 # EOM(1)
166 .byte 0 # EOM(2)
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
172 .byte 3 # DW_AT_name
173 .byte 8 # DW_FORM_string
174 .byte 0 # EOM(1)
175 .byte 0 # EOM(2)
176 .byte 0 # EOM(3)
177 .section .debug_info,"",@progbits
178 .Lcu_begin0:
179 .long .Ldebug_info_end0-.Ldebug_info_start0 # Length of Unit
180 .Ldebug_info_start0:
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
191 # unit.
192 # Roughly corresponds to this:
193 # struct A {
194 # virtual ~A(); // not defined here
195 # // implicit A() {}
196 # } a;
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
201 .byte 3
202 .quad a
203 .LA:
204 .byte 3 # Abbrev [3] DW_TAG_structure_type
205 .asciz "A" # DW_AT_name
206 # DW_AT_declaration
207 .LA_A:
208 .byte 4 # Abbrev [4] DW_TAG_subprogram
209 .asciz "A" # DW_AT_name
210 # DW_AT_declaration
211 .byte 5 # Abbrev [5] DW_TAG_formal_parameter
212 .long .LAptr-.Lcu_begin0 # DW_AT_type
213 # DW_AT_artificial
214 .byte 0 # End Of Children Mark
215 .byte 0 # End Of Children Mark
216 .LAptr:
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
223 .byte 86
224 .long .Lthis-.Lcu_begin0 # DW_AT_object_pointer
225 .long .LA_A-.Lcu_begin0 # DW_AT_specification
226 .Lthis:
227 .byte 11 # Abbrev [11] DW_TAG_formal_parameter
228 .byte 2 # DW_AT_location
229 .byte 145
230 .byte 120
231 .asciz "this" # DW_AT_name
232 .long .LAptr-.Lcu_begin0 # DW_AT_type
233 # DW_AT_artificial
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:
239 # struct B {
240 # virtual ~B(); // not defined here
241 # class B1 {
242 # A* ptr;
243 # };
244 # };
245 # B::B1 b1;
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
250 # DW_AT_declaration
251 .LB1:
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
265 .byte 3
266 .quad b1
268 # Case 3: A typedef in DW_AT_declaration struct.
269 # C++ equivalent:
270 # struct C {
271 # virtual ~C(); // not defined here
272 # typedef int C1;
273 # };
274 # C::C1 c1;
275 .Lint:
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
282 # DW_AT_declaration
283 .LC1:
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
293 .byte 3
294 .quad c1
296 .byte 0 # End Of Children Mark
297 .Ldebug_info_end0: