12633Sahl#!/bin/ksh -p 22633Sahl# 32633Sahl# CDDL HEADER START 42633Sahl# 52633Sahl# The contents of this file are subject to the terms of the 62633Sahl# Common Development and Distribution License (the "License"). 72633Sahl# You may not use this file except in compliance with the License. 82633Sahl# 92633Sahl# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 102633Sahl# or http://www.opensolaris.org/os/licensing. 112633Sahl# See the License for the specific language governing permissions 122633Sahl# and limitations under the License. 132633Sahl# 142633Sahl# When distributing Covered Code, include this CDDL HEADER in each 152633Sahl# file and include the License file at usr/src/OPENSOLARIS.LICENSE. 162633Sahl# If applicable, add the following below this CDDL HEADER, with the 172633Sahl# fields enclosed by brackets "[]" replaced with your own identifying 182633Sahl# information: Portions Copyright [yyyy] [name of copyright owner] 192633Sahl# 202633Sahl# CDDL HEADER END 212633Sahl# 222633Sahl 232633Sahl# 242633Sahl# Copyright 2006 Sun Microsystems, Inc. All rights reserved. 252633Sahl# Use is subject to license terms. 262633Sahl# 272633Sahl#ident "%Z%%M% %I% %E% SMI" 282633Sahl 29*2804Stomeeif [ $# != 1 ]; then 30*2804Stomee echo expected one argument: '<'dtrace-path'>' 31*2804Stomee exit 2 32*2804Stomeefi 33*2804Stomee 34*2804Stomeedtrace=$1 352633SahlDIR=/var/tmp/dtest.$$ 362633Sahl 372633Sahlmkdir $DIR 382633Sahlcd $DIR 392633Sahl 402633Sahlcat > prov.d <<EOF 412633Sahlprovider test_prov { 422633Sahl probe go(); 432633Sahl}; 442633SahlEOF 452633Sahl 46*2804Stomee$dtrace -h -s prov.d 472633Sahlif [ $? -ne 0 ]; then 482633Sahl print -u2 "failed to generate header file" 492633Sahl exit 1 502633Sahlfi 512633Sahl 522633Sahlcat > test.c <<EOF 532633Sahl#include <sys/types.h> 542633Sahl#include "prov.h" 552633Sahl 562633Sahlint 572633Sahlmain(int argc, char **argv) 582633Sahl{ 592633Sahl TEST_PROV_GO(); 602633Sahl TEST_PROV_GO(); 612633Sahl TEST_PROV_GO(); 622633Sahl TEST_PROV_GO(); 632633Sahl 642633Sahl return (0); 652633Sahl} 662633SahlEOF 672633Sahl 682633Sahlcc -c test.c 692633Sahlif [ $? -ne 0 ]; then 702633Sahl print -u2 "failed to compile test.c" 712633Sahl exit 1 722633Sahlfi 73*2804Stomee$dtrace -G -32 -s prov.d test.o 742633Sahlif [ $? -ne 0 ]; then 752633Sahl print -u2 "failed to create DOF" 762633Sahl exit 1 772633Sahlfi 782633Sahlcc -o test test.o prov.o 792633Sahlif [ $? -ne 0 ]; then 802633Sahl print -u2 "failed to link final executable" 812633Sahl exit 1 822633Sahlfi 832633Sahl 842633Sahlscript() { 85*2804Stomee $dtrace -c ./test -qs /dev/stdin <<EOF 862633Sahl test_prov\$target::: 872633Sahl { 882633Sahl printf("%s:%s:%s\n", probemod, probefunc, probename); 892633Sahl } 902633SahlEOF 912633Sahl} 922633Sahl 932633Sahlscript 942633Sahlstatus=$? 952633Sahl 962633Sahlcd / 972633Sahl/usr/bin/rm -rf $DIR 982633Sahl 992633Sahlexit $status 100