tst.tailcall.ksh revision 211545
19313Ssos#
29313Ssos# CDDL HEADER START
39313Ssos#
49313Ssos# The contents of this file are subject to the terms of the
59313Ssos# Common Development and Distribution License (the "License").
69313Ssos# You may not use this file except in compliance with the License.
79313Ssos#
89313Ssos# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
99313Ssos# or http://www.opensolaris.org/os/licensing.
109313Ssos# See the License for the specific language governing permissions
119313Ssos# and limitations under the License.
129313Ssos#
139313Ssos# When distributing Covered Code, include this CDDL HEADER in each
149313Ssos# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
1597748Sschweikh# If applicable, add the following below this CDDL HEADER, with the
169313Ssos# fields enclosed by brackets "[]" replaced with your own identifying
179313Ssos# information: Portions Copyright [yyyy] [name of copyright owner]
189313Ssos#
199313Ssos# CDDL HEADER END
209313Ssos#
219313Ssos
229313Ssos#
239313Ssos# Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
249313Ssos# Use is subject to license terms.
259313Ssos#
269313Ssos# ident	"%Z%%M%	%I%	%E% SMI"
279313Ssos
289313Ssos#
29116173Sobrien# ASSERTION: Make sure USDT probes work as tail-calls on SPARC.
30141829Snjl#
31116173Sobrien
329313Ssosif [ $# != 1 ]; then
339313Ssos	echo expected one argument: '<'dtrace-path'>'
3476166Smarkm	exit 2
3576166Smarkmfi
36161461Snetchild
379313Ssosdtrace=$1
389313SsosDIR=/var/tmp/dtest.$$
39102814Siedowse
4076166Smarkmmkdir $DIR
419313Ssoscd $DIR
42184058Skib
43184058Skibcat > test.s <<EOF
44156874Sru#include <sys/asm_linkage.h>
45156874Sru
46140214Sobrien	DGDEF(__fsr_init_value)
47140214Sobrien	.word 0
48140214Sobrien
49140214Sobrien	ENTRY(test)
5064911Smarcel	save	%sp, -SA(MINFRAME + 4), %sp
5168583Smarcel	mov	9, %i0
52133816Stjr	mov	19, %i1
5364911Smarcel	mov	2006, %i2
5464911Smarcel	call	__dtrace_test___fire
55161310Snetchild	restore
569313Ssos	SET_SIZE(test)
5764911Smarcel
5883221Smarcel	ENTRY(main)
5951793Smarcel	save	%sp, -SA(MINFRAME + 4), %sp
6051793Smarcel
619313Ssos1:
6251793Smarcel	call	test
6351793Smarcel	nop
6451793Smarcel
6551793Smarcel	ba	1b
6651793Smarcel	nop
6751793Smarcel
6851793Smarcel	ret
6951793Smarcel	restore	%g0, %g0, %o0
7051793Smarcel	SET_SIZE(main)
7114331SpeterEOF
729313Ssos
739313Ssoscat > prov.d <<EOF
7467234Sgallatinprovider test {
7583221Smarcel	probe fire(int, int, int);
7651793Smarcel};
7751793SmarcelEOF
789313Ssos
7951793Smarcel/usr/bin/as -xregsym=no -P -D_ASM -o test.o test.s
8051793Smarcelif [ $? -ne 0 ]; then
8151793Smarcel	print -u2 "failed to compile test.s"
8251793Smarcel	exit 1
8351793Smarcelfi
8451793Smarcel
8551793Smarcel$dtrace -G -32 -s prov.d test.o
8651793Smarcelif [ $? -ne 0 ]; then
8751793Smarcel	print -u2 "failed to create DOF"
8814331Speter	exit 1
899313Ssosfi
909313Ssos
9114342Spetercc -o test test.o prov.o
9283221Smarcelif [ $? -ne 0 ]; then
9314331Speter	print -u2 "failed to link final executable"
9451793Smarcel	exit 1
9551793Smarcelfi
96133816Stjr
9751793Smarcel$dtrace -c ./test -s /dev/stdin <<EOF
9851793Smarceltest\$target:::fire
9951793Smarcel/arg0 == 9 && arg1 == 19 && arg2 == 2006/
10051793Smarcel{
10151793Smarcel	printf("%d/%d/%d", arg0, arg1, arg2);
10251793Smarcel	exit(0);
10351793Smarcel}
10451793Smarcel
10551793Smarceltest\$target:::fire
10651793Smarcel{
10751793Smarcel	printf("%d/%d/%d", arg0, arg1, arg2);
10851793Smarcel	exit(1);
10951793Smarcel}
11051793Smarcel
11151793SmarcelBEGIN
11214331Speter{
1139313Ssos	/*
11414342Speter	 * Let's just do this for 5 seconds.
11583221Smarcel	 */
11614331Speter	timeout = timestamp + 5000000000;
11751793Smarcel}
11851793Smarcel
119140214Sobrienprofile:::tick-4
120133816Stjr/timestamp > timeout/
121133816Stjr{
12251793Smarcel	trace("test timed out");
123133816Stjr	exit(1);
124133816Stjr}
12551793SmarcelEOF
12651793Smarcel
12751793Smarcelstatus=$?
12851793Smarcel
12951793Smarcelcd /
13051793Smarcel/bin/rm -rf $DIR
13151793Smarcel
13251793Smarcelexit $status
13351793Smarcel