19512fe85Sahl# 29512fe85Sahl# CDDL HEADER START 39512fe85Sahl# 49512fe85Sahl# The contents of this file are subject to the terms of the 59512fe85Sahl# Common Development and Distribution License (the "License"). 69512fe85Sahl# You may not use this file except in compliance with the License. 79512fe85Sahl# 89512fe85Sahl# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 99512fe85Sahl# or http://www.opensolaris.org/os/licensing. 109512fe85Sahl# See the License for the specific language governing permissions 119512fe85Sahl# and limitations under the License. 129512fe85Sahl# 139512fe85Sahl# When distributing Covered Code, include this CDDL HEADER in each 149512fe85Sahl# file and include the License file at usr/src/OPENSOLARIS.LICENSE. 159512fe85Sahl# If applicable, add the following below this CDDL HEADER, with the 169512fe85Sahl# fields enclosed by brackets "[]" replaced with your own identifying 179512fe85Sahl# information: Portions Copyright [yyyy] [name of copyright owner] 189512fe85Sahl# 199512fe85Sahl# CDDL HEADER END 209512fe85Sahl# 219512fe85Sahl 229512fe85Sahl# 239512fe85Sahl# Copyright 2006 Sun Microsystems, Inc. All rights reserved. 249512fe85Sahl# Use is subject to license terms. 259512fe85Sahl# 269512fe85Sahl#ident "%Z%%M% %I% %E% SMI" 279512fe85Sahl 28*23b5c241Stomeeif [ $# != 1 ]; then 29*23b5c241Stomee echo expected one argument: '<'dtrace-path'>' 30*23b5c241Stomee exit 2 31*23b5c241Stomeefi 32*23b5c241Stomee 339512fe85Sahlfile=out.$$ 34*23b5c241Stomeedtrace=$1 359512fe85Sahl 369512fe85Sahlrm -f $file 379512fe85Sahl 389512fe85Sahl$dtrace -o $file -c date -s /dev/stdin <<EOF 399512fe85Sahl 409512fe85Sahl #pragma D option quiet 419512fe85Sahl #pragma D option bufsize=1M 429512fe85Sahl #pragma D option bufpolicy=fill 439512fe85Sahl 449512fe85Sahl pid\$target:::entry, 459512fe85Sahl pid\$target:::return, 469512fe85Sahl pid\$target:a.out::, 479512fe85Sahl syscall:::return, 489512fe85Sahl profile:::profile-997 499512fe85Sahl /pid == \$target/ 509512fe85Sahl { 519512fe85Sahl printf("START %s:%s:%s:%s\n", 529512fe85Sahl probeprov, probemod, probefunc, probename); 539512fe85Sahl trace(ustackdepth); 549512fe85Sahl ustack(100); 559512fe85Sahl trace("END\n"); 569512fe85Sahl } 579512fe85Sahl 589512fe85Sahl tick-1sec 599512fe85Sahl /n++ == 10/ 609512fe85Sahl { 619512fe85Sahl trace("test timed out..."); 629512fe85Sahl exit(1); 639512fe85Sahl } 649512fe85SahlEOF 659512fe85Sahl 669512fe85Sahlstatus=$? 679512fe85Sahlif [ "$status" -ne 0 ]; then 689512fe85Sahl echo $tst: dtrace failed 699512fe85Sahl exit $status 709512fe85Sahlfi 719512fe85Sahl 729512fe85Sahlperl /dev/stdin $file <<EOF 739512fe85Sahl while (<>) { 749512fe85Sahl chomp; 759512fe85Sahl 769512fe85Sahl last if /^\$/; 779512fe85Sahl 789512fe85Sahl die "expected START at \$.\n" unless /^START/; 799512fe85Sahl 809512fe85Sahl \$_ = <>; 819512fe85Sahl chomp; 829512fe85Sahl die "expected depth (\$_) at \$.\n" unless /^(\d+)\$/; 839512fe85Sahl \$depth = \$1; 849512fe85Sahl 859512fe85Sahl for (\$i = 0; \$i < \$depth; \$i++) { 869512fe85Sahl \$_ = <>; 879512fe85Sahl chomp; 889512fe85Sahl die "unexpected END at \$.\n" if /^END/; 899512fe85Sahl } 909512fe85Sahl 919512fe85Sahl \$_ = <>; 929512fe85Sahl chomp; 939512fe85Sahl die "expected END at \$.\n" unless /^END\$/; 949512fe85Sahl } 959512fe85SahlEOF 969512fe85Sahl 979512fe85Sahlstatus=$? 989512fe85Sahl 999512fe85Sahlcount=`wc -l $file | cut -f1 -do` 1009512fe85Sahlif [ "$count" -lt 1000 ]; then 1019512fe85Sahl echo $tst: output was too short 1029512fe85Sahl status=1 1039512fe85Sahlfi 1049512fe85Sahl 1059512fe85Sahl 1069512fe85Sahlif [ "$status" -eq 0 ]; then 1079512fe85Sahl rm -f $file 1089512fe85Sahlfi 1099512fe85Sahl 1109512fe85Sahlexit $status 111