tst.tailcall.ksh revision 178477
15331SN/A#
25331SN/A# CDDL HEADER START
35331SN/A#
45331SN/A# The contents of this file are subject to the terms of the
55331SN/A# Common Development and Distribution License (the "License").
65331SN/A# You may not use this file except in compliance with the License.
75331SN/A#
85331SN/A# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
95331SN/A# or http://www.opensolaris.org/os/licensing.
105331SN/A# See the License for the specific language governing permissions
115331SN/A# and limitations under the License.
125331SN/A#
135331SN/A# When distributing Covered Code, include this CDDL HEADER in each
145331SN/A# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
155331SN/A# If applicable, add the following below this CDDL HEADER, with the
165331SN/A# fields enclosed by brackets "[]" replaced with your own identifying
175331SN/A# information: Portions Copyright [yyyy] [name of copyright owner]
185331SN/A#
195331SN/A# CDDL HEADER END
205331SN/A#
2112508Samw@Sun.COM
225331SN/A#
2312508Samw@Sun.COM# Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
245331SN/A# Use is subject to license terms.
255331SN/A#
265331SN/A# ident	"%Z%%M%	%I%	%E% SMI"
275331SN/A
285331SN/A#
295331SN/A# ASSERTION: Make sure USDT probes work as tail-calls on SPARC.
305331SN/A#
3112508Samw@Sun.COM
325331SN/Aif [ $# != 1 ]; then
3312508Samw@Sun.COM	echo expected one argument: '<'dtrace-path'>'
3412508Samw@Sun.COM	exit 2
3512508Samw@Sun.COMfi
3612508Samw@Sun.COM
3712508Samw@Sun.COMdtrace=$1
3812508Samw@Sun.COMDIR=/var/tmp/dtest.$$
395331SN/A
4012508Samw@Sun.COMmkdir $DIR
4112508Samw@Sun.COMcd $DIR
4212508Samw@Sun.COM
4312508Samw@Sun.COMcat > test.s <<EOF
4412508Samw@Sun.COM#include <sys/asm_linkage.h>
4512508Samw@Sun.COM
4612508Samw@Sun.COM	DGDEF(__fsr_init_value)
4712508Samw@Sun.COM	.word 0
485331SN/A
4912508Samw@Sun.COM	ENTRY(test)
5012508Samw@Sun.COM	save	%sp, -SA(MINFRAME + 4), %sp
5112508Samw@Sun.COM	mov	9, %i0
5212508Samw@Sun.COM	mov	19, %i1
5312508Samw@Sun.COM	mov	2006, %i2
5412508Samw@Sun.COM	call	__dtrace_test___fire
555331SN/A	restore
565331SN/A	SET_SIZE(test)
575331SN/A
585331SN/A	ENTRY(main)
595331SN/A	save	%sp, -SA(MINFRAME + 4), %sp
605331SN/A
615331SN/A1:
625331SN/A	call	test
635331SN/A	nop
6412508Samw@Sun.COM
6512508Samw@Sun.COM	ba	1b
665331SN/A	nop
675331SN/A
6812508Samw@Sun.COM	ret
6912508Samw@Sun.COM	restore	%g0, %g0, %o0
705331SN/A	SET_SIZE(main)
7112508Samw@Sun.COMEOF
7212508Samw@Sun.COM
7312508Samw@Sun.COMcat > prov.d <<EOF
7412508Samw@Sun.COMprovider test {
755331SN/A	probe fire(int, int, int);
7612508Samw@Sun.COM};
7712508Samw@Sun.COMEOF
7812508Samw@Sun.COM
7912508Samw@Sun.COM/usr/ccs/bin/as -xregsym=no -P -D_ASM -o test.o test.s
8012508Samw@Sun.COMif [ $? -ne 0 ]; then
815331SN/A	print -u2 "failed to compile test.s"
82	exit 1
83fi
84
85$dtrace -G -32 -s prov.d test.o
86if [ $? -ne 0 ]; then
87	print -u2 "failed to create DOF"
88	exit 1
89fi
90
91cc -o test test.o prov.o
92if [ $? -ne 0 ]; then
93	print -u2 "failed to link final executable"
94	exit 1
95fi
96
97$dtrace -c ./test -s /dev/stdin <<EOF
98test\$target:::fire
99/arg0 == 9 && arg1 == 19 && arg2 == 2006/
100{
101	printf("%d/%d/%d", arg0, arg1, arg2);
102	exit(0);
103}
104
105test\$target:::fire
106{
107	printf("%d/%d/%d", arg0, arg1, arg2);
108	exit(1);
109}
110
111BEGIN
112{
113	/*
114	 * Let's just do this for 5 seconds.
115	 */
116	timeout = timestamp + 5000000000;
117}
118
119profile:::tick-4
120/timestamp > timeout/
121{
122	trace("test timed out");
123	exit(1);
124}
125EOF
126
127status=$?
128
129cd /
130/usr/bin/rm -rf $DIR
131
132exit $status
133