1 5984 jhaslam #!/bin/ksh -p 2 5984 jhaslam # 3 5984 jhaslam # CDDL HEADER START 4 5984 jhaslam # 5 5984 jhaslam # The contents of this file are subject to the terms of the 6 5984 jhaslam # Common Development and Distribution License (the "License"). 7 5984 jhaslam # You may not use this file except in compliance with the License. 8 5984 jhaslam # 9 5984 jhaslam # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10 5984 jhaslam # or http://www.opensolaris.org/os/licensing. 11 5984 jhaslam # See the License for the specific language governing permissions 12 5984 jhaslam # and limitations under the License. 13 5984 jhaslam # 14 5984 jhaslam # When distributing Covered Code, include this CDDL HEADER in each 15 5984 jhaslam # file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16 5984 jhaslam # If applicable, add the following below this CDDL HEADER, with the 17 5984 jhaslam # fields enclosed by brackets "[]" replaced with your own identifying 18 5984 jhaslam # information: Portions Copyright [yyyy] [name of copyright owner] 19 5984 jhaslam # 20 5984 jhaslam # CDDL HEADER END 21 5984 jhaslam # 22 5984 jhaslam 23 5984 jhaslam # 24 5984 jhaslam # Copyright 2008 Sun Microsystems, Inc. All rights reserved. 25 5984 jhaslam # Use is subject to license terms. 26 5984 jhaslam # 27 5984 jhaslam # ident "%Z%%M% %I% %E% SMI" 28 5984 jhaslam 29 5984 jhaslam # 30 5984 jhaslam # This test verifies that a regex in the provider name will match 31 5984 jhaslam # USDT probes as well as pid probes (e.g., p*d$target matches both 32 5984 jhaslam # pid$target and pyramid$target.) 33 5984 jhaslam # 34 5984 jhaslam 35 5984 jhaslam if [ $# != 1 ]; then 36 5984 jhaslam echo expected one argument: '<'dtrace-path'>' 37 5984 jhaslam exit 2 38 5984 jhaslam fi 39 5984 jhaslam 40 5984 jhaslam dtrace=$1 41 5984 jhaslam DIR=${TMPDIR:-/tmp}/dtest.$$ 42 5984 jhaslam 43 5984 jhaslam mkdir $DIR 44 5984 jhaslam cd $DIR 45 5984 jhaslam 46 5984 jhaslam cat > Makefile <<EOF 47 5984 jhaslam all: main 48 5984 jhaslam 49 5984 jhaslam main: main.o prov.o 50 5984 jhaslam cc -o main main.o prov.o 51 5984 jhaslam 52 5984 jhaslam main.o: main.c prov.h 53 5984 jhaslam cc -c main.c 54 5984 jhaslam 55 5984 jhaslam prov.h: prov.d 56 5984 jhaslam $dtrace -h -s prov.d 57 5984 jhaslam 58 5984 jhaslam prov.o: prov.d main.o 59 5984 jhaslam $dtrace -G -32 -s prov.d main.o 60 5984 jhaslam EOF 61 5984 jhaslam 62 5984 jhaslam cat > prov.d <<EOF 63 5984 jhaslam provider pyramid { 64 5984 jhaslam probe entry(); 65 5984 jhaslam }; 66 5984 jhaslam EOF 67 5984 jhaslam 68 5984 jhaslam cat > main.c <<EOF 69 5984 jhaslam #include <sys/sdt.h> 70 5984 jhaslam #include "prov.h" 71 5984 jhaslam 72 5984 jhaslam int 73 5984 jhaslam main(int argc, char **argv) 74 5984 jhaslam { 75 5984 jhaslam PYRAMID_ENTRY(); 76 5984 jhaslam } 77 5984 jhaslam EOF 78 5984 jhaslam 79 5984 jhaslam make > /dev/null 80 5984 jhaslam if [ $? -ne 0 ]; then 81 5984 jhaslam print -u2 "failed to build" 82 5984 jhaslam exit 1 83 5984 jhaslam fi 84 5984 jhaslam 85 5984 jhaslam cat > main.d <<'EOF' 86 5984 jhaslam p*d$target::main:entry 87 5984 jhaslam { 88 5984 jhaslam printf("%s:%s:%s\n", probemod, probefunc, probename); 89 5984 jhaslam } 90 5984 jhaslam EOF 91 5984 jhaslam 92 5984 jhaslam script() { 93 5984 jhaslam $dtrace -q -s ./main.d -c ./main 94 5984 jhaslam } 95 5984 jhaslam 96 5984 jhaslam script 97 5984 jhaslam status=$? 98 5984 jhaslam 99 5984 jhaslam cd /tmp 100 5984 jhaslam /usr/bin/rm -rf $DIR 101 5984 jhaslam 102 5984 jhaslam exit $status 103