14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync#
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync# CDDL HEADER START
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync#
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync# The contents of this file are subject to the terms of the
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync# Common Development and Distribution License (the "License").
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync# You may not use this file except in compliance with the License.
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync#
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync# or http://www.opensolaris.org/os/licensing.
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync# See the License for the specific language governing permissions
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync# and limitations under the License.
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync#
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync# When distributing Covered Code, include this CDDL HEADER in each
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync# If applicable, add the following below this CDDL HEADER, with the
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync# fields enclosed by brackets "[]" replaced with your own identifying
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync# information: Portions Copyright [yyyy] [name of copyright owner]
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync#
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync# CDDL HEADER END
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync#
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync#
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync# Use is subject to license terms.
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync#
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync# ident "%Z%%M% %I% %E% SMI"
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync#
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync# Make sure temporary symbols generated due to DTrace probes in static
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync# functions are removed in the final link step.
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync#
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncif [ $# != 1 ]; then
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync echo expected one argument: '<'dtrace-path'>'
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync exit 2
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncfi
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncdtrace=$1
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncDIR=/var/tmp/dtest.$$
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncmkdir $DIR
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsynccd $DIR
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsynccat > prov.d <<EOF
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncprovider test_prov {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync probe go();
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync};
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncEOF
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync$dtrace -h -s prov.d
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncif [ $? -ne 0 ]; then
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync print -u2 "failed to generate header file"
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync exit 1
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncfi
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsynccat > test.c <<EOF
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync#include <sys/types.h>
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync#include "prov.h"
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncstatic void
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncfoo(void)
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync{
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync TEST_PROV_GO();
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync}
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncint
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncmain(int argc, char **argv)
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync{
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync foo();
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync return (0);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync}
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncEOF
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsynccc -c test.c
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncif [ $? -ne 0 ]; then
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync print -u2 "failed to compile test.c"
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync exit 1
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncfi
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync$dtrace -G -32 -s prov.d test.o
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncif [ $? -ne 0 ]; then
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync print -u2 "failed to create DOF"
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync exit 1
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncfi
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsynccc -o test test.o prov.o
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncif [ $? -ne 0 ]; then
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync print -u2 "failed to link final executable"
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync exit 1
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncfi
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncnm test.o | grep \$dtrace > /dev/null
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncif [ $? -ne 0 ]; then
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync print -u2 "no temporary symbols in the object file"
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync exit 1
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncfi
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncnm test | grep \$dtrace > /dev/null
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncif [ $? -eq 0 ]; then
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync print -u2 "failed to eliminate temporary symbols"
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync exit 1
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncfi
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsynccd /
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync/usr/bin/rm -rf $DIR
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncexit 0