tst.tailcall.ksh revision 285830
10Sstevel@tonic-gate# 20Sstevel@tonic-gate# CDDL HEADER START 30Sstevel@tonic-gate# 40Sstevel@tonic-gate# The contents of this file are subject to the terms of the 54321Scasper# Common Development and Distribution License (the "License"). 64321Scasper# You may not use this file except in compliance with the License. 70Sstevel@tonic-gate# 80Sstevel@tonic-gate# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 90Sstevel@tonic-gate# or http://www.opensolaris.org/os/licensing. 100Sstevel@tonic-gate# See the License for the specific language governing permissions 110Sstevel@tonic-gate# and limitations under the License. 120Sstevel@tonic-gate# 130Sstevel@tonic-gate# When distributing Covered Code, include this CDDL HEADER in each 140Sstevel@tonic-gate# file and include the License file at usr/src/OPENSOLARIS.LICENSE. 150Sstevel@tonic-gate# If applicable, add the following below this CDDL HEADER, with the 160Sstevel@tonic-gate# fields enclosed by brackets "[]" replaced with your own identifying 170Sstevel@tonic-gate# information: Portions Copyright [yyyy] [name of copyright owner] 180Sstevel@tonic-gate# 190Sstevel@tonic-gate# CDDL HEADER END 200Sstevel@tonic-gate# 210Sstevel@tonic-gate 224321Scasper# 230Sstevel@tonic-gate# Copyright 2007 Sun Microsystems, Inc. All rights reserved. 240Sstevel@tonic-gate# Use is subject to license terms. 250Sstevel@tonic-gate# 260Sstevel@tonic-gate# ident "%Z%%M% %I% %E% SMI" 270Sstevel@tonic-gate 280Sstevel@tonic-gate# 290Sstevel@tonic-gate# ASSERTION: Make sure USDT probes work as tail-calls on SPARC. 300Sstevel@tonic-gate# 310Sstevel@tonic-gate 320Sstevel@tonic-gateif [ $# != 1 ]; then 330Sstevel@tonic-gate echo expected one argument: '<'dtrace-path'>' 340Sstevel@tonic-gate exit 2 350Sstevel@tonic-gatefi 360Sstevel@tonic-gate 370Sstevel@tonic-gatedtrace=$1 380Sstevel@tonic-gateDIR=/var/tmp/dtest.$$ 390Sstevel@tonic-gate 400Sstevel@tonic-gatemkdir $DIR 410Sstevel@tonic-gatecd $DIR 420Sstevel@tonic-gate 430Sstevel@tonic-gatecat > test.s <<EOF 440Sstevel@tonic-gate#include <sys/asm_linkage.h> 450Sstevel@tonic-gate 460Sstevel@tonic-gate DGDEF(__fsr_init_value) 470Sstevel@tonic-gate .word 0 480Sstevel@tonic-gate 490Sstevel@tonic-gate ENTRY(test) 500Sstevel@tonic-gate save %sp, -SA(MINFRAME + 4), %sp 510Sstevel@tonic-gate mov 9, %i0 520Sstevel@tonic-gate mov 19, %i1 530Sstevel@tonic-gate mov 2006, %i2 540Sstevel@tonic-gate call __dtrace_test___fire 550Sstevel@tonic-gate restore 560Sstevel@tonic-gate SET_SIZE(test) 570Sstevel@tonic-gate 580Sstevel@tonic-gate ENTRY(main) 590Sstevel@tonic-gate save %sp, -SA(MINFRAME + 4), %sp 600Sstevel@tonic-gate 610Sstevel@tonic-gate1: 620Sstevel@tonic-gate call test 63108Sbasabi nop 640Sstevel@tonic-gate 650Sstevel@tonic-gate ba 1b 660Sstevel@tonic-gate nop 670Sstevel@tonic-gate 680Sstevel@tonic-gate ret 690Sstevel@tonic-gate restore %g0, %g0, %o0 700Sstevel@tonic-gate SET_SIZE(main) 710Sstevel@tonic-gateEOF 720Sstevel@tonic-gate 730Sstevel@tonic-gatecat > prov.d <<EOF 740Sstevel@tonic-gateprovider test { 750Sstevel@tonic-gate probe fire(int, int, int); 760Sstevel@tonic-gate}; 770Sstevel@tonic-gateEOF 780Sstevel@tonic-gate 790Sstevel@tonic-gate/usr/bin/as -xregsym=no -P -D_ASM -o test.o test.s 800Sstevel@tonic-gateif [ $? -ne 0 ]; then 810Sstevel@tonic-gate print -u2 "failed to compile test.s" 820Sstevel@tonic-gate exit 1 830Sstevel@tonic-gatefi 840Sstevel@tonic-gate 850Sstevel@tonic-gate$dtrace -G -32 -s prov.d test.o 860Sstevel@tonic-gateif [ $? -ne 0 ]; then 870Sstevel@tonic-gate print -u2 "failed to create DOF" 880Sstevel@tonic-gate exit 1 890Sstevel@tonic-gatefi 900Sstevel@tonic-gate 910Sstevel@tonic-gatecc -o test test.o prov.o 920Sstevel@tonic-gateif [ $? -ne 0 ]; then 930Sstevel@tonic-gate print -u2 "failed to link final executable" 940Sstevel@tonic-gate exit 1 950Sstevel@tonic-gatefi 960Sstevel@tonic-gate 970Sstevel@tonic-gate$dtrace -c ./test -s /dev/stdin <<EOF 980Sstevel@tonic-gatetest\$target:::fire 990Sstevel@tonic-gate/arg0 == 9 && arg1 == 19 && arg2 == 2006/ 1000Sstevel@tonic-gate{ 1010Sstevel@tonic-gate printf("%d/%d/%d", arg0, arg1, arg2); 1020Sstevel@tonic-gate exit(0); 1030Sstevel@tonic-gate} 1040Sstevel@tonic-gate 1050Sstevel@tonic-gatetest\$target:::fire 1060Sstevel@tonic-gate{ 1070Sstevel@tonic-gate printf("%d/%d/%d", arg0, arg1, arg2); 1080Sstevel@tonic-gate exit(1); 1090Sstevel@tonic-gate} 1100Sstevel@tonic-gate 1110Sstevel@tonic-gateBEGIN 1120Sstevel@tonic-gate{ 1130Sstevel@tonic-gate /* 1140Sstevel@tonic-gate * Let's just do this for 5 seconds. 1150Sstevel@tonic-gate */ 1160Sstevel@tonic-gate timeout = timestamp + 5000000000; 1170Sstevel@tonic-gate} 1180Sstevel@tonic-gate 1190Sstevel@tonic-gateprofile:::tick-4 1200Sstevel@tonic-gate/timestamp > timeout/ 1210Sstevel@tonic-gate{ 1220Sstevel@tonic-gate trace("test timed out"); 1230Sstevel@tonic-gate exit(1); 1240Sstevel@tonic-gate} 1250Sstevel@tonic-gateEOF 1260Sstevel@tonic-gate 1270Sstevel@tonic-gatestatus=$? 1280Sstevel@tonic-gate 1290Sstevel@tonic-gatecd / 1300Sstevel@tonic-gate/bin/rm -rf $DIR 1310Sstevel@tonic-gate 1320Sstevel@tonic-gateexit $status 1330Sstevel@tonic-gate