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 <sys/wait.h> 552633Sahl#include <unistd.h> 562633Sahl#include "prov.h" 572633Sahl 582633Sahlint 592633Sahlmain(int argc, char **argv) 602633Sahl{ 612633Sahl TEST_PROV_GO(); 622633Sahl if (fork() == 0) { 632633Sahl TEST_PROV_GO(); 642633Sahl return (0); 652633Sahl } 662633Sahl 672633Sahl (void) wait(NULL); 682633Sahl TEST_PROV_GO(); 692633Sahl 702633Sahl return (0); 712633Sahl} 722633SahlEOF 732633Sahl 742633Sahlcc -c test.c 752633Sahlif [ $? -ne 0 ]; then 762633Sahl print -u2 "failed to compile test.c" 772633Sahl exit 1 782633Sahlfi 79*2804Stomee$dtrace -G -32 -s prov.d test.o 802633Sahlif [ $? -ne 0 ]; then 812633Sahl print -u2 "failed to create DOF" 822633Sahl exit 1 832633Sahlfi 842633Sahlcc -o test test.o prov.o 852633Sahlif [ $? -ne 0 ]; then 862633Sahl print -u2 "failed to link final executable" 872633Sahl exit 1 882633Sahlfi 892633Sahl 902633Sahlscript() { 91*2804Stomee $dtrace -c ./test -Zqs /dev/stdin <<EOF 922633Sahl test_prov*::: 932633Sahl { 942633Sahl printf("%s:%s:%s\n", probemod, probefunc, probename); 952633Sahl } 962633SahlEOF 972633Sahl} 982633Sahl 992633Sahlscript 1002633Sahlstatus=$? 1012633Sahl 1022633Sahlcd / 1032633Sahl/usr/bin/rm -rf $DIR 1042633Sahl 1052633Sahlexit $status 106