10bac14eaSahl# 20bac14eaSahl# CDDL HEADER START 30bac14eaSahl# 40bac14eaSahl# The contents of this file are subject to the terms of the 50bac14eaSahl# Common Development and Distribution License (the "License"). 60bac14eaSahl# You may not use this file except in compliance with the License. 70bac14eaSahl# 80bac14eaSahl# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 90bac14eaSahl# or http://www.opensolaris.org/os/licensing. 100bac14eaSahl# See the License for the specific language governing permissions 110bac14eaSahl# and limitations under the License. 120bac14eaSahl# 130bac14eaSahl# When distributing Covered Code, include this CDDL HEADER in each 140bac14eaSahl# file and include the License file at usr/src/OPENSOLARIS.LICENSE. 150bac14eaSahl# If applicable, add the following below this CDDL HEADER, with the 160bac14eaSahl# fields enclosed by brackets "[]" replaced with your own identifying 170bac14eaSahl# information: Portions Copyright [yyyy] [name of copyright owner] 180bac14eaSahl# 190bac14eaSahl# CDDL HEADER END 200bac14eaSahl# 210bac14eaSahl 220bac14eaSahl# 230bac14eaSahl# Copyright 2008 Sun Microsystems, Inc. All rights reserved. 240bac14eaSahl# Use is subject to license terms. 250bac14eaSahl# 260bac14eaSahl 270bac14eaSahl# 280bac14eaSahl# This test is primarily intended to verify a fix for SPARC, but there's no 290bac14eaSahl# harm in running it on other platforms. Here, we verify that is-enabled 300bac14eaSahl# probes don't interfere with return values from previously invoked functions. 310bac14eaSahl# 320bac14eaSahl 330bac14eaSahlif [ $# != 1 ]; then 340bac14eaSahl echo expected one argument: '<'dtrace-path'>' 350bac14eaSahl exit 2 360bac14eaSahlfi 370bac14eaSahl 380bac14eaSahldtrace=$1 390bac14eaSahlDIR=/var/tmp/dtest.$$ 400bac14eaSahl 410bac14eaSahlmkdir $DIR 420bac14eaSahlcd $DIR 430bac14eaSahl 440bac14eaSahlcat > prov.d <<EOF 450bac14eaSahlprovider test_prov { 460bac14eaSahl probe go(); 470bac14eaSahl}; 480bac14eaSahlEOF 490bac14eaSahl 500bac14eaSahl$dtrace -h -s prov.d 510bac14eaSahlif [ $? -ne 0 ]; then 520bac14eaSahl print -u2 "failed to generate header file" 530bac14eaSahl exit 1 540bac14eaSahlfi 550bac14eaSahl 560bac14eaSahlcat > test.c <<EOF 570bac14eaSahl#include <stdio.h> 580bac14eaSahl#include "prov.h" 590bac14eaSahl 600bac14eaSahlint 610bac14eaSahlfoo(void) 620bac14eaSahl{ 630bac14eaSahl return (24); 640bac14eaSahl} 650bac14eaSahl 660bac14eaSahlint 670bac14eaSahlmain(int argc, char **argv) 680bac14eaSahl{ 690bac14eaSahl int a = foo(); 700bac14eaSahl if (TEST_PROV_GO_ENABLED()) { 710bac14eaSahl TEST_PROV_GO(); 720bac14eaSahl } 730bac14eaSahl (void) printf("%d %d %d\n", a, a, a); 740bac14eaSahl 750bac14eaSahl return (0); 760bac14eaSahl} 770bac14eaSahlEOF 780bac14eaSahl 79*a386cc11SRobert Mustacchigcc -m32 -c test.c 800bac14eaSahlif [ $? -ne 0 ]; then 810bac14eaSahl print -u2 "failed to compile test.c" 820bac14eaSahl exit 1 830bac14eaSahlfi 840bac14eaSahl$dtrace -G -32 -s prov.d test.o 850bac14eaSahlif [ $? -ne 0 ]; then 860bac14eaSahl print -u2 "failed to create DOF" 870bac14eaSahl exit 1 880bac14eaSahlfi 89*a386cc11SRobert Mustacchi 90*a386cc11SRobert Mustacchigcc -m32 -o test test.o prov.o 910bac14eaSahlif [ $? -ne 0 ]; then 920bac14eaSahl print -u2 "failed to link final executable" 930bac14eaSahl exit 1 940bac14eaSahlfi 950bac14eaSahl 960bac14eaSahlscript() 970bac14eaSahl{ 980bac14eaSahl ./test 990bac14eaSahl 1000bac14eaSahl $dtrace -c ./test -qs /dev/stdin <<EOF 1010bac14eaSahl test_prov\$target::: 1020bac14eaSahl { 1030bac14eaSahl } 1040bac14eaSahlEOF 1050bac14eaSahl} 1060bac14eaSahl 1070bac14eaSahlscript 1080bac14eaSahlstatus=$? 1090bac14eaSahl 1100bac14eaSahlcd / 1110bac14eaSahl/usr/bin/rm -rf $DIR 1120bac14eaSahl 1130bac14eaSahlexit $status 114