xref: /netbsd-src/external/gpl3/gdb/dist/gdb/testsuite/gdb.dwarf2/pr13961.S (revision f8cf1a9151c7af1cb0bd8b09c13c66bca599c027)
1/* Copyright 2012-2024 Free Software Foundation, Inc.
2
3   This program is free software; you can redistribute it and/or modify
4   it under the terms of the GNU General Public License as published by
5   the Free Software Foundation; either version 3 of the License, or
6   (at your option) any later version.
7
8   This program is distributed in the hope that it will be useful,
9   but WITHOUT ANY WARRANTY; without even the implied warranty of
10   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11   GNU General Public License for more details.
12
13   You should have received a copy of the GNU General Public License
14   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
15
16/* Testcase to exercise the code path in bug 13961.
17
18   Compiled from:
19
20   class foo
21   {
22    public:
23     int bar;
24   };
25
26   foo baz;
27
28   int
29   main ()
30   {
31     return 0;
32   }
33
34   And then manually edited to insert the necessary DW_AT_specification
35   entries to trigger the desired code path.
36   There's no real need to make this architecture-specific, so it has been
37   further hand-edited to support that.
38*/
39
40#define CONCAT1(a, b) CONCAT2(a, b)
41#define CONCAT2(a, b) a ## b
42
43#ifdef SYMBOL_PREFIX
44# define SYMBOL(str)     CONCAT1(SYMBOL_PREFIX, str)
45#else
46# define SYMBOL(str)     str
47#endif
48
49	.file	"pr13961.cc"
50
51	.globl	baz
52	.data	/* Previously this used .bss, but it's not portable.  */
53	.align 4
54	.type	baz, %object
55	.size	baz, 4
56baz:
57#if 0
58	/* This is disabled because when it was accidentally left out it
59	   caused a segv when used with .gdb_index.  */
60	.file	1 "foo.c"
61	.loc	1 12 0
62#endif
63	.zero	4
64
65	.text
66.Ltext0:
67	.globl	SYMBOL(main)
68	.type	SYMBOL(main), %function
69SYMBOL(main):
70.LFB0:
71	.4byte 0
72.LFE0:
73	.size	SYMBOL(main), .-SYMBOL(main)
74.Letext0:
75
76	.section	.debug_types,"",%progbits
77.Ldebug_types0:
78	.4byte	.Ltu_end - .Ltu_start	/* Length of Compilation Unit Info */
79.Ltu_start:
80	.2byte	0x4	/* DWARF version number */
81	.4byte	.Ldebug_abbrev0	/* Offset Into Abbrev. Section */
82	.byte	0x4	/* Pointer Size (in bytes) */
83	.byte	0x19	/* Type Signature */
84	.byte	0x8b
85	.byte	0x7e
86	.byte	0xac
87	.byte	0xce
88	.byte	0xf1
89	.byte	0x22
90	.byte	0x90
91	.4byte	.Ltu_class_type - .Ldebug_types0 /* Offset to Type DIE */
92	.uleb128 0x1	/* DW_TAG_type_unit */
93	.byte	0x4	/* DW_AT_language */
94	.byte	0x73	/* DW_AT_GNU_odr_signature */
95	.byte	0xea
96	.byte	0x85
97	.byte	0x23
98	.byte	0x75
99	.byte	0x8a
100	.byte	0x7e
101	.byte	0x87
102	.4byte	.Ldebug_line0	/* DW_AT_stmt_list */
103
104	/* Manually inserted to have a DW_AT_specification refering to
105	   something and appearing ahead of it.  */
106	.uleb128 0x8	/* DW_TAG_class_type */
107	.4byte .Ltu_class_type - .Ldebug_types0
108	/* End of manual insertion */
109
110.Ltu_class_type:
111	.uleb128 0x2	/* (DW_TAG_class_type) */
112	.ascii "foo\0"	/* DW_AT_name */
113	.byte	0x4	/* DW_AT_byte_size */
114	.byte	0x1	/* DW_AT_decl_file (pr13961.cc) */
115	.byte	0x1	/* DW_AT_decl_line */
116	.4byte	.Ltu_base_type - .Ldebug_types0	/* DW_AT_sibling */
117
118		.uleb128 0x3	/* (DW_TAG_member) */
119		.ascii "bar\0"	/* DW_AT_name */
120		.byte	0x1	/* DW_AT_decl_file (pr13961.cc) */
121		.byte	0x4	/* DW_AT_decl_line */
122		.4byte	.Ltu_base_type - .Ldebug_types0	/* DW_AT_type */
123		.byte	0	/* DW_AT_data_member_location */
124		.byte	0x1	/* DW_AT_accessibility */
125		.byte	0	/* end of children */
126
127.Ltu_base_type:
128	.uleb128 0x4	/* DW_TAG_base_type */
129	.byte	0x4	/* DW_AT_byte_size */
130	.byte	0x5	/* DW_AT_encoding */
131	.ascii "int\0"	/* DW_AT_name */
132	.byte	0	/* end of children */
133
134.Ltu_end:
135
136	.section	.debug_info,"",%progbits
137.Ldebug_info0:
138	.4byte	.Lcu_end - .Lcu_start	/* Length of Compilation Unit Info */
139.Lcu_start:
140	.2byte	0x4	/* DWARF version number */
141	.4byte	.Ldebug_abbrev0	/* Offset Into Abbrev. Section */
142	.byte	0x4	/* Pointer Size (in bytes) */
143
144	.uleb128 0x5	/* (DW_TAG_compile_unit) */
145	.4byte	.LASF0	/* DW_AT_producer: "GNU C++ 4.6.3 20120306" */
146	.byte	0x4	/* DW_AT_language */
147	.4byte	.LASF1	/* DW_AT_name: "pr13961.cc" */
148	.4byte	.LASF2	/* DW_AT_comp_dir: "." */
149	.4byte	.Ltext0	/* DW_AT_low_pc */
150	.4byte	.Letext0	/* DW_AT_high_pc */
151	.4byte	.Ldebug_line0	/* DW_AT_stmt_list */
152
153.Lint_base_type:
154		.uleb128 0x4	/* DW_TAG_base_type */
155		.byte	0x4	/* DW_AT_byte_size */
156		.byte	0x5	/* DW_AT_encoding */
157		.ascii "int\0"	/* DW_AT_name */
158
159		.uleb128 0x6	/* DW_TAG_subprogram */
160				/* DW_AT_external */
161		.4byte	.LASF3	/* DW_AT_name: "main" */
162		.byte	0x1	/* DW_AT_decl_file (pr13961.cc) */
163		.byte	0xa	/* DW_AT_decl_line */
164		.4byte	.Lint_base_type - .Ldebug_info0	/* DW_AT_type */
165		.4byte	.LFB0	/* DW_AT_low_pc */
166		.4byte	.LFE0	/* DW_AT_high_pc */
167		.uleb128 0x1	/* DW_AT_frame_base */
168		.byte	0x9c	/* DW_OP_call_frame_cfa */
169				/* DW_AT_GNU_all_call_sites */
170
171		.uleb128 0x7	/* DW_TAG_variable */
172		.ascii "baz\0"	/* DW_AT_name */
173		.byte	0x1	/* DW_AT_decl_file (pr13961.cc) */
174		.byte	0x7	/* DW_AT_decl_line */
175		.byte	0x19	/* DW_AT_type */
176		.byte	0x8b
177		.byte	0x7e
178		.byte	0xac
179		.byte	0xce
180		.byte	0xf1
181		.byte	0x22
182		.byte	0x90
183				/* DW_AT_external */
184		.uleb128 0x5	/* DW_AT_location */
185		.byte	0x3	/* DW_OP_addr */
186		.4byte	baz
187
188		/* Manually inserted to have a DW_AT_specification refering to
189		   something and appearing ahead of it.  */
190		.uleb128 0x8	/* DW_TAG_class_type */
191		.4byte .Lcu_class_type - .Ldebug_info0 /* DW_AT_specification */
192
193.Lcu_int_type:
194		.uleb128 0x4	/* DW_TAG_base_type */
195		.byte	0x4	/* DW_AT_byte_size */
196		.byte	0x5	/* DW_AT_encoding */
197		.ascii "int\0"	/* DW_AT_name */
198
199.Lcu_class_type:
200		.uleb128 0x2	/* DW_TAG_class_type */
201		.ascii "foo2\0"	/* DW_AT_name */
202		.byte	0x4	/* DW_AT_byte_size */
203		.byte	0x1	/* DW_AT_decl_file (pr13961.cc) */
204		.byte	0x1	/* DW_AT_decl_line */
205		.4byte	.Lcu_second_int_type - .Ldebug_info0	/* DW_AT_sibling */
206
207			.uleb128 0x3	/* DW_TAG_member */
208			.ascii "bar\0"	/* DW_AT_name */
209			.byte	0x1	/* DW_AT_decl_file (pr13961.cc) */
210			.byte	0x4	/* DW_AT_decl_line */
211			.4byte	.Lcu_second_int_type - .Ldebug_info0 /* DW_AT_type */
212			.byte	0	/* DW_AT_data_member_location */
213			.byte	0x1	/* DW_AT_accessibility */
214			.byte	0	/* end of children */
215
216.Lcu_second_int_type:
217		.uleb128 0x4	/* DW_TAG_base_type */
218		.byte	0x4	/* DW_AT_byte_size */
219		.byte	0x5	/* DW_AT_encoding */
220		.ascii "int\0"	/* DW_AT_name */
221		/* End of manual insertion */
222
223		.byte	0	/* end of children */
224
225.Lcu_end:
226
227	.section	.debug_abbrev,"",%progbits
228.Ldebug_abbrev0:
229	.uleb128 0x1	/* (abbrev code) */
230	.uleb128 0x41	/* (TAG: DW_TAG_type_unit) */
231	.byte	0x1	/* DW_children_yes */
232	.uleb128 0x13	/* (DW_AT_language) */
233	.uleb128 0xb	/* (DW_FORM_data1) */
234	.uleb128 0x210f	/* (DW_AT_GNU_odr_signature) */
235	.uleb128 0x7	/* (DW_FORM_data8) */
236	.uleb128 0x10	/* (DW_AT_stmt_list) */
237	.uleb128 0x17	/* (DW_FORM_sec_offset) */
238	.byte	0
239	.byte	0
240	.uleb128 0x2	/* (abbrev code) */
241	.uleb128 0x2	/* (TAG: DW_TAG_class_type) */
242	.byte	0x1	/* DW_children_yes */
243	.uleb128 0x3	/* (DW_AT_name) */
244	.uleb128 0x8	/* (DW_FORM_string) */
245	.uleb128 0xb	/* (DW_AT_byte_size) */
246	.uleb128 0xb	/* (DW_FORM_data1) */
247	.uleb128 0x3a	/* (DW_AT_decl_file) */
248	.uleb128 0xb	/* (DW_FORM_data1) */
249	.uleb128 0x3b	/* (DW_AT_decl_line) */
250	.uleb128 0xb	/* (DW_FORM_data1) */
251	.uleb128 0x1	/* (DW_AT_sibling) */
252	.uleb128 0x13	/* (DW_FORM_ref4) */
253	.byte	0
254	.byte	0
255	.uleb128 0x3	/* (abbrev code) */
256	.uleb128 0xd	/* (TAG: DW_TAG_member) */
257	.byte	0	/* DW_children_no */
258	.uleb128 0x3	/* (DW_AT_name) */
259	.uleb128 0x8	/* (DW_FORM_string) */
260	.uleb128 0x3a	/* (DW_AT_decl_file) */
261	.uleb128 0xb	/* (DW_FORM_data1) */
262	.uleb128 0x3b	/* (DW_AT_decl_line) */
263	.uleb128 0xb	/* (DW_FORM_data1) */
264	.uleb128 0x49	/* (DW_AT_type) */
265	.uleb128 0x13	/* (DW_FORM_ref4) */
266	.uleb128 0x38	/* (DW_AT_data_member_location) */
267	.uleb128 0xb	/* (DW_FORM_data1) */
268	.uleb128 0x32	/* (DW_AT_accessibility) */
269	.uleb128 0xb	/* (DW_FORM_data1) */
270	.byte	0
271	.byte	0
272	.uleb128 0x4	/* (abbrev code) */
273	.uleb128 0x24	/* (TAG: DW_TAG_base_type) */
274	.byte	0	/* DW_children_no */
275	.uleb128 0xb	/* (DW_AT_byte_size) */
276	.uleb128 0xb	/* (DW_FORM_data1) */
277	.uleb128 0x3e	/* (DW_AT_encoding) */
278	.uleb128 0xb	/* (DW_FORM_data1) */
279	.uleb128 0x3	/* (DW_AT_name) */
280	.uleb128 0x8	/* (DW_FORM_string) */
281	.byte	0
282	.byte	0
283	.uleb128 0x5	/* (abbrev code) */
284	.uleb128 0x11	/* (TAG: DW_TAG_compile_unit) */
285	.byte	0x1	/* DW_children_yes */
286	.uleb128 0x25	/* (DW_AT_producer) */
287	.uleb128 0xe	/* (DW_FORM_strp) */
288	.uleb128 0x13	/* (DW_AT_language) */
289	.uleb128 0xb	/* (DW_FORM_data1) */
290	.uleb128 0x3	/* (DW_AT_name) */
291	.uleb128 0xe	/* (DW_FORM_strp) */
292	.uleb128 0x1b	/* (DW_AT_comp_dir) */
293	.uleb128 0xe	/* (DW_FORM_strp) */
294	.uleb128 0x11	/* (DW_AT_low_pc) */
295	.uleb128 0x1	/* (DW_FORM_addr) */
296	.uleb128 0x12	/* (DW_AT_high_pc) */
297	.uleb128 0x1	/* (DW_FORM_addr) */
298	.uleb128 0x10	/* (DW_AT_stmt_list) */
299	.uleb128 0x17	/* (DW_FORM_sec_offset) */
300	.byte	0
301	.byte	0
302	.uleb128 0x6	/* (abbrev code) */
303	.uleb128 0x2e	/* (TAG: DW_TAG_subprogram) */
304	.byte	0	/* DW_children_no */
305	.uleb128 0x3f	/* (DW_AT_external) */
306	.uleb128 0x19	/* (DW_FORM_flag_present) */
307	.uleb128 0x3	/* (DW_AT_name) */
308	.uleb128 0xe	/* (DW_FORM_strp) */
309	.uleb128 0x3a	/* (DW_AT_decl_file) */
310	.uleb128 0xb	/* (DW_FORM_data1) */
311	.uleb128 0x3b	/* (DW_AT_decl_line) */
312	.uleb128 0xb	/* (DW_FORM_data1) */
313	.uleb128 0x49	/* (DW_AT_type) */
314	.uleb128 0x13	/* (DW_FORM_ref4) */
315	.uleb128 0x11	/* (DW_AT_low_pc) */
316	.uleb128 0x1	/* (DW_FORM_addr) */
317	.uleb128 0x12	/* (DW_AT_high_pc) */
318	.uleb128 0x1	/* (DW_FORM_addr) */
319	.uleb128 0x40	/* (DW_AT_frame_base) */
320	.uleb128 0x18	/* (DW_FORM_exprloc) */
321	.uleb128 0x2117	/* (DW_AT_GNU_all_call_sites) */
322	.uleb128 0x19	/* (DW_FORM_flag_present) */
323	.byte	0
324	.byte	0
325	.uleb128 0x7	/* (abbrev code) */
326	.uleb128 0x34	/* (TAG: DW_TAG_variable) */
327	.byte	0	/* DW_children_no */
328	.uleb128 0x3	/* (DW_AT_name) */
329	.uleb128 0x8	/* (DW_FORM_string) */
330	.uleb128 0x3a	/* (DW_AT_decl_file) */
331	.uleb128 0xb	/* (DW_FORM_data1) */
332	.uleb128 0x3b	/* (DW_AT_decl_line) */
333	.uleb128 0xb	/* (DW_FORM_data1) */
334	.uleb128 0x49	/* (DW_AT_type) */
335	.uleb128 0x20	/* (DW_FORM_ref_sig8) */
336	.uleb128 0x3f	/* (DW_AT_external) */
337	.uleb128 0x19	/* (DW_FORM_flag_present) */
338	.uleb128 0x2	/* (DW_AT_location) */
339	.uleb128 0x18	/* (DW_FORM_exprloc) */
340	.byte	0
341	.byte	0
342
343	/* Manually inserted.  */
344	.uleb128 0x8		/* abbrev code */
345	.uleb128 0x2		/* DW_TAG_class_type */
346	.byte	0x0		/* DW_has_children_no */
347	.uleb128 0x47		/* DW_AT_specification */
348	.uleb128 0x13		/* DW_FORM_ref4 */
349	.byte	0x0		/* Terminator */
350	.byte	0x0		/* Terminator */
351	/* End of manual insertion.  */
352
353	.byte	0
354
355	.section	.debug_aranges,"",%progbits
356	.4byte	0x1c	/* Length of Address Ranges Info */
357	.2byte	0x2	/* DWARF Version */
358	.4byte	.Ldebug_info0	/* Offset of Compilation Unit Info */
359	.byte	0x4	/* Size of Address */
360	.byte	0	/* Size of Segment Descriptor */
361	.2byte	0	/* Pad to 8 byte boundary */
362	.2byte	0
363	.4byte	.Ltext0	/* Address */
364	.4byte	.Letext0-.Ltext0	/* Length */
365	.4byte	0
366	.4byte	0
367
368	.section	.debug_line,"",%progbits
369.Ldebug_line0:
370
371	.section	.debug_str,"MS",%progbits,1
372.LASF0:
373	.string	"GNU C++ 4.6.3 20120306"
374.LASF2:
375	.string	"."
376.LASF1:
377	.string	"pr13961.cc"
378.LASF3:
379	.string	"main"
380
381#ifdef __arm__
382	.section	.note.GNU-stack,"",%progbits
383#else
384	.section	.note.GNU-stack,"",@progbits
385#endif
386