DW_AT_declaration-with-children.s
14.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
# Test handling of forward-declared (DW_AT_declaration) structures. These types
# can be produced due to vtable-based type homing, or other -flimit-debug-info
# optimizations.
# REQUIRES: x86
# RUN: split-file %s %t
# RUN: llvm-mc --triple x86_64-pc-linux %t/asm --filetype=obj -o %t.o
# RUN: %lldb -o "settings set interpreter.stop-command-source-on-error false" \
# RUN: -s %t/commands -o exit %t.o 2>&1 | FileCheck %s
#--- commands
# Type A should be treated as a forward-declaration even though it has a child.
target var a
# CHECK-LABEL: target var a
# FIXME: This should also produce some kind of an error.
# CHECK: (A) a = {}
expr a
# CHECK-LABEL: expr a
# CHECK: incomplete type 'A' where a complete type is required
# Parsing B::B1 should not crash even though B is incomplete. Note that in this
# case B must be forcefully completed.
target var b1
# CHECK-LABEL: target var b1
# CHECK: (B::B1) b1 = (ptr = 0x00000000baadf00d)
expr b1
# CHECK-LABEL: expr b1
# CHECK: (B::B1) $0 = (ptr = 0x00000000baadf00d)
target var c1
# CHECK-LABEL: target var c1
# CHECK: (C::C1) c1 = 424742
expr c1
# CHECK-LABEL: expr c1
# CHECK: (C::C1) $1 = 424742
#--- asm
.text
_ZN1AC2Ev:
retq
.LZN1AC2Ev_end:
.data
.p2align 4
a:
.quad _ZTV1A+16
.quad 0xdeadbeef
b1:
.quad 0xbaadf00d
c1:
.long 42474247
.section .debug_abbrev,"",@progbits
.byte 1 # Abbreviation Code
.byte 17 # DW_TAG_compile_unit
.byte 1 # DW_CHILDREN_yes
.byte 37 # DW_AT_producer
.byte 8 # DW_FORM_string
.byte 17 # DW_AT_low_pc
.byte 1 # DW_FORM_addr
.byte 18 # DW_AT_high_pc
.byte 6 # DW_FORM_data4
.byte 0 # EOM(1)
.byte 0 # EOM(2)
.byte 2 # Abbreviation Code
.byte 52 # DW_TAG_variable
.byte 0 # DW_CHILDREN_no
.byte 3 # DW_AT_name
.byte 8 # DW_FORM_string
.byte 73 # DW_AT_type
.byte 19 # DW_FORM_ref4
.byte 2 # DW_AT_location
.byte 24 # DW_FORM_exprloc
.byte 0 # EOM(1)
.byte 0 # EOM(2)
.byte 3 # Abbreviation Code
.byte 19 # DW_TAG_structure_type
.byte 1 # DW_CHILDREN_yes
.byte 3 # DW_AT_name
.byte 8 # DW_FORM_string
.byte 60 # DW_AT_declaration
.byte 25 # DW_FORM_flag_present
.byte 0 # EOM(1)
.byte 0 # EOM(2)
.byte 4 # Abbreviation Code
.byte 46 # DW_TAG_subprogram
.byte 1 # DW_CHILDREN_yes
.byte 3 # DW_AT_name
.byte 8 # DW_FORM_string
.byte 60 # DW_AT_declaration
.byte 25 # DW_FORM_flag_present
.byte 0 # EOM(1)
.byte 0 # EOM(2)
.byte 5 # Abbreviation Code
.byte 5 # DW_TAG_formal_parameter
.byte 0 # DW_CHILDREN_no
.byte 73 # DW_AT_type
.byte 19 # DW_FORM_ref4
.byte 52 # DW_AT_artificial
.byte 25 # DW_FORM_flag_present
.byte 0 # EOM(1)
.byte 0 # EOM(2)
.byte 6 # Abbreviation Code
.byte 2 # DW_TAG_class_type
.byte 1 # DW_CHILDREN_yes
.byte 3 # DW_AT_name
.byte 8 # DW_FORM_string
.byte 0 # EOM(1)
.byte 0 # EOM(2)
.byte 7 # Abbreviation Code
.byte 13 # DW_TAG_member
.byte 0 # DW_CHILDREN_no
.byte 3 # DW_AT_name
.byte 8 # DW_FORM_string
.byte 73 # DW_AT_type
.byte 19 # DW_FORM_ref4
.byte 56 # DW_AT_data_member_location
.byte 11 # DW_FORM_data1
.byte 0 # EOM(1)
.byte 0 # EOM(2)
.byte 8 # Abbreviation Code
.byte 15 # DW_TAG_pointer_type
.byte 0 # DW_CHILDREN_no
.byte 73 # DW_AT_type
.byte 19 # DW_FORM_ref4
.byte 0 # EOM(1)
.byte 0 # EOM(2)
.byte 9 # Abbreviation Code
.byte 36 # DW_TAG_base_type
.byte 0 # DW_CHILDREN_no
.byte 3 # DW_AT_name
.byte 8 # DW_FORM_string
.byte 62 # DW_AT_encoding
.byte 11 # DW_FORM_data1
.byte 11 # DW_AT_byte_size
.byte 11 # DW_FORM_data1
.byte 0 # EOM(1)
.byte 0 # EOM(2)
.byte 10 # Abbreviation Code
.byte 46 # DW_TAG_subprogram
.byte 1 # DW_CHILDREN_yes
.byte 17 # DW_AT_low_pc
.byte 1 # DW_FORM_addr
.byte 18 # DW_AT_high_pc
.byte 6 # DW_FORM_data4
.byte 64 # DW_AT_frame_base
.byte 24 # DW_FORM_exprloc
.byte 100 # DW_AT_object_pointer
.byte 19 # DW_FORM_ref4
.byte 71 # DW_AT_specification
.byte 19 # DW_FORM_ref4
.byte 0 # EOM(1)
.byte 0 # EOM(2)
.byte 11 # Abbreviation Code
.byte 5 # DW_TAG_formal_parameter
.byte 0 # DW_CHILDREN_no
.byte 2 # DW_AT_location
.byte 24 # DW_FORM_exprloc
.byte 3 # DW_AT_name
.byte 8 # DW_FORM_string
.byte 73 # DW_AT_type
.byte 19 # DW_FORM_ref4
.byte 52 # DW_AT_artificial
.byte 25 # DW_FORM_flag_present
.byte 0 # EOM(1)
.byte 0 # EOM(2)
.byte 12 # Abbreviation Code
.byte 22 # DW_TAG_typedef
.byte 0 # DW_CHILDREN_no
.byte 73 # DW_AT_type
.byte 19 # DW_FORM_ref4
.byte 3 # DW_AT_name
.byte 8 # DW_FORM_string
.byte 0 # EOM(1)
.byte 0 # EOM(2)
.byte 0 # EOM(3)
.section .debug_info,"",@progbits
.Lcu_begin0:
.long .Ldebug_info_end0-.Ldebug_info_start0 # Length of Unit
.Ldebug_info_start0:
.short 4 # DWARF version number
.long .debug_abbrev # Offset Into Abbrev. Section
.byte 8 # Address Size (in bytes)
.byte 1 # Abbrev [1] DW_TAG_compile_unit
.asciz "Hand-written DWARF" # DW_AT_producer
.quad _ZN1AC2Ev # DW_AT_low_pc
.long .LZN1AC2Ev_end-_ZN1AC2Ev # DW_AT_high_pc
# Case 1: The compiler has omitted the declaration of the type, but it still
# produces an entry for its implicit constructor instantiated in this compile
# unit.
# Roughly corresponds to this:
# struct A {
# virtual ~A(); // not defined here
# // implicit A() {}
# } a;
.byte 2 # Abbrev [2] DW_TAG_variable
.asciz "a" # DW_AT_name
.long .LA-.Lcu_begin0 # DW_AT_type
.byte 9 # DW_AT_location
.byte 3
.quad a
.LA:
.byte 3 # Abbrev [3] DW_TAG_structure_type
.asciz "A" # DW_AT_name
# DW_AT_declaration
.byte 4 # Abbrev [4] DW_TAG_subprogram
.asciz "A" # DW_AT_name
# DW_AT_declaration
.byte 5 # Abbrev [5] DW_TAG_formal_parameter
.long .LAptr-.Lcu_begin0 # DW_AT_type
# DW_AT_artificial
.byte 0 # End Of Children Mark
.byte 0 # End Of Children Mark
.LAptr:
.byte 8 # Abbrev [8] DW_TAG_pointer_type
.long .LA-.Lcu_begin0 # DW_AT_type
.byte 10 # Abbrev [10] DW_TAG_subprogram
.quad _ZN1AC2Ev # DW_AT_low_pc
.long .LZN1AC2Ev_end-_ZN1AC2Ev # DW_AT_high_pc
.byte 1 # DW_AT_frame_base
.byte 86
.long 147 # DW_AT_object_pointer
.long 68 # DW_AT_specification
.byte 11 # Abbrev [11] DW_TAG_formal_parameter
.byte 2 # DW_AT_location
.byte 145
.byte 120
.asciz "this" # DW_AT_name
.long .LAptr-.Lcu_begin0 # DW_AT_type
# DW_AT_artificial
.byte 0 # End Of Children Mark
# Case 2: A structure has been emitted as a declaration only, but it contains a
# nested class, which has a full definition present.
# Rougly corresponds to this:
# struct B {
# virtual ~B(); // not defined here
# class B1 {
# A* ptr;
# };
# };
# B::B1 b1;
# Note that it is important that the inner type is a class (not struct) as that
# triggers a clang assertion.
.byte 3 # Abbrev [3] DW_TAG_structure_type
.asciz "B" # DW_AT_name
# DW_AT_declaration
.LB1:
.byte 6 # Abbrev [6] DW_TAG_class_type
.asciz "B1" # DW_AT_name
.byte 7 # Abbrev [5] 0x58:0xc DW_TAG_member
.asciz "ptr" # DW_AT_name
.long .LAptr # DW_AT_type
.byte 0 # DW_AT_data_member_location
.byte 0 # End Of Children Mark
.byte 0 # End Of Children Mark
.byte 2 # Abbrev [2] DW_TAG_variable
.asciz "b1" # DW_AT_name
.long .LB1-.Lcu_begin0 # DW_AT_type
.byte 9 # DW_AT_location
.byte 3
.quad b1
# Case 3: A typedef in DW_AT_declaration struct.
# C++ equivalent:
# struct C {
# virtual ~C(); // not defined here
# typedef int C1;
# };
# C::C1 c1;
.Lint:
.byte 9 # Abbrev [9] DW_TAG_base_type
.asciz "int" # DW_AT_name
.byte 5 # DW_AT_encoding
.byte 4 # DW_AT_byte_size
.byte 3 # Abbrev [3] DW_TAG_structure_type
.asciz "C" # DW_AT_name
# DW_AT_declaration
.LC1:
.byte 12 # Abbrev [12] DW_TAG_typedef
.long .Lint-.Lcu_begin0 # DW_AT_type
.asciz "C1" # DW_AT_name
.byte 0 # End Of Children Mark
.byte 2 # Abbrev [2] DW_TAG_variable
.asciz "c1" # DW_AT_name
.long .LC1-.Lcu_begin0 # DW_AT_type
.byte 9 # DW_AT_location
.byte 3
.quad c1
.byte 0 # End Of Children Mark
.Ldebug_info_end0: