• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.
4
5# REQUIRES: x86
6
7# RUN: split-file %s %t
8# RUN: llvm-mc --triple x86_64-pc-linux %t/asm --filetype=obj -o %t.o
9# RUN: %lldb -o "settings set interpreter.stop-command-source-on-error false" \
10# RUN:   -s %t/commands -o exit %t.o 2>&1 | FileCheck %s
11
12#--- commands
13# Type A should be treated as a forward-declaration even though it has a child.
14target var a
15# CHECK-LABEL: target var a
16# FIXME: This should also produce some kind of an error.
17# CHECK: (A) a = {}
18expr a
19# CHECK-LABEL: expr a
20# CHECK: incomplete type 'A' where a complete type is required
21
22# Parsing B::B1 should not crash even though B is incomplete. Note that in this
23# case B must be forcefully completed.
24target var b1
25# CHECK-LABEL: target var b1
26# CHECK: (B::B1) b1 = (ptr = 0x00000000baadf00d)
27expr b1
28# CHECK-LABEL: expr b1
29# CHECK: (B::B1) $0 = (ptr = 0x00000000baadf00d)
30
31target var c1
32# CHECK-LABEL: target var c1
33# CHECK: (C::C1) c1 = 424742
34
35expr c1
36# CHECK-LABEL: expr c1
37# CHECK: (C::C1) $1 = 424742
38#--- asm
39        .text
40_ZN1AC2Ev:
41        retq
42.LZN1AC2Ev_end:
43
44        .data
45        .p2align 4
46a:
47        .quad   _ZTV1A+16
48        .quad   0xdeadbeef
49
50b1:
51        .quad   0xbaadf00d
52c1:
53        .long   42474247
54
55        .section        .debug_abbrev,"",@progbits
56        .byte   1                               # Abbreviation Code
57        .byte   17                              # DW_TAG_compile_unit
58        .byte   1                               # DW_CHILDREN_yes
59        .byte   37                              # DW_AT_producer
60        .byte   8                               # DW_FORM_string
61        .byte   17                              # DW_AT_low_pc
62        .byte   1                               # DW_FORM_addr
63        .byte   18                              # DW_AT_high_pc
64        .byte   6                               # DW_FORM_data4
65        .byte   0                               # EOM(1)
66        .byte   0                               # EOM(2)
67        .byte   2                               # Abbreviation Code
68        .byte   52                              # DW_TAG_variable
69        .byte   0                               # DW_CHILDREN_no
70        .byte   3                               # DW_AT_name
71        .byte   8                               # DW_FORM_string
72        .byte   73                              # DW_AT_type
73        .byte   19                              # DW_FORM_ref4
74        .byte   2                               # DW_AT_location
75        .byte   24                              # DW_FORM_exprloc
76        .byte   0                               # EOM(1)
77        .byte   0                               # EOM(2)
78        .byte   3                               # Abbreviation Code
79        .byte   19                              # DW_TAG_structure_type
80        .byte   1                               # DW_CHILDREN_yes
81        .byte   3                               # DW_AT_name
82        .byte   8                               # DW_FORM_string
83        .byte   60                              # DW_AT_declaration
84        .byte   25                              # DW_FORM_flag_present
85        .byte   0                               # EOM(1)
86        .byte   0                               # EOM(2)
87        .byte   4                               # Abbreviation Code
88        .byte   46                              # DW_TAG_subprogram
89        .byte   1                               # DW_CHILDREN_yes
90        .byte   3                               # DW_AT_name
91        .byte   8                               # DW_FORM_string
92        .byte   60                              # DW_AT_declaration
93        .byte   25                              # DW_FORM_flag_present
94        .byte   0                               # EOM(1)
95        .byte   0                               # EOM(2)
96        .byte   5                               # Abbreviation Code
97        .byte   5                               # DW_TAG_formal_parameter
98        .byte   0                               # DW_CHILDREN_no
99        .byte   73                              # DW_AT_type
100        .byte   19                              # DW_FORM_ref4
101        .byte   52                              # DW_AT_artificial
102        .byte   25                              # DW_FORM_flag_present
103        .byte   0                               # EOM(1)
104        .byte   0                               # EOM(2)
105        .byte   6                               # Abbreviation Code
106        .byte   2                               # DW_TAG_class_type
107        .byte   1                               # DW_CHILDREN_yes
108        .byte   3                               # DW_AT_name
109        .byte   8                               # DW_FORM_string
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
190
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
237
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   7                               # Abbrev [5] 0x58:0xc DW_TAG_member
257        .asciz  "ptr"                           # DW_AT_name
258        .long   .LAptr                          # DW_AT_type
259        .byte   0                               # DW_AT_data_member_location
260        .byte   0                               # End Of Children Mark
261        .byte   0                               # End Of Children Mark
262
263        .byte   2                               # Abbrev [2] DW_TAG_variable
264        .asciz  "b1"                            # DW_AT_name
265        .long   .LB1-.Lcu_begin0                # DW_AT_type
266        .byte   9                               # DW_AT_location
267        .byte   3
268        .quad   b1
269
270# Case 3: A typedef in DW_AT_declaration struct.
271# C++ equivalent:
272# struct C {
273#   virtual ~C(); // not defined here
274#   typedef int C1;
275# };
276# C::C1 c1;
277.Lint:
278        .byte   9                               # Abbrev [9] DW_TAG_base_type
279        .asciz  "int"                           # DW_AT_name
280        .byte   5                               # DW_AT_encoding
281        .byte   4                               # DW_AT_byte_size
282        .byte   3                               # Abbrev [3] DW_TAG_structure_type
283        .asciz  "C"                             # DW_AT_name
284                                                # DW_AT_declaration
285.LC1:
286        .byte   12                              # Abbrev [12] DW_TAG_typedef
287        .long   .Lint-.Lcu_begin0               # DW_AT_type
288        .asciz  "C1"                            # DW_AT_name
289        .byte   0                               # End Of Children Mark
290
291        .byte   2                               # Abbrev [2] DW_TAG_variable
292        .asciz  "c1"                            # DW_AT_name
293        .long   .LC1-.Lcu_begin0                # DW_AT_type
294        .byte   9                               # DW_AT_location
295        .byte   3
296        .quad   c1
297
298        .byte   0                               # End Of Children Mark
299.Ldebug_info_end0:
300