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
2723b5c241Stomeeif [ $# != 1 ]; then
2823b5c241Stomee	echo expected one argument: '<'dtrace-path'>'
2923b5c241Stomee	exit 2
3023b5c241Stomeefi
3123b5c241Stomee
3223b5c241Stomeedtrace=$1
339512fe85SahlDIR=/var/tmp/dtest.$$
349512fe85Sahl
359512fe85Sahlmkdir $DIR
369512fe85Sahlcd $DIR
379512fe85Sahl
389512fe85Sahlcat > test.c <<EOF
399512fe85Sahl#include <unistd.h>
409512fe85Sahl#include <sys/sdt.h>
419512fe85Sahl
429512fe85Sahlstatic void
439512fe85Sahlfoo(void)
449512fe85Sahl{
459512fe85Sahl	DTRACE_PROBE(test_prov, probe1);
469512fe85Sahl	DTRACE_PROBE(test_prov, probe2);
479512fe85Sahl}
489512fe85Sahl
499512fe85Sahlint
509512fe85Sahlmain(int argc, char **argv)
519512fe85Sahl{
529512fe85Sahl	DTRACE_PROBE(test_prov, probe1);
539512fe85Sahl	DTRACE_PROBE(test_prov, probe2);
549512fe85Sahl	foo();
559512fe85Sahl}
569512fe85SahlEOF
579512fe85Sahl
589512fe85Sahlcat > prov.d <<EOF
599512fe85Sahlprovider test_prov {
609512fe85Sahl	probe probe1();
619512fe85Sahl	probe probe2();
629512fe85Sahl};
639512fe85SahlEOF
649512fe85Sahl
65*a386cc11SRobert Mustacchigcc -m32 -c test.c
669512fe85Sahlif [ $? -ne 0 ]; then
679512fe85Sahl	print -u2 "failed to compile test.c"
689512fe85Sahl	exit 1
699512fe85Sahlfi
7023b5c241Stomee$dtrace -G -32 -s prov.d test.o
719512fe85Sahlif [ $? -ne 0 ]; then
729512fe85Sahl	print -u2 "failed to create DOF"
739512fe85Sahl	exit 1
749512fe85Sahlfi
75*a386cc11SRobert Mustacchigcc -m32 -o test test.o prov.o
769512fe85Sahlif [ $? -ne 0 ]; then
779512fe85Sahl	print -u2 "failed to link final executable"
789512fe85Sahl	exit 1
799512fe85Sahlfi
809512fe85Sahl
819512fe85Sahlscript()
829512fe85Sahl{
8323b5c241Stomee	$dtrace -c ./test -qs /dev/stdin <<EOF
849512fe85Sahl	test_prov\$target:::
859512fe85Sahl	{
869512fe85Sahl		printf("%s:%s:%s\n", probemod, probefunc, probename);
879512fe85Sahl	}
889512fe85SahlEOF
899512fe85Sahl}
909512fe85Sahl
919512fe85Sahlscript
929512fe85Sahlstatus=$?
939512fe85Sahl
949512fe85Sahlcd /
959512fe85Sahl/usr/bin/rm -rf $DIR
969512fe85Sahl
979512fe85Sahlexit $status
98