1*4565Sjhaslam#/bin/ksh -p 2*4565Sjhaslam# 3*4565Sjhaslam# CDDL HEADER START 4*4565Sjhaslam# 5*4565Sjhaslam# The contents of this file are subject to the terms of the 6*4565Sjhaslam# Common Development and Distribution License (the "License"). 7*4565Sjhaslam# You may not use this file except in compliance with the License. 8*4565Sjhaslam# 9*4565Sjhaslam# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*4565Sjhaslam# or http://www.opensolaris.org/os/licensing. 11*4565Sjhaslam# See the License for the specific language governing permissions 12*4565Sjhaslam# and limitations under the License. 13*4565Sjhaslam# 14*4565Sjhaslam# When distributing Covered Code, include this CDDL HEADER in each 15*4565Sjhaslam# file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*4565Sjhaslam# If applicable, add the following below this CDDL HEADER, with the 17*4565Sjhaslam# fields enclosed by brackets "[]" replaced with your own identifying 18*4565Sjhaslam# information: Portions Copyright [yyyy] [name of copyright owner] 19*4565Sjhaslam# 20*4565Sjhaslam# CDDL HEADER END 21*4565Sjhaslam# 22*4565Sjhaslam 23*4565Sjhaslam# 24*4565Sjhaslam# Copyright 2007 Sun Microsystems, Inc. All rights reserved. 25*4565Sjhaslam# Use is subject to license terms. 26*4565Sjhaslam# 27*4565Sjhaslam# ident "%Z%%M% %I% %E% SMI" 28*4565Sjhaslam 29*4565Sjhaslam# 30*4565Sjhaslam# This script verifies that user-land stacks can be walked safely 31*4565Sjhaslam# when the trapstat(1M) utility is running. An arbitrary program, w(1), 32*4565Sjhaslam# is started once a second to ensure stacks can be walked at all stages 33*4565Sjhaslam# of the process lifecycle. 34*4565Sjhaslam# 35*4565Sjhaslam 36*4565Sjhaslamscript() 37*4565Sjhaslam{ 38*4565Sjhaslam $dtrace -o $dtraceout -s /dev/stdin <<EOF 39*4565Sjhaslam fbt::: 40*4565Sjhaslam { 41*4565Sjhaslam @[ustackdepth] = count(); 42*4565Sjhaslam } 43*4565SjhaslamEOF 44*4565Sjhaslam} 45*4565Sjhaslam 46*4565Sjhaslamrun_commands() 47*4565Sjhaslam{ 48*4565Sjhaslam cnt=0 49*4565Sjhaslam 50*4565Sjhaslam while [ $cnt -lt 10 ]; do 51*4565Sjhaslam w > /dev/null 52*4565Sjhaslam sleep 1 53*4565Sjhaslam cnt=$(($cnt+1)) 54*4565Sjhaslam done 55*4565Sjhaslam} 56*4565Sjhaslam 57*4565Sjhaslamif [ $# != 1 ]; then 58*4565Sjhaslam echo expected one argument: '<'dtrace-path'>' 59*4565Sjhaslam exit 2 60*4565Sjhaslamfi 61*4565Sjhaslam 62*4565Sjhaslamdtrace=$1 63*4565Sjhaslamdtraceout=/tmp/dtrace.out.$$ 64*4565Sjhaslamscript 2>/dev/null & 65*4565Sjhaslamtimeout=15 66*4565Sjhaslam 67*4565Sjhaslam# 68*4565Sjhaslam# Sleep while the above script fires into life. To guard against dtrace dying 69*4565Sjhaslam# and us sleeping forever we allow 15 secs for this to happen. This should be 70*4565Sjhaslam# enough for even the slowest systems. 71*4565Sjhaslam# 72*4565Sjhaslamwhile [ ! -f $dtraceout ]; do 73*4565Sjhaslam sleep 1 74*4565Sjhaslam timeout=$(($timeout-1)) 75*4565Sjhaslam if [ $timeout -eq 0 ]; then 76*4565Sjhaslam echo "dtrace failed to start. Exiting." 77*4565Sjhaslam exit 1 78*4565Sjhaslam fi 79*4565Sjhaslamdone 80*4565Sjhaslam 81*4565Sjhaslamrun_commands & 82*4565Sjhaslamtrapstat -t 1 10 83*4565Sjhaslamstatus=$? 84*4565Sjhaslam 85*4565Sjhaslamrm $dtraceout 86*4565Sjhaslam 87*4565Sjhaslamexit $status 88