tst.tailcall.ksh revision 211545
11556Srgrimes#
21556Srgrimes# CDDL HEADER START
31556Srgrimes#
41556Srgrimes# The contents of this file are subject to the terms of the
51556Srgrimes# Common Development and Distribution License (the "License").
61556Srgrimes# You may not use this file except in compliance with the License.
71556Srgrimes#
81556Srgrimes# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
91556Srgrimes# or http://www.opensolaris.org/os/licensing.
101556Srgrimes# See the License for the specific language governing permissions
111556Srgrimes# and limitations under the License.
121556Srgrimes#
131556Srgrimes# When distributing Covered Code, include this CDDL HEADER in each
141556Srgrimes# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
151556Srgrimes# If applicable, add the following below this CDDL HEADER, with the
161556Srgrimes# fields enclosed by brackets "[]" replaced with your own identifying
171556Srgrimes# information: Portions Copyright [yyyy] [name of copyright owner]
181556Srgrimes#
191556Srgrimes# CDDL HEADER END
201556Srgrimes#
211556Srgrimes
221556Srgrimes#
231556Srgrimes# Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
241556Srgrimes# Use is subject to license terms.
251556Srgrimes#
261556Srgrimes# ident	"%Z%%M%	%I%	%E% SMI"
271556Srgrimes
281556Srgrimes#
291556Srgrimes# ASSERTION: Make sure USDT probes work as tail-calls on SPARC.
301556Srgrimes#
311556Srgrimes
321556Srgrimesif [ $# != 1 ]; then
331556Srgrimes	echo expected one argument: '<'dtrace-path'>'
341556Srgrimes	exit 2
351556Srgrimesfi
361556Srgrimes
371556Srgrimesdtrace=$1
3836150ScharnierDIR=/var/tmp/dtest.$$
3936150Scharnier
4036150Scharniermkdir $DIR
411556Srgrimescd $DIR
4299110Sobrien
4399110Sobriencat > test.s <<EOF
441556Srgrimes#include <sys/asm_linkage.h>
4517987Speter
4617987Speter	DGDEF(__fsr_init_value)
4717987Speter	.word 0
4817987Speter
4917987Speter	ENTRY(test)
5017987Speter	save	%sp, -SA(MINFRAME + 4), %sp
5117987Speter	mov	9, %i0
5217987Speter	mov	19, %i1
5317987Speter	mov	2006, %i2
5417987Speter	call	__dtrace_test___fire
5569793Sobrien	restore
5617987Speter	SET_SIZE(test)
5718018Speter
5817987Speter	ENTRY(main)
591556Srgrimes	save	%sp, -SA(MINFRAME + 4), %sp
601556Srgrimes
6125222Ssteve1:
621556Srgrimes	call	test
6317987Speter	nop
6417987Speter
6517987Speter	ba	1b
661556Srgrimes	nop
671556Srgrimes
6817987Speter	ret
6917987Speter	restore	%g0, %g0, %o0
701556Srgrimes	SET_SIZE(main)
711556SrgrimesEOF
721556Srgrimes
731556Srgrimescat > prov.d <<EOF
741556Srgrimesprovider test {
751556Srgrimes	probe fire(int, int, int);
761556Srgrimes};
771556SrgrimesEOF
781556Srgrimes
791556Srgrimes/usr/bin/as -xregsym=no -P -D_ASM -o test.o test.s
801556Srgrimesif [ $? -ne 0 ]; then
811556Srgrimes	print -u2 "failed to compile test.s"
821556Srgrimes	exit 1
831556Srgrimesfi
841556Srgrimes
851556Srgrimes$dtrace -G -32 -s prov.d test.o
8628346Ssteveif [ $? -ne 0 ]; then
871556Srgrimes	print -u2 "failed to create DOF"
8897659Stjr	exit 1
891556Srgrimesfi
901556Srgrimes
9138536Scracauercc -o test test.o prov.o
9238950Scracauerif [ $? -ne 0 ]; then
9338536Scracauer	print -u2 "failed to link final executable"
941556Srgrimes	exit 1
9520425Sstevefi
9690111Simp
9720425Ssteve$dtrace -c ./test -s /dev/stdin <<EOF
9890111Simptest\$target:::fire
9990111Simp/arg0 == 9 && arg1 == 19 && arg2 == 2006/
10090111Simp{
10120425Ssteve	printf("%d/%d/%d", arg0, arg1, arg2);
10290111Simp	exit(0);
10320425Ssteve}
10490111Simp
10590111Simptest\$target:::fire
10690111Simp{
10797659Stjr	printf("%d/%d/%d", arg0, arg1, arg2);
10897659Stjr	exit(1);
10997659Stjr}
11097659Stjr
11197659StjrBEGIN
11297822Stjr{
1131556Srgrimes	/*
1141556Srgrimes	 * Let's just do this for 5 seconds.
1151556Srgrimes	 */
1161556Srgrimes	timeout = timestamp + 5000000000;
1171556Srgrimes}
1181556Srgrimes
1191556Srgrimesprofile:::tick-4
1201556Srgrimes/timestamp > timeout/
1211556Srgrimes{
1221556Srgrimes	trace("test timed out");
1231556Srgrimes	exit(1);
1241556Srgrimes}
12520425SsteveEOF
1261556Srgrimes
12790111Simpstatus=$?
12817987Speter
1291556Srgrimescd /
1301556Srgrimes/bin/rm -rf $DIR
1311556Srgrimes
1321556Srgrimesexit $status
1331556Srgrimes