1210753Srpaulo#
2210753Srpaulo# CDDL HEADER START
3210753Srpaulo#
4210753Srpaulo# The contents of this file are subject to the terms of the
5210753Srpaulo# Common Development and Distribution License (the "License").
6210753Srpaulo# You may not use this file except in compliance with the License.
7210753Srpaulo#
8210753Srpaulo# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9210753Srpaulo# or http://www.opensolaris.org/os/licensing.
10210753Srpaulo# See the License for the specific language governing permissions
11210753Srpaulo# and limitations under the License.
12210753Srpaulo#
13210753Srpaulo# When distributing Covered Code, include this CDDL HEADER in each
14210753Srpaulo# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15210753Srpaulo# If applicable, add the following below this CDDL HEADER, with the
16210753Srpaulo# fields enclosed by brackets "[]" replaced with your own identifying
17210753Srpaulo# information: Portions Copyright [yyyy] [name of copyright owner]
18210753Srpaulo#
19210753Srpaulo# CDDL HEADER END
20210753Srpaulo#
21210753Srpaulo
22210753Srpaulo#
23210753Srpaulo# Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
24210753Srpaulo# Use is subject to license terms.
25210753Srpaulo#
26210753Srpaulo
27210753Srpauloif [ $# != 1 ]; then
28210753Srpaulo	echo expected one argument: '<'dtrace-path'>'
29210753Srpaulo	exit 2
30210753Srpaulofi
31210753Srpaulo
32210753Srpaulodtrace=$1
33210753SrpauloDIR=/var/tmp/dtest.$$
34210753Srpaulo
35210753Srpaulomkdir $DIR
36210753Srpaulocd $DIR
37210753Srpaulo
38210753Srpaulocat > test.c <<EOF
39210753Srpaulovoid
40210753Srpaulothequickbrownfoxjumpsoverthelazydogthequickbrownfoxjumpsoverthelazydogthequickbrownfoxjumpsoverthelazydogthequickbrownfoxjumpsoverthelazydogthequickbrownfoxjumpsoverthelazydogthequickbrownfoxjumpsoverthelazydogthequickbrownfoxjumpsoverthelazydogthequickbrownfoxjumpsoverthelazydogthequickbrownfoxjumpsoverthelazydog(void)
41210753Srpaulo{
42210753Srpaulo	while (1)
43210753Srpaulo		;
44210753Srpaulo}
45210753Srpaulo
46210753Srpauloint
47210753Srpaulomain(int argc, char *argv[])
48210753Srpaulo{
49210753Srpaulo	thequickbrownfoxjumpsoverthelazydogthequickbrownfoxjumpsoverthelazydogthequickbrownfoxjumpsoverthelazydogthequickbrownfoxjumpsoverthelazydogthequickbrownfoxjumpsoverthelazydogthequickbrownfoxjumpsoverthelazydogthequickbrownfoxjumpsoverthelazydogthequickbrownfoxjumpsoverthelazydogthequickbrownfoxjumpsoverthelazydog();
50210753Srpaulo}
51210753SrpauloEOF
52210753Srpaulo
53210753Srpaulocc -o test test.c
54210753Srpauloif [ $? -ne 0 ]; then
55210753Srpaulo	print -u2 "failed to compile test.c"
56210753Srpaulo	exit 1
57210753Srpaulofi
58210753Srpaulo
59210753Srpauloscript()
60210753Srpaulo{
61210753Srpaulo	$dtrace -c ./test -qs /dev/stdin <<EOF
62210753Srpaulo	profile:::profile-1001hz
63210753Srpaulo	/pid == \$target/
64210753Srpaulo	{
65210753Srpaulo		@[arg1] = count();
66210753Srpaulo	}
67210753Srpaulo
68210753Srpaulo	tick-1s
69210753Srpaulo	/n++ > 10/
70210753Srpaulo	{
71210753Srpaulo		printa("%A %@d\n", @);
72210753Srpaulo		exit(0);
73210753Srpaulo	}
74210753SrpauloEOF
75210753Srpaulo}
76210753Srpaulo
77210753Srpauloscript
78210753Srpaulostatus=$?
79210753Srpaulo
80210753Srpaulocd /
81211545Srpaulo/bin/rm -rf $DIR
82210753Srpaulo
83210753Srpauloexit $status
84