• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# This test ensures that dwarfdump doesn't crash for malformed DWARF where a
2# DIE references itself.
3#
4# Source:
5#   void f();
6#   __attribute__((always_inline)) void g() {
7#     f();
8#   }
9#   void h() {
10#     g();
11#   };
12#
13# Compile with:
14#   clang inlined.c -S -g -o inlined.s
15#
16# RUN: llvm-mc %s -filetype obj -triple x86_64-apple-darwin -o - \
17# RUN:   | llvm-dwarfdump -debug-info - \
18# RUN:   | FileCheck %s
19
20# CHECK: 0x0000005a:     DW_TAG_inlined_subroutine
21# CHECK-NEXT: DW_AT_abstract_origin (0x0000005a)
22
23	.section	__TEXT,__text,regular,pure_instructions
24	.macosx_version_min 10, 13
25	.globl	_g                      ## -- Begin function g
26	.p2align	4, 0x90
27_g:                                     ## @g
28Lfunc_begin0:
29	.file	1 "inlined.c"
30	.loc	1 2 0                   ## inlined.c:2:0
31	.cfi_startproc
32## %bb.0:                               ## %entry
33	pushq	%rbp
34	.cfi_def_cfa_offset 16
35	.cfi_offset %rbp, -16
36	movq	%rsp, %rbp
37	.cfi_def_cfa_register %rbp
38Ltmp0:
39	.loc	1 3 3 prologue_end      ## inlined.c:3:3
40	movb	$0, %al
41	callq	_f
42	.loc	1 4 1                   ## inlined.c:4:1
43	popq	%rbp
44	retq
45Ltmp1:
46Lfunc_end0:
47	.cfi_endproc
48                                        ## -- End function
49	.globl	_h                      ## -- Begin function h
50	.p2align	4, 0x90
51_h:                                     ## @h
52Lfunc_begin1:
53	.loc	1 5 0                   ## inlined.c:5:0
54	.cfi_startproc
55## %bb.0:                               ## %entry
56	pushq	%rbp
57	.cfi_def_cfa_offset 16
58	.cfi_offset %rbp, -16
59	movq	%rsp, %rbp
60	.cfi_def_cfa_register %rbp
61Ltmp2:
62	.loc	1 3 3 prologue_end      ## inlined.c:3:3
63	movb	$0, %al
64	callq	_f
65Ltmp3:
66	.loc	1 7 1                   ## inlined.c:7:1
67	popq	%rbp
68	retq
69Ltmp4:
70Lfunc_end1:
71	.cfi_endproc
72                                        ## -- End function
73	.section	__DWARF,__debug_str,regular,debug
74Linfo_string:
75	.asciz	"clang version 7.0.0 "  ## string offset=0
76	.asciz	"inlined.c"             ## string offset=21
77	.asciz	"/private/tmp"          ## string offset=31
78	.asciz	"g"                     ## string offset=44
79	.asciz	"h"                     ## string offset=46
80	.section	__DWARF,__debug_abbrev,regular,debug
81Lsection_abbrev:
82	.byte	1                       ## Abbreviation Code
83	.byte	17                      ## DW_TAG_compile_unit
84	.byte	1                       ## DW_CHILDREN_yes
85	.byte	37                      ## DW_AT_producer
86	.byte	14                      ## DW_FORM_strp
87	.byte	19                      ## DW_AT_language
88	.byte	5                       ## DW_FORM_data2
89	.byte	3                       ## DW_AT_name
90	.byte	14                      ## DW_FORM_strp
91	.byte	16                      ## DW_AT_stmt_list
92	.byte	23                      ## DW_FORM_sec_offset
93	.byte	27                      ## DW_AT_comp_dir
94	.byte	14                      ## DW_FORM_strp
95	.byte	17                      ## DW_AT_low_pc
96	.byte	1                       ## DW_FORM_addr
97	.byte	18                      ## DW_AT_high_pc
98	.byte	6                       ## DW_FORM_data4
99	.byte	0                       ## EOM(1)
100	.byte	0                       ## EOM(2)
101	.byte	2                       ## Abbreviation Code
102	.byte	46                      ## DW_TAG_subprogram
103	.byte	0                       ## DW_CHILDREN_no
104	.byte	17                      ## DW_AT_low_pc
105	.byte	1                       ## DW_FORM_addr
106	.byte	18                      ## DW_AT_high_pc
107	.byte	6                       ## DW_FORM_data4
108	.byte	64                      ## DW_AT_frame_base
109	.byte	24                      ## DW_FORM_exprloc
110	.byte	49                      ## DW_AT_abstract_origin
111	.byte	19                      ## DW_FORM_ref4
112	.byte	0                       ## EOM(1)
113	.byte	0                       ## EOM(2)
114	.byte	3                       ## Abbreviation Code
115	.byte	46                      ## DW_TAG_subprogram
116	.byte	0                       ## DW_CHILDREN_no
117	.byte	3                       ## DW_AT_name
118	.byte	14                      ## DW_FORM_strp
119	.byte	58                      ## DW_AT_decl_file
120	.byte	11                      ## DW_FORM_data1
121	.byte	59                      ## DW_AT_decl_line
122	.byte	11                      ## DW_FORM_data1
123	.byte	63                      ## DW_AT_external
124	.byte	25                      ## DW_FORM_flag_present
125	.byte	32                      ## DW_AT_inline
126	.byte	11                      ## DW_FORM_data1
127	.byte	0                       ## EOM(1)
128	.byte	0                       ## EOM(2)
129	.byte	4                       ## Abbreviation Code
130	.byte	46                      ## DW_TAG_subprogram
131	.byte	1                       ## DW_CHILDREN_yes
132	.byte	17                      ## DW_AT_low_pc
133	.byte	1                       ## DW_FORM_addr
134	.byte	18                      ## DW_AT_high_pc
135	.byte	6                       ## DW_FORM_data4
136	.byte	64                      ## DW_AT_frame_base
137	.byte	24                      ## DW_FORM_exprloc
138	.byte	3                       ## DW_AT_name
139	.byte	14                      ## DW_FORM_strp
140	.byte	58                      ## DW_AT_decl_file
141	.byte	11                      ## DW_FORM_data1
142	.byte	59                      ## DW_AT_decl_line
143	.byte	11                      ## DW_FORM_data1
144	.byte	63                      ## DW_AT_external
145	.byte	25                      ## DW_FORM_flag_present
146	.byte	0                       ## EOM(1)
147	.byte	0                       ## EOM(2)
148	.byte	5                       ## Abbreviation Code
149	.byte	29                      ## DW_TAG_inlined_subroutine
150	.byte	0                       ## DW_CHILDREN_no
151	.byte	49                      ## DW_AT_abstract_origin
152	.byte	19                      ## DW_FORM_ref4
153	.byte	17                      ## DW_AT_low_pc
154	.byte	1                       ## DW_FORM_addr
155	.byte	18                      ## DW_AT_high_pc
156	.byte	6                       ## DW_FORM_data4
157	.byte	88                      ## DW_AT_call_file
158	.byte	11                      ## DW_FORM_data1
159	.byte	89                      ## DW_AT_call_line
160	.byte	11                      ## DW_FORM_data1
161	.byte	0                       ## EOM(1)
162	.byte	0                       ## EOM(2)
163	.byte	0                       ## EOM(3)
164	.section	__DWARF,__debug_info,regular,debug
165Lsection_info:
166Lcu_begin0:
167	.long	107                     ## Length of Unit
168	.short	4                       ## DWARF version number
169Lset0 = Lsection_abbrev-Lsection_abbrev ## Offset Into Abbrev. Section
170	.long	Lset0
171	.byte	8                       ## Address Size (in bytes)
172	.byte	1                       ## Abbrev [1] 0xb:0x64 DW_TAG_compile_unit
173	.long	0                       ## DW_AT_producer
174	.short	12                      ## DW_AT_language
175	.long	21                      ## DW_AT_name
176Lset1 = Lline_table_start0-Lsection_line ## DW_AT_stmt_list
177	.long	Lset1
178	.long	31                      ## DW_AT_comp_dir
179	.quad	Lfunc_begin0            ## DW_AT_low_pc
180Lset2 = Lfunc_end1-Lfunc_begin0         ## DW_AT_high_pc
181	.long	Lset2
182	.byte	2                       ## Abbrev [2] 0x2a:0x13 DW_TAG_subprogram
183	.quad	Lfunc_begin0            ## DW_AT_low_pc
184Lset3 = Lfunc_end0-Lfunc_begin0         ## DW_AT_high_pc
185	.long	Lset3
186	.byte	1                       ## DW_AT_frame_base
187	.byte	86
188	.long	61                      ## DW_AT_abstract_origin
189	.byte	3                       ## Abbrev [3] 0x3d:0x8 DW_TAG_subprogram
190	.long	44                      ## DW_AT_name
191	.byte	1                       ## DW_AT_decl_file
192	.byte	2                       ## DW_AT_decl_line
193                                        ## DW_AT_external
194	.byte	1                       ## DW_AT_inline
195	.byte	4                       ## Abbrev [4] 0x45:0x29 DW_TAG_subprogram
196	.quad	Lfunc_begin1            ## DW_AT_low_pc
197Lset4 = Lfunc_end1-Lfunc_begin1         ## DW_AT_high_pc
198	.long	Lset4
199	.byte	1                       ## DW_AT_frame_base
200	.byte	86
201	.long	46                      ## DW_AT_name
202	.byte	1                       ## DW_AT_decl_file
203	.byte	5                       ## DW_AT_decl_line
204                                        ## DW_AT_external
205	.byte	5                       ## Abbrev [5] 0x5a:0x13 DW_TAG_inlined_subroutine
206	.long	90                      ## DW_AT_abstract_origin <- We modified the value so the DIE references itself.
207	.quad	Ltmp2                   ## DW_AT_low_pc
208Lset5 = Ltmp3-Ltmp2                     ## DW_AT_high_pc
209	.long	Lset5
210	.byte	1                       ## DW_AT_call_file
211	.byte	6                       ## DW_AT_call_line
212	.byte	0                       ## End Of Children Mark
213	.byte	0                       ## End Of Children Mark
214	.section	__DWARF,__debug_ranges,regular,debug
215Ldebug_range:
216	.section	__DWARF,__debug_macinfo,regular,debug
217Ldebug_macinfo:
218Lcu_macro_begin0:
219	.byte	0                       ## End Of Macro List Mark
220	.section	__DWARF,__apple_names,regular,debug
221Lnames_begin:
222	.long	1212240712              ## Header Magic
223	.short	1                       ## Header Version
224	.short	0                       ## Header Hash Function
225	.long	2                       ## Header Bucket Count
226	.long	2                       ## Header Hash Count
227	.long	12                      ## Header Data Length
228	.long	0                       ## HeaderData Die Offset Base
229	.long	1                       ## HeaderData Atom Count
230	.short	1                       ## DW_ATOM_die_offset
231	.short	6                       ## DW_FORM_data4
232	.long	0                       ## Bucket 0
233	.long	1                       ## Bucket 1
234	.long	177676                  ## Hash in Bucket 0
235	.long	177677                  ## Hash in Bucket 1
236	.long	LNames0-Lnames_begin    ## Offset in Bucket 0
237	.long	LNames1-Lnames_begin    ## Offset in Bucket 1
238LNames0:
239	.long	44                      ## g
240	.long	2                       ## Num DIEs
241	.long	42
242	.long	90
243	.long	0
244LNames1:
245	.long	46                      ## h
246	.long	1                       ## Num DIEs
247	.long	69
248	.long	0
249	.section	__DWARF,__apple_objc,regular,debug
250Lobjc_begin:
251	.long	1212240712              ## Header Magic
252	.short	1                       ## Header Version
253	.short	0                       ## Header Hash Function
254	.long	1                       ## Header Bucket Count
255	.long	0                       ## Header Hash Count
256	.long	12                      ## Header Data Length
257	.long	0                       ## HeaderData Die Offset Base
258	.long	1                       ## HeaderData Atom Count
259	.short	1                       ## DW_ATOM_die_offset
260	.short	6                       ## DW_FORM_data4
261	.long	-1                      ## Bucket 0
262	.section	__DWARF,__apple_namespac,regular,debug
263Lnamespac_begin:
264	.long	1212240712              ## Header Magic
265	.short	1                       ## Header Version
266	.short	0                       ## Header Hash Function
267	.long	1                       ## Header Bucket Count
268	.long	0                       ## Header Hash Count
269	.long	12                      ## Header Data Length
270	.long	0                       ## HeaderData Die Offset Base
271	.long	1                       ## HeaderData Atom Count
272	.short	1                       ## DW_ATOM_die_offset
273	.short	6                       ## DW_FORM_data4
274	.long	-1                      ## Bucket 0
275	.section	__DWARF,__apple_types,regular,debug
276Ltypes_begin:
277	.long	1212240712              ## Header Magic
278	.short	1                       ## Header Version
279	.short	0                       ## Header Hash Function
280	.long	1                       ## Header Bucket Count
281	.long	0                       ## Header Hash Count
282	.long	20                      ## Header Data Length
283	.long	0                       ## HeaderData Die Offset Base
284	.long	3                       ## HeaderData Atom Count
285	.short	1                       ## DW_ATOM_die_offset
286	.short	6                       ## DW_FORM_data4
287	.short	3                       ## DW_ATOM_die_tag
288	.short	5                       ## DW_FORM_data2
289	.short	4                       ## DW_ATOM_type_flags
290	.short	11                      ## DW_FORM_data1
291	.long	-1                      ## Bucket 0
292
293.subsections_via_symbols
294	.section	__DWARF,__debug_line,regular,debug
295Lsection_line:
296Lline_table_start0:
297