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
23b5c241225a8ade2b6b9f06ebb891ee459e3b02tomeeif [ $# != 1 ]; then
23b5c241225a8ade2b6b9f06ebb891ee459e3b02tomee echo expected one argument: '<'dtrace-path'>'
23b5c241225a8ade2b6b9f06ebb891ee459e3b02tomee exit 2
23b5c241225a8ade2b6b9f06ebb891ee459e3b02tomeefi
23b5c241225a8ade2b6b9f06ebb891ee459e3b02tomee
23b5c241225a8ade2b6b9f06ebb891ee459e3b02tomeedtrace=$1
9512fe850e98fdd448c638ca63fdd92a8a510255ahlDIR=/var/tmp/dtest.$$
9512fe850e98fdd448c638ca63fdd92a8a510255ahl
9512fe850e98fdd448c638ca63fdd92a8a510255ahlmkdir $DIR
9512fe850e98fdd448c638ca63fdd92a8a510255ahlcd $DIR
9512fe850e98fdd448c638ca63fdd92a8a510255ahl
9512fe850e98fdd448c638ca63fdd92a8a510255ahlppriv -s A=basic $$
9512fe850e98fdd448c638ca63fdd92a8a510255ahl
9512fe850e98fdd448c638ca63fdd92a8a510255ahlcat > test.c <<EOF
9512fe850e98fdd448c638ca63fdd92a8a510255ahl#include <sys/sdt.h>
9512fe850e98fdd448c638ca63fdd92a8a510255ahl
9512fe850e98fdd448c638ca63fdd92a8a510255ahlint
9512fe850e98fdd448c638ca63fdd92a8a510255ahlmain(int argc, char **argv)
9512fe850e98fdd448c638ca63fdd92a8a510255ahl{
9512fe850e98fdd448c638ca63fdd92a8a510255ahl DTRACE_PROBE(test_prov, zero);
9512fe850e98fdd448c638ca63fdd92a8a510255ahl DTRACE_PROBE1(test_prov, one, 1);
9512fe850e98fdd448c638ca63fdd92a8a510255ahl DTRACE_PROBE2(test_prov, two, 2, 3);
9512fe850e98fdd448c638ca63fdd92a8a510255ahl DTRACE_PROBE3(test_prov, three, 4, 5, 7);
9512fe850e98fdd448c638ca63fdd92a8a510255ahl DTRACE_PROBE4(test_prov, four, 7, 8, 9, 10);
9512fe850e98fdd448c638ca63fdd92a8a510255ahl DTRACE_PROBE5(test_prov, five, 11, 12, 13, 14, 15);
9512fe850e98fdd448c638ca63fdd92a8a510255ahl}
9512fe850e98fdd448c638ca63fdd92a8a510255ahlEOF
9512fe850e98fdd448c638ca63fdd92a8a510255ahl
9512fe850e98fdd448c638ca63fdd92a8a510255ahlcat > prov.d <<EOF
9512fe850e98fdd448c638ca63fdd92a8a510255ahlprovider test_prov {
9512fe850e98fdd448c638ca63fdd92a8a510255ahl probe zero();
9512fe850e98fdd448c638ca63fdd92a8a510255ahl probe one(uintptr_t);
9512fe850e98fdd448c638ca63fdd92a8a510255ahl probe two(uintptr_t, uintptr_t);
9512fe850e98fdd448c638ca63fdd92a8a510255ahl probe three(uintptr_t, uintptr_t, uintptr_t);
9512fe850e98fdd448c638ca63fdd92a8a510255ahl probe four(uintptr_t, uintptr_t, uintptr_t, uintptr_t);
9512fe850e98fdd448c638ca63fdd92a8a510255ahl probe five(uintptr_t, uintptr_t, uintptr_t, uintptr_t, uintptr_t);
9512fe850e98fdd448c638ca63fdd92a8a510255ahl};
9512fe850e98fdd448c638ca63fdd92a8a510255ahlEOF
9512fe850e98fdd448c638ca63fdd92a8a510255ahl
a386cc11a86ecb60f5a48078d22c1500e2ad003eRobert Mustacchigcc -m32 -c test.c
9512fe850e98fdd448c638ca63fdd92a8a510255ahlif [ $? -ne 0 ]; then
9512fe850e98fdd448c638ca63fdd92a8a510255ahl print -u2 "failed to compile test.c"
9512fe850e98fdd448c638ca63fdd92a8a510255ahl exit 1
9512fe850e98fdd448c638ca63fdd92a8a510255ahlfi
23b5c241225a8ade2b6b9f06ebb891ee459e3b02tomee$dtrace -G -32 -s prov.d test.o
9512fe850e98fdd448c638ca63fdd92a8a510255ahlif [ $? -ne 0 ]; then
9512fe850e98fdd448c638ca63fdd92a8a510255ahl print -u2 "failed to create DOF"
9512fe850e98fdd448c638ca63fdd92a8a510255ahl exit 1
9512fe850e98fdd448c638ca63fdd92a8a510255ahlfi
a386cc11a86ecb60f5a48078d22c1500e2ad003eRobert Mustacchigcc -m32 -o test test.o prov.o
9512fe850e98fdd448c638ca63fdd92a8a510255ahlif [ $? -ne 0 ]; then
9512fe850e98fdd448c638ca63fdd92a8a510255ahl print -u2 "failed to link final executable"
9512fe850e98fdd448c638ca63fdd92a8a510255ahl exit 1
9512fe850e98fdd448c638ca63fdd92a8a510255ahlfi
9512fe850e98fdd448c638ca63fdd92a8a510255ahl
9512fe850e98fdd448c638ca63fdd92a8a510255ahlcd /
9512fe850e98fdd448c638ca63fdd92a8a510255ahl/usr/bin/rm -rf $DIR