9512fe850e98fdd448c638ca63fdd92a8a510255ahl#
9512fe850e98fdd448c638ca63fdd92a8a510255ahl# CDDL HEADER START
9512fe850e98fdd448c638ca63fdd92a8a510255ahl#
9512fe850e98fdd448c638ca63fdd92a8a510255ahl# The contents of this file are subject to the terms of the
9512fe850e98fdd448c638ca63fdd92a8a510255ahl# Common Development and Distribution License (the "License").
9512fe850e98fdd448c638ca63fdd92a8a510255ahl# You may not use this file except in compliance with the License.
9512fe850e98fdd448c638ca63fdd92a8a510255ahl#
9512fe850e98fdd448c638ca63fdd92a8a510255ahl# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9512fe850e98fdd448c638ca63fdd92a8a510255ahl# or http://www.opensolaris.org/os/licensing.
9512fe850e98fdd448c638ca63fdd92a8a510255ahl# See the License for the specific language governing permissions
9512fe850e98fdd448c638ca63fdd92a8a510255ahl# and limitations under the License.
9512fe850e98fdd448c638ca63fdd92a8a510255ahl#
9512fe850e98fdd448c638ca63fdd92a8a510255ahl# When distributing Covered Code, include this CDDL HEADER in each
9512fe850e98fdd448c638ca63fdd92a8a510255ahl# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
9512fe850e98fdd448c638ca63fdd92a8a510255ahl# If applicable, add the following below this CDDL HEADER, with the
9512fe850e98fdd448c638ca63fdd92a8a510255ahl# fields enclosed by brackets "[]" replaced with your own identifying
9512fe850e98fdd448c638ca63fdd92a8a510255ahl# information: Portions Copyright [yyyy] [name of copyright owner]
9512fe850e98fdd448c638ca63fdd92a8a510255ahl#
9512fe850e98fdd448c638ca63fdd92a8a510255ahl# CDDL HEADER END
9512fe850e98fdd448c638ca63fdd92a8a510255ahl#
9512fe850e98fdd448c638ca63fdd92a8a510255ahl
9512fe850e98fdd448c638ca63fdd92a8a510255ahl#
9512fe850e98fdd448c638ca63fdd92a8a510255ahl# Copyright 2006 Sun Microsystems, Inc. All rights reserved.
9512fe850e98fdd448c638ca63fdd92a8a510255ahl# Use is subject to license terms.
9512fe850e98fdd448c638ca63fdd92a8a510255ahl#
9512fe850e98fdd448c638ca63fdd92a8a510255ahl#ident "%Z%%M% %I% %E% SMI"
9512fe850e98fdd448c638ca63fdd92a8a510255ahl
23b5c241225a8ade2b6b9f06ebb891ee459e3b02tomeeif [ $# != 1 ]; then
23b5c241225a8ade2b6b9f06ebb891ee459e3b02tomee echo expected one argument: '<'dtrace-path'>'
23b5c241225a8ade2b6b9f06ebb891ee459e3b02tomee exit 2
23b5c241225a8ade2b6b9f06ebb891ee459e3b02tomeefi
23b5c241225a8ade2b6b9f06ebb891ee459e3b02tomee
9512fe850e98fdd448c638ca63fdd92a8a510255ahlfile=out.$$
23b5c241225a8ade2b6b9f06ebb891ee459e3b02tomeedtrace=$1
9512fe850e98fdd448c638ca63fdd92a8a510255ahl
9512fe850e98fdd448c638ca63fdd92a8a510255ahlrm -f $file
9512fe850e98fdd448c638ca63fdd92a8a510255ahl
9512fe850e98fdd448c638ca63fdd92a8a510255ahl$dtrace -o $file -c date -s /dev/stdin <<EOF
9512fe850e98fdd448c638ca63fdd92a8a510255ahl
9512fe850e98fdd448c638ca63fdd92a8a510255ahl #pragma D option quiet
9512fe850e98fdd448c638ca63fdd92a8a510255ahl #pragma D option bufsize=1M
9512fe850e98fdd448c638ca63fdd92a8a510255ahl #pragma D option bufpolicy=fill
9512fe850e98fdd448c638ca63fdd92a8a510255ahl
9512fe850e98fdd448c638ca63fdd92a8a510255ahl pid\$target:::entry,
9512fe850e98fdd448c638ca63fdd92a8a510255ahl pid\$target:::return,
9512fe850e98fdd448c638ca63fdd92a8a510255ahl pid\$target:a.out::,
9512fe850e98fdd448c638ca63fdd92a8a510255ahl syscall:::return,
9512fe850e98fdd448c638ca63fdd92a8a510255ahl profile:::profile-997
9512fe850e98fdd448c638ca63fdd92a8a510255ahl /pid == \$target/
9512fe850e98fdd448c638ca63fdd92a8a510255ahl {
9512fe850e98fdd448c638ca63fdd92a8a510255ahl printf("START %s:%s:%s:%s\n",
9512fe850e98fdd448c638ca63fdd92a8a510255ahl probeprov, probemod, probefunc, probename);
9512fe850e98fdd448c638ca63fdd92a8a510255ahl trace(ustackdepth);
9512fe850e98fdd448c638ca63fdd92a8a510255ahl ustack(100);
9512fe850e98fdd448c638ca63fdd92a8a510255ahl trace("END\n");
9512fe850e98fdd448c638ca63fdd92a8a510255ahl }
9512fe850e98fdd448c638ca63fdd92a8a510255ahl
9512fe850e98fdd448c638ca63fdd92a8a510255ahl tick-1sec
9512fe850e98fdd448c638ca63fdd92a8a510255ahl /n++ == 10/
9512fe850e98fdd448c638ca63fdd92a8a510255ahl {
9512fe850e98fdd448c638ca63fdd92a8a510255ahl trace("test timed out...");
9512fe850e98fdd448c638ca63fdd92a8a510255ahl exit(1);
9512fe850e98fdd448c638ca63fdd92a8a510255ahl }
9512fe850e98fdd448c638ca63fdd92a8a510255ahlEOF
9512fe850e98fdd448c638ca63fdd92a8a510255ahl
9512fe850e98fdd448c638ca63fdd92a8a510255ahlstatus=$?
9512fe850e98fdd448c638ca63fdd92a8a510255ahlif [ "$status" -ne 0 ]; then
9512fe850e98fdd448c638ca63fdd92a8a510255ahl echo $tst: dtrace failed
9512fe850e98fdd448c638ca63fdd92a8a510255ahl exit $status
9512fe850e98fdd448c638ca63fdd92a8a510255ahlfi
9512fe850e98fdd448c638ca63fdd92a8a510255ahl
9512fe850e98fdd448c638ca63fdd92a8a510255ahlperl /dev/stdin $file <<EOF
9512fe850e98fdd448c638ca63fdd92a8a510255ahl while (<>) {
9512fe850e98fdd448c638ca63fdd92a8a510255ahl chomp;
9512fe850e98fdd448c638ca63fdd92a8a510255ahl
9512fe850e98fdd448c638ca63fdd92a8a510255ahl last if /^\$/;
9512fe850e98fdd448c638ca63fdd92a8a510255ahl
9512fe850e98fdd448c638ca63fdd92a8a510255ahl die "expected START at \$.\n" unless /^START/;
9512fe850e98fdd448c638ca63fdd92a8a510255ahl
9512fe850e98fdd448c638ca63fdd92a8a510255ahl \$_ = <>;
9512fe850e98fdd448c638ca63fdd92a8a510255ahl chomp;
9512fe850e98fdd448c638ca63fdd92a8a510255ahl die "expected depth (\$_) at \$.\n" unless /^(\d+)\$/;
9512fe850e98fdd448c638ca63fdd92a8a510255ahl \$depth = \$1;
9512fe850e98fdd448c638ca63fdd92a8a510255ahl
9512fe850e98fdd448c638ca63fdd92a8a510255ahl for (\$i = 0; \$i < \$depth; \$i++) {
9512fe850e98fdd448c638ca63fdd92a8a510255ahl \$_ = <>;
9512fe850e98fdd448c638ca63fdd92a8a510255ahl chomp;
9512fe850e98fdd448c638ca63fdd92a8a510255ahl die "unexpected END at \$.\n" if /^END/;
9512fe850e98fdd448c638ca63fdd92a8a510255ahl }
9512fe850e98fdd448c638ca63fdd92a8a510255ahl
9512fe850e98fdd448c638ca63fdd92a8a510255ahl \$_ = <>;
9512fe850e98fdd448c638ca63fdd92a8a510255ahl chomp;
9512fe850e98fdd448c638ca63fdd92a8a510255ahl die "expected END at \$.\n" unless /^END\$/;
9512fe850e98fdd448c638ca63fdd92a8a510255ahl }
9512fe850e98fdd448c638ca63fdd92a8a510255ahlEOF
9512fe850e98fdd448c638ca63fdd92a8a510255ahl
9512fe850e98fdd448c638ca63fdd92a8a510255ahlstatus=$?
9512fe850e98fdd448c638ca63fdd92a8a510255ahl
9512fe850e98fdd448c638ca63fdd92a8a510255ahlcount=`wc -l $file | cut -f1 -do`
9512fe850e98fdd448c638ca63fdd92a8a510255ahlif [ "$count" -lt 1000 ]; then
9512fe850e98fdd448c638ca63fdd92a8a510255ahl echo $tst: output was too short
9512fe850e98fdd448c638ca63fdd92a8a510255ahl status=1
9512fe850e98fdd448c638ca63fdd92a8a510255ahlfi
9512fe850e98fdd448c638ca63fdd92a8a510255ahl
9512fe850e98fdd448c638ca63fdd92a8a510255ahl
9512fe850e98fdd448c638ca63fdd92a8a510255ahlif [ "$status" -eq 0 ]; then
9512fe850e98fdd448c638ca63fdd92a8a510255ahl rm -f $file
9512fe850e98fdd448c638ca63fdd92a8a510255ahlfi
9512fe850e98fdd448c638ca63fdd92a8a510255ahl
9512fe850e98fdd448c638ca63fdd92a8a510255ahlexit $status