diff options
Diffstat (limited to '')
44 files changed, 2882 insertions, 0 deletions
diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/Makefile.kup b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/Makefile.kup new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/Makefile.kup diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/argmap.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/argmap.d new file mode 100644 index 00000000..0a1c3609 --- /dev/null +++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/argmap.d @@ -0,0 +1,31 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +provider test_prov { + probe place(int i, int j) : (int j, int i, int i, int j); +}; diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/args.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/args.d new file mode 100644 index 00000000..a11984c1 --- /dev/null +++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/args.d @@ -0,0 +1,31 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +provider test_prov { + probe place(int i, int j); +}; diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/forker.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/forker.d new file mode 100644 index 00000000..f63b965d --- /dev/null +++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/forker.d @@ -0,0 +1,31 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +provider forker { + probe fire(); +}; diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.andpid.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.andpid.ksh new file mode 100644 index 00000000..2096422b --- /dev/null +++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.andpid.ksh @@ -0,0 +1,46 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2006 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# +#ident "%Z%%M% %I% %E% SMI" + +if [ $# != 1 ]; then + echo expected one argument: '<'dtrace-path'>' + exit 2 +fi + +dtrace=$1 + +$dtrace -c date -s /dev/stdin <<EOF +plockstat\$target::mutex_lock_impl:, +pid\$target::mutex_lock_impl: +{} +EOF + +if [ $? -ne 0 ]; then + print -u2 "dtrace failed" + exit 1 +fi + +exit 0 diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.argmap.c b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.argmap.c new file mode 100644 index 00000000..5697ef51 --- /dev/null +++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.argmap.c @@ -0,0 +1,39 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +#include <sys/sdt.h> + +int +main(int argc, char **argv) +{ + for (;;) { + DTRACE_PROBE2(test_prov, place, 10, 4); + } + + return (0); +} diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.argmap.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.argmap.d new file mode 100644 index 00000000..fd9f9f47 --- /dev/null +++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.argmap.d @@ -0,0 +1,65 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: Verify that argN and args[N] variables are properly remapped. + */ + +BEGIN +{ + /* Timeout after 5 seconds */ + timeout = timestamp + 5000000000; +} + +test_prov$1:::place +/arg0 != 4 || arg1 != 10 || arg2 != 10 || arg3 != 4/ +{ + printf("args are %d, %d, %d, %d; should be 4, 10, 10, 4", + arg0, arg1, arg2, arg3); + exit(1); +} + +test_prov$1:::place +/args[0] != 4 || args[1] != 10 || args[2] != 10 || args[3] != 4/ +{ + printf("args are %d, %d, %d, %d; should be 4, 10, 10, 4", + args[0], args[1], args[2], args[3]); + exit(1); +} + +test_prov$1:::place +{ + exit(0); +} + +profile:::tick-1 +/timestamp > timeout/ +{ + trace("test timed out"); + exit(1); +} diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.args.c b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.args.c new file mode 100644 index 00000000..5697ef51 --- /dev/null +++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.args.c @@ -0,0 +1,39 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +#include <sys/sdt.h> + +int +main(int argc, char **argv) +{ + for (;;) { + DTRACE_PROBE2(test_prov, place, 10, 4); + } + + return (0); +} diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.args.d b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.args.d new file mode 100644 index 00000000..bb74e80f --- /dev/null +++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.args.d @@ -0,0 +1,60 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * ASSERTION: + * + * SECTION: + * + * NOTES: + * + */ +BEGIN +{ + /* Timeout after 5 seconds */ + timeout = timestamp + 5000000000; +} + +test_prov$1:::place +/arg0 == 10 && arg1 == 4/ +{ + exit(0); +} + +test_prov$1:::place +{ + printf("args are %d, %d; should be 10, 4", arg0, arg1); + exit(1); +} + +profile:::tick-1 +/timestamp > timeout/ +{ + trace("test timed out"); + exit(1); +} diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.badguess.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.badguess.ksh new file mode 100644 index 00000000..291fe83f --- /dev/null +++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.badguess.ksh @@ -0,0 +1,84 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2006 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# +# ident "%Z%%M% %I% %E% SMI" + +if [ $# != 1 ]; then + echo expected one argument: '<'dtrace-path'>' + exit 2 +fi + +dtrace=$1 +DIR=/var/tmp/dtest.$$ + +mkdir $DIR +cd $DIR + +cat > prov.d <<EOF +provider test_prov { + probe go(); +}; +EOF + +$dtrace -h -s prov.d +if [ $? -ne 0 ]; then + print -u2 "failed to generate header file" + exit 1 +fi + +cat > test.c <<EOF +#include <sys/types.h> +#include "prov.h" + +int +main(int argc, char **argv) +{ + if (TEST_PROV_GO_ENABLED()) { + TEST_PROV_GO(); + } +} +EOF + +cc -xarch=generic64 -c -o test64.o test.c +if [ $? -ne 0 ]; then + print -u2 "failed to compile test.c 64-bit" + exit 1 +fi +cc -xarch=generic -c -o test32.o test.c +if [ $? -ne 0 ]; then + print -u2 "failed to compile test.c 32-bit" + exit 1 +fi + +$dtrace -G -s prov.d test32.o test64.o +if [ $? -eq 0 ]; then + print -u2 "DOF generation failed to generate a warning" + exit 1 +fi + +cd / +/usr/bin/rm -rf $DIR + +exit 0 diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.corruptenv.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.corruptenv.ksh new file mode 100644 index 00000000..68dbb034 --- /dev/null +++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.corruptenv.ksh @@ -0,0 +1,107 @@ +#!/usr/bin/ksh +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2008 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# + +# +# This test verifies that a program that corrupts its own environment +# without inducing a crash does not crash solely due to drti.o's use of +# getenv(3C). +# + +PATH=/usr/bin:/usr/sbin:$PATH + +if (( $# != 1 )); then + print -u2 'expected one argument: <dtrace-path>' + exit 2 +fi + +# +# jdtrace does not implement the -h option that is required to generate +# C header files. +# +if [[ "$1" == */jdtrace ]]; then + exit 0 +fi + +dtrace="$1" +startdir="$PWD" +dir=$(mktemp -td drtiXXXXXX) +if (( $? != 0 )); then + print -u2 'Could not create safe temporary directory' + exit 2 +fi + +cd "$dir" + +cat > Makefile <<EOF +all: main + +main: main.o prov.o + \$(CC) -o main main.o prov.o + +main.o: main.c prov.h + \$(CC) -c main.c + +prov.h: prov.d + $dtrace -h -s prov.d + +prov.o: prov.d main.o + $dtrace -G -32 -s prov.d main.o +EOF + +cat > prov.d <<EOF +provider tester { + probe entry(); +}; +EOF + +cat > main.c <<EOF +#include <stdlib.h> +#include <sys/sdt.h> +#include "prov.h" + +int +main(int argc, char **argv, char **envp) +{ + envp[0] = (char*)0xff; + TESTER_ENTRY(); + return 0; +} +EOF + +make > /dev/null +status=$? +if (( $status != 0 )) ; then + print -u2 "failed to build" +else + ./main + status=$? +fi + +cd "$startdir" +rm -rf "$dir" + +exit $status diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.dlclose1.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.dlclose1.ksh new file mode 100755 index 00000000..0a666662 --- /dev/null +++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.dlclose1.ksh @@ -0,0 +1,159 @@ +#!/bin/ksh -p +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2007 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# +# ident "%Z%%M% %I% %E% SMI" + +# +# This test verifies that USDT providers are removed when its associated +# load object is closed via dlclose(3dl). +# + +if [ $# != 1 ]; then + echo expected one argument: '<'dtrace-path'>' + exit 2 +fi + +dtrace=$1 +DIR=/var/tmp/dtest.$$ + +mkdir $DIR +cd $DIR + +cat > Makefile <<EOF +all: main livelib.so deadlib.so + +main: main.o prov.o + cc -o main main.o + +main.o: main.c + cc -c main.c + + +livelib.so: livelib.o prov.o + cc -z defs -G -o livelib.so livelib.o prov.o -lc + +livelib.o: livelib.c prov.h + cc -c livelib.c + +prov.o: livelib.o prov.d + $dtrace -G -s prov.d livelib.o + +prov.h: prov.d + $dtrace -h -s prov.d + + +deadlib.so: deadlib.o + cc -z defs -G -o deadlib.so deadlib.o -lc + +deadlib.o: deadlib.c + cc -c deadlib.c + +clean: + rm -f main.o livelib.o prov.o prov.h deadlib.o + +clobber: clean + rm -f main livelib.so deadlib.so +EOF + +cat > prov.d <<EOF +provider test_prov { + probe go(); +}; +EOF + +cat > livelib.c <<EOF +#include "prov.h" + +void +go(void) +{ + TEST_PROV_GO(); +} +EOF + +cat > deadlib.c <<EOF +void +go(void) +{ +} +EOF + + +cat > main.c <<EOF +#include <dlfcn.h> +#include <unistd.h> +#include <stdio.h> + +int +main(int argc, char **argv) +{ + void *live; + + if ((live = dlopen("./livelib.so", RTLD_LAZY | RTLD_LOCAL)) == NULL) { + printf("dlopen of livelib.so failed: %s\n", dlerror()); + return (1); + } + + (void) dlclose(live); + + pause(); + + return (0); +} +EOF + +/usr/ccs/bin/make > /dev/null +if [ $? -ne 0 ]; then + print -u2 "failed to build" + exit 1 +fi + +script() { + $dtrace -w -x bufsize=1k -c ./main -qs /dev/stdin <<EOF + syscall::pause:entry + /pid == \$target/ + { + system("$dtrace -l -P test_prov*"); + system("kill %d", \$target); + exit(0); + } + + tick-1s + /i++ == 5/ + { + printf("failed\n"); + exit(1); + } +EOF +} + +script 2>&1 +status=$? + +cd / +/usr/bin/rm -rf $DIR + +exit $status diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.dlclose1.ksh.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.dlclose1.ksh.out new file mode 100644 index 00000000..2f5bb15f --- /dev/null +++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.dlclose1.ksh.out @@ -0,0 +1,3 @@ +dtrace: failed to match test_prov*:::: No probe matches description + ID PROVIDER MODULE FUNCTION NAME + diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.dlclose2.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.dlclose2.ksh new file mode 100755 index 00000000..c83d8bfa --- /dev/null +++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.dlclose2.ksh @@ -0,0 +1,160 @@ +#!/bin/ksh -p +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2006 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# +#ident "%Z%%M% %I% %E% SMI" + +if [ $# != 1 ]; then + echo expected one argument: '<'dtrace-path'>' + exit 2 +fi + +dtrace=$1 +DIR=/var/tmp/dtest.$$ + +mkdir $DIR +cd $DIR + +cat > Makefile <<EOF +all: main livelib.so deadlib.so + +main: main.o prov.o + cc -o main main.o + +main.o: main.c + cc -c main.c + + +livelib.so: livelib.o prov.o + cc -z defs -G -o livelib.so livelib.o prov.o -lc + +livelib.o: livelib.c prov.h + cc -c livelib.c + +prov.o: livelib.o prov.d + $dtrace -G -s prov.d livelib.o + +prov.h: prov.d + $dtrace -h -s prov.d + + +deadlib.so: deadlib.o + cc -z defs -G -o deadlib.so deadlib.o -lc + +deadlib.o: deadlib.c + cc -c deadlib.c + +clean: + rm -f main.o livelib.o prov.o prov.h deadlib.o + +clobber: clean + rm -f main livelib.so deadlib.so +EOF + +cat > prov.d <<EOF +provider test_prov { + probe go(); +}; +EOF + +cat > livelib.c <<EOF +#include "prov.h" + +void +go(void) +{ + TEST_PROV_GO(); +} +EOF + +cat > deadlib.c <<EOF +void +go(void) +{ +} +EOF + + +cat > main.c <<EOF +#include <dlfcn.h> +#include <unistd.h> +#include <stdio.h> + +int +main(int argc, char **argv) +{ + void *live, *dead; + void *go; + + if ((live = dlopen("./livelib.so", RTLD_LAZY | RTLD_LOCAL)) == NULL) { + printf("dlopen of livelib.so failed: %s\n", dlerror()); + return (1); + } + + (void) dlclose(live); + + if ((dead = dlopen("./deadlib.so", RTLD_LAZY | RTLD_LOCAL)) == NULL) { + printf("dlopen of deadlib.so failed: %s\n", dlerror()); + return (1); + } + + if ((live = dlopen("./livelib.so", RTLD_LAZY | RTLD_LOCAL)) == NULL) { + printf("dlopen of livelib.so failed: %s\n", dlerror()); + return (1); + } + + if ((go = dlsym(live, "go")) == NULL) { + printf("failed to lookup 'go' in livelib.so\n"); + return (1); + } + + ((void (*)(void))go)(); + + return (0); +} +EOF + +/usr/ccs/bin/make > /dev/null +if [ $? -ne 0 ]; then + print -u2 "failed to build" + exit 1 +fi + +script() { + $dtrace -w -c ./main -Zqs /dev/stdin <<EOF + test_prov*::: + { + printf("%s:%s:%s\n", probemod, probefunc, probename); + } +EOF +} + +script +status=$? + +cd / +/usr/bin/rm -rf $DIR + +exit $status diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.dlclose2.ksh.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.dlclose2.ksh.out new file mode 100644 index 00000000..2164eabc --- /dev/null +++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.dlclose2.ksh.out @@ -0,0 +1,2 @@ +livelib.so:go:go + diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.dlclose3.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.dlclose3.ksh new file mode 100755 index 00000000..72f24ce5 --- /dev/null +++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.dlclose3.ksh @@ -0,0 +1,170 @@ +#!/bin/ksh -p +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2007 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# +# ident "%Z%%M% %I% %E% SMI" + +# +# This test verifies that performing a dlclose(3dl) on a library doesn't +# cause existing pid provider probes to become invalid. +# + +if [ $# != 1 ]; then + echo expected one argument: '<'dtrace-path'>' + exit 2 +fi + +dtrace=$1 +DIR=/var/tmp/dtest.$$ + +mkdir $DIR +cd $DIR + +cat > Makefile <<EOF +all: main livelib.so deadlib.so + +main: main.o prov.o + cc -o main main.o + +main.o: main.c + cc -c main.c + + +livelib.so: livelib.o prov.o + cc -z defs -G -o livelib.so livelib.o prov.o -lc + +livelib.o: livelib.c prov.h + cc -c livelib.c + +prov.o: livelib.o prov.d + $dtrace -G -s prov.d livelib.o + +prov.h: prov.d + $dtrace -h -s prov.d + + +deadlib.so: deadlib.o + cc -z defs -G -o deadlib.so deadlib.o -lc + +deadlib.o: deadlib.c + cc -c deadlib.c + +clean: + rm -f main.o livelib.o prov.o prov.h deadlib.o + +clobber: clean + rm -f main livelib.so deadlib.so +EOF + +cat > prov.d <<EOF +provider test_prov { + probe go(); +}; +EOF + +cat > livelib.c <<EOF +#include "prov.h" + +void +go(void) +{ + TEST_PROV_GO(); +} +EOF + +cat > deadlib.c <<EOF +void +go(void) +{ +} +EOF + + +cat > main.c <<EOF +#include <dlfcn.h> +#include <unistd.h> +#include <stdio.h> + +static void +foo(void) +{ + (void) close(-1); +} + +int +main(int argc, char **argv) +{ + void *live; + + if ((live = dlopen("./livelib.so", RTLD_LAZY | RTLD_LOCAL)) == NULL) { + printf("dlopen of livelib.so failed: %s\n", dlerror()); + return (1); + } + + (void) dlclose(live); + + foo(); + + return (0); +} +EOF + +/usr/ccs/bin/make > /dev/null +if [ $? -ne 0 ]; then + print -u2 "failed to build" + exit 1 +fi + +script() { + $dtrace -c ./main -s /dev/stdin <<EOF + pid\$target:a.out:foo:entry + { + gotit = 1; + exit(0); + } + + tick-1s + /i++ == 5/ + { + printf("test timed out"); + exit(1); + } + + END + /!gotit/ + { + printf("program ended without hitting probe"); + exit(1); + } +EOF +} + +script +status=$? + +cd / +/usr/bin/rm -rf $DIR + +exit $status diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.eliminate.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.eliminate.ksh new file mode 100644 index 00000000..687e435e --- /dev/null +++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.eliminate.ksh @@ -0,0 +1,106 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2007 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# +# ident "%Z%%M% %I% %E% SMI" + +# +# Make sure temporary symbols generated due to DTrace probes in static +# functions are removed in the final link step. +# + +if [ $# != 1 ]; then + echo expected one argument: '<'dtrace-path'>' + exit 2 +fi + +dtrace=$1 +DIR=/var/tmp/dtest.$$ + +mkdir $DIR +cd $DIR + +cat > prov.d <<EOF +provider test_prov { + probe go(); +}; +EOF + +$dtrace -h -s prov.d +if [ $? -ne 0 ]; then + print -u2 "failed to generate header file" + exit 1 +fi + +cat > test.c <<EOF +#include <sys/types.h> +#include "prov.h" + +static void +foo(void) +{ + TEST_PROV_GO(); +} + +int +main(int argc, char **argv) +{ + foo(); + + return (0); +} +EOF + +cc -c test.c +if [ $? -ne 0 ]; then + print -u2 "failed to compile test.c" + exit 1 +fi +$dtrace -G -32 -s prov.d test.o +if [ $? -ne 0 ]; then + print -u2 "failed to create DOF" + exit 1 +fi +cc -o test test.o prov.o +if [ $? -ne 0 ]; then + print -u2 "failed to link final executable" + exit 1 +fi + +nm test.o | grep \$dtrace > /dev/null +if [ $? -ne 0 ]; then + print -u2 "no temporary symbols in the object file" + exit 1 +fi + +nm test | grep \$dtrace > /dev/null +if [ $? -eq 0 ]; then + print -u2 "failed to eliminate temporary symbols" + exit 1 +fi + +cd / +/usr/bin/rm -rf $DIR + +exit 0 diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.enabled.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.enabled.ksh new file mode 100644 index 00000000..ba62be75 --- /dev/null +++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.enabled.ksh @@ -0,0 +1,96 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2006 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# +#ident "%Z%%M% %I% %E% SMI" + +if [ $# != 1 ]; then + echo expected one argument: '<'dtrace-path'>' + exit 2 +fi + +dtrace=$1 +DIR=/var/tmp/dtest.$$ + +mkdir $DIR +cd $DIR + +cat > prov.d <<EOF +provider test_prov { + probe go(); +}; +EOF + +$dtrace -h -s prov.d +if [ $? -ne 0 ]; then + print -u2 "failed to generate header file" + exit 1 +fi + +cat > test.c <<EOF +#include <sys/types.h> +#include "prov.h" + +int +main(int argc, char **argv) +{ + if (TEST_PROV_GO_ENABLED()) { + TEST_PROV_GO(); + } +} +EOF + +cc -c test.c +if [ $? -ne 0 ]; then + print -u2 "failed to compile test.c" + exit 1 +fi +$dtrace -G -32 -s prov.d test.o +if [ $? -ne 0 ]; then + print -u2 "failed to create DOF" + exit 1 +fi +cc -o test test.o prov.o +if [ $? -ne 0 ]; then + print -u2 "failed to link final executable" + exit 1 +fi + +script() +{ + $dtrace -c ./test -qs /dev/stdin <<EOF + test_prov\$target::: + { + printf("%s:%s:%s\n", probemod, probefunc, probename); + } +EOF +} + +script +status=$? + +cd / +/usr/bin/rm -rf $DIR + +exit $status diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.enabled.ksh.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.enabled.ksh.out new file mode 100644 index 00000000..b856cc59 --- /dev/null +++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.enabled.ksh.out @@ -0,0 +1,2 @@ +test:main:go + diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.enabled2.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.enabled2.ksh new file mode 100644 index 00000000..34016484 --- /dev/null +++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.enabled2.ksh @@ -0,0 +1,113 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2008 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# +#ident "%Z%%M% %I% %E% SMI" + +# +# This test is primarily intended to verify a fix for SPARC, but there's no +# harm in running it on other platforms. Here, we verify that is-enabled +# probes don't interfere with return values from previously invoked functions. +# + +if [ $# != 1 ]; then + echo expected one argument: '<'dtrace-path'>' + exit 2 +fi + +dtrace=$1 +DIR=/var/tmp/dtest.$$ + +mkdir $DIR +cd $DIR + +cat > prov.d <<EOF +provider test_prov { + probe go(); +}; +EOF + +$dtrace -h -s prov.d +if [ $? -ne 0 ]; then + print -u2 "failed to generate header file" + exit 1 +fi + +cat > test.c <<EOF +#include <stdio.h> +#include "prov.h" + +int +foo(void) +{ + return (24); +} + +int +main(int argc, char **argv) +{ + int a = foo(); + if (TEST_PROV_GO_ENABLED()) { + TEST_PROV_GO(); + } + (void) printf("%d %d %d\n", a, a, a); + + return (0); +} +EOF + +cc -c -xO2 test.c +if [ $? -ne 0 ]; then + print -u2 "failed to compile test.c" + exit 1 +fi +$dtrace -G -32 -s prov.d test.o +if [ $? -ne 0 ]; then + print -u2 "failed to create DOF" + exit 1 +fi +cc -o test test.o prov.o +if [ $? -ne 0 ]; then + print -u2 "failed to link final executable" + exit 1 +fi + +script() +{ + ./test + + $dtrace -c ./test -qs /dev/stdin <<EOF + test_prov\$target::: + { + } +EOF +} + +script +status=$? + +cd / +/usr/bin/rm -rf $DIR + +exit $status diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.enabled2.ksh.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.enabled2.ksh.out new file mode 100644 index 00000000..563d68fd --- /dev/null +++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.enabled2.ksh.out @@ -0,0 +1,3 @@ +24 24 24 +24 24 24 + diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.entryreturn.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.entryreturn.ksh new file mode 100644 index 00000000..9d2646cd --- /dev/null +++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.entryreturn.ksh @@ -0,0 +1,118 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2007 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# +# ident "%Z%%M% %I% %E% SMI" + +if [ $# != 1 ]; then + echo expected one argument: '<'dtrace-path'>' + exit 2 +fi + +dtrace=$1 +DIR=/var/tmp/dtest.$$ + +mkdir $DIR +cd $DIR + +cat > test.c <<EOF +#include <sys/sdt.h> + +int +main(int argc, char **argv) +{ + DTRACE_PROBE(test_prov, entry); + DTRACE_PROBE(test_prov, __entry); + DTRACE_PROBE(test_prov, foo__entry); + DTRACE_PROBE(test_prov, carpentry); + DTRACE_PROBE(test_prov, miniatureturn); + DTRACE_PROBE(test_prov, foo__return); + DTRACE_PROBE(test_prov, __return); + /* + * Unfortunately, a "return" probe is not currently possible due to + * the conflict with a reserved word. + */ + DTRACE_PROBE(test_prov, done); +} +EOF + +cat > prov.d <<EOF +provider test_prov { + probe entry(); + probe __entry(); + probe foo__entry(); + probe carpentry(); + probe miniatureturn(); + probe foo__return(); + probe __return(); + probe done(); +}; +EOF + +cc -c test.c +if [ $? -ne 0 ]; then + print -u2 "failed to compile test.c" + exit 1 +fi +$dtrace -G -32 -s prov.d test.o +if [ $? -ne 0 ]; then + print -u2 "failed to create DOF" + exit 1 +fi +cc -o test test.o prov.o +if [ $? -ne 0 ]; then + print -u2 "failed to link final executable" + exit 1 +fi + +script() +{ + $dtrace -wqZFs /dev/stdin <<EOF + BEGIN + { + system("$DIR/test"); + printf("\n"); + } + + test_prov*:::done + /progenyof(\$pid)/ + { + exit(0); + } + + test_prov*::: + /progenyof(\$pid)/ + { + printf("\n"); + } +EOF +} + +script | cut -c5- +status=$? + +cd / +/usr/bin/rm -rf $DIR + +exit $status diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.entryreturn.ksh.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.entryreturn.ksh.out new file mode 100644 index 00000000..3bf28907 --- /dev/null +++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.entryreturn.ksh.out @@ -0,0 +1,10 @@ +FUNCTION +| :BEGIN + -> main + -> main + -> main + | main:carpentry + | main:miniatureturn + <- main + <- main + | main:done diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.fork.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.fork.ksh new file mode 100755 index 00000000..9c12e6de --- /dev/null +++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.fork.ksh @@ -0,0 +1,105 @@ +#!/bin/ksh -p +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2006 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# +#ident "%Z%%M% %I% %E% SMI" + +if [ $# != 1 ]; then + echo expected one argument: '<'dtrace-path'>' + exit 2 +fi + +dtrace=$1 +DIR=/var/tmp/dtest.$$ + +mkdir $DIR +cd $DIR + +cat > prov.d <<EOF +provider test_prov { + probe go(); +}; +EOF + +$dtrace -h -s prov.d +if [ $? -ne 0 ]; then + print -u2 "failed to generate header file" + exit 1 +fi + +cat > test.c <<EOF +#include <sys/types.h> +#include <sys/wait.h> +#include <unistd.h> +#include "prov.h" + +int +main(int argc, char **argv) +{ + TEST_PROV_GO(); + if (fork() == 0) { + TEST_PROV_GO(); + return (0); + } + + (void) wait(NULL); + TEST_PROV_GO(); + + return (0); +} +EOF + +cc -c test.c +if [ $? -ne 0 ]; then + print -u2 "failed to compile test.c" + exit 1 +fi +$dtrace -G -32 -s prov.d test.o +if [ $? -ne 0 ]; then + print -u2 "failed to create DOF" + exit 1 +fi +cc -o test test.o prov.o +if [ $? -ne 0 ]; then + print -u2 "failed to link final executable" + exit 1 +fi + +script() { + $dtrace -c ./test -Zqs /dev/stdin <<EOF + test_prov*::: + { + printf("%s:%s:%s\n", probemod, probefunc, probename); + } +EOF +} + +script +status=$? + +cd / +/usr/bin/rm -rf $DIR + +exit $status diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.fork.ksh.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.fork.ksh.out new file mode 100644 index 00000000..c656c337 --- /dev/null +++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.fork.ksh.out @@ -0,0 +1,4 @@ +test:main:go +test:main:go +test:main:go + diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.forker.c b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.forker.c new file mode 100644 index 00000000..ade7f83b --- /dev/null +++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.forker.c @@ -0,0 +1,47 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +#include <unistd.h> + +#include "forker.h" + +int +main(int argc, char **argv) +{ + int i; + + for (i = 0; i < 10000; i++) { + FORKER_FIRE(); + if (fork() == 0) + exit(0); + + (void) wait(NULL); + } + + return (0); +} diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.forker.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.forker.ksh new file mode 100755 index 00000000..d35fc4db --- /dev/null +++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.forker.ksh @@ -0,0 +1,55 @@ +#!/usr/bin/ksh +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2007 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# +# ident "%Z%%M% %I% %E% SMI" +# + +if [ $# != 1 ]; then + echo expected one argument: '<'dtrace-path'>' + exit 2 +fi + +dtrace=$1 + +# +# Test that we don't deadlock between forking and enabling/disabling USDT +# probes. This test has succeeded if it completes at all. +# + +./tst.forker.exe & +id=$! + +while kill -0 $id >/dev/null 2>&1; do + $dtrace -p $id -s /dev/stdin <<-EOF + forker*:::fire + /i++ == 4/ + { + exit(0); + } + EOF +done + +exit 0 diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.guess32.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.guess32.ksh new file mode 100644 index 00000000..68a8d016 --- /dev/null +++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.guess32.ksh @@ -0,0 +1,96 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2006 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# +# ident "%Z%%M% %I% %E% SMI" + +if [ $# != 1 ]; then + echo expected one argument: '<'dtrace-path'>' + exit 2 +fi + +dtrace=$1 +DIR=/var/tmp/dtest.$$ + +mkdir $DIR +cd $DIR + +cat > prov.d <<EOF +provider test_prov { + probe go(); +}; +EOF + +$dtrace -h -s prov.d +if [ $? -ne 0 ]; then + print -u2 "failed to generate header file" + exit 1 +fi + +cat > test.c <<EOF +#include <sys/types.h> +#include "prov.h" + +int +main(int argc, char **argv) +{ + if (TEST_PROV_GO_ENABLED()) { + TEST_PROV_GO(); + } +} +EOF + +cc -xarch=generic -c test.c +if [ $? -ne 0 ]; then + print -u2 "failed to compile test.c" + exit 1 +fi +$dtrace -G -s prov.d test.o +if [ $? -ne 0 ]; then + print -u2 "failed to create DOF" + exit 1 +fi +cc -xarch=generic -o test test.o prov.o +if [ $? -ne 0 ]; then + print -u2 "failed to link final executable" + exit 1 +fi + +script() +{ + $dtrace -c ./test -qs /dev/stdin <<EOF + test_prov\$target::: + { + printf("%s:%s:%s\n", probemod, probefunc, probename); + } +EOF +} + +script +status=$? + +cd / +/usr/bin/rm -rf $DIR + +exit $status diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.guess64.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.guess64.ksh new file mode 100644 index 00000000..39de8e0d --- /dev/null +++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.guess64.ksh @@ -0,0 +1,100 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2006 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# +# ident "%Z%%M% %I% %E% SMI" + +if [ $# != 1 ]; then + echo expected one argument: '<'dtrace-path'>' + exit 2 +fi + +dtrace=$1 +DIR=/var/tmp/dtest.$$ + +mkdir $DIR +cd $DIR + +cat > prov.d <<EOF +provider test_prov { + probe go(); +}; +EOF + +$dtrace -h -s prov.d +if [ $? -ne 0 ]; then + print -u2 "failed to generate header file" + exit 1 +fi + +cat > test.c <<EOF +#include <sys/types.h> +#include "prov.h" + +int +main(int argc, char **argv) +{ + if (TEST_PROV_GO_ENABLED()) { + TEST_PROV_GO(); + } +} +EOF + +cc -xarch=generic64 -c test.c +if [ $? -ne 0 ]; then + print -u2 "failed to compile test.c" + exit 1 +fi +$dtrace -G -s prov.d test.o +if [ $? -ne 0 ]; then + print -u2 "failed to create DOF" + exit 1 +fi +cc -xarch=generic64 -o test test.o prov.o +if [ $? -ne 0 ]; then + print -u2 "failed to link final executable" + exit 1 +fi + +script() +{ + $dtrace -c ./test -qs /dev/stdin <<EOF + test_prov\$target::: + { + printf("%s:%s:%s\n", probemod, probefunc, probename); + } +EOF +} + +if [ `isainfo -b` -ne '64']; then + script + status=$? +else + status=0 +fi + +cd / +/usr/bin/rm -rf $DIR + +exit $status diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.header.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.header.ksh new file mode 100644 index 00000000..08a1912b --- /dev/null +++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.header.ksh @@ -0,0 +1,85 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2006 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# +#ident "%Z%%M% %I% %E% SMI" + +if [ $# != 1 ]; then + echo expected one argument: '<'dtrace-path'>' + exit 2 +fi + +dtrace=$1 +DIR=/var/tmp/dtest.$$ + +mkdir $DIR +cd $DIR + +cat > prov.d <<EOF +provider test_prov { + probe zero(); + probe one(uintptr_t); + probe u_nder(char *); + probe d__ash(int **); +}; +EOF + +$dtrace -h -s prov.d +if [ $? -ne 0 ]; then + print -u2 "failed to generate header file" + exit 1 +fi + +cat > test.c <<EOF +#include <sys/types.h> +#include "prov.h" + +int +main(int argc, char **argv) +{ + TEST_PROV_ZERO(); + TEST_PROV_ONE(1); + TEST_PROV_U_NDER("hi there"); + TEST_PROV_D_ASH(argv); +} +EOF + +cc -c test.c +if [ $? -ne 0 ]; then + print -u2 "failed to compile test.c" + exit 1 +fi +$dtrace -G -32 -s prov.d test.o +if [ $? -ne 0 ]; then + print -u2 "failed to create DOF" + exit 1 +fi +cc -o test test.o prov.o +if [ $? -ne 0 ]; then + print -u2 "failed to link final executable" + exit 1 +fi + +cd / +/usr/bin/rm -rf $DIR diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.include.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.include.ksh new file mode 100644 index 00000000..5683f47d --- /dev/null +++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.include.ksh @@ -0,0 +1,61 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2006 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# +# ident "%Z%%M% %I% %E% SMI" + +# Make sure <unistd.h> defines _DTRACE_VERSION + +DIR=/var/tmp/dtest.$$ + +mkdir $DIR +cd $DIR + +cat > test.c <<EOF +#include <unistd.h> + +int +main(int argc, char **argv) +{ +#ifdef _DTRACE_VERSION + return (0); +#else + return (1); +#endif +} +EOF + +cc -xarch=generic -o test test.c +if [ $? -ne 0 ]; then + print -u2 "failed to compile test.c" + exit 1 +fi + +./test +status=$? + +cd / +/usr/bin/rm -rf $DIR + +exit $status diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.linkpriv.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.linkpriv.ksh new file mode 100644 index 00000000..ec07e057 --- /dev/null +++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.linkpriv.ksh @@ -0,0 +1,82 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2006 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# +#ident "%Z%%M% %I% %E% SMI" + +if [ $# != 1 ]; then + echo expected one argument: '<'dtrace-path'>' + exit 2 +fi + +dtrace=$1 +DIR=/var/tmp/dtest.$$ + +mkdir $DIR +cd $DIR + +cat > test.c <<EOF +#include <sys/sdt.h> + +int +main(int argc, char **argv) +{ + DTRACE_PROBE(test_prov, zero); + DTRACE_PROBE1(test_prov, one, 1); + DTRACE_PROBE2(test_prov, two, 2, 3); + DTRACE_PROBE3(test_prov, three, 4, 5, 7); + DTRACE_PROBE4(test_prov, four, 7, 8, 9, 10); + DTRACE_PROBE5(test_prov, five, 11, 12, 13, 14, 15); +} +EOF + +cat > prov.d <<EOF +provider test_prov { + probe zero(); + probe one(uintptr_t); + probe two(uintptr_t, uintptr_t); + probe three(uintptr_t, uintptr_t, uintptr_t); + probe four(uintptr_t, uintptr_t, uintptr_t, uintptr_t); + probe five(uintptr_t, uintptr_t, uintptr_t, uintptr_t, uintptr_t); +}; +EOF + +cc -c test.c +if [ $? -ne 0 ]; then + print -u2 "failed to compile test.c" + exit 1 +fi +$dtrace -G -32 -s prov.d test.o +if [ $? -ne 0 ]; then + print -u2 "failed to create DOF" + exit 1 +fi +cc -o test test.o prov.o +if [ $? -ne 0 ]; then + print -u2 "failed to link final executable" + exit 1 +fi + +cd / +/usr/bin/rm -rf $DIR diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.linkunpriv.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.linkunpriv.ksh new file mode 100644 index 00000000..01b2126c --- /dev/null +++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.linkunpriv.ksh @@ -0,0 +1,84 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2006 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# +#ident "%Z%%M% %I% %E% SMI" + +if [ $# != 1 ]; then + echo expected one argument: '<'dtrace-path'>' + exit 2 +fi + +dtrace=$1 +DIR=/var/tmp/dtest.$$ + +mkdir $DIR +cd $DIR + +ppriv -s A=basic $$ + +cat > test.c <<EOF +#include <sys/sdt.h> + +int +main(int argc, char **argv) +{ + DTRACE_PROBE(test_prov, zero); + DTRACE_PROBE1(test_prov, one, 1); + DTRACE_PROBE2(test_prov, two, 2, 3); + DTRACE_PROBE3(test_prov, three, 4, 5, 7); + DTRACE_PROBE4(test_prov, four, 7, 8, 9, 10); + DTRACE_PROBE5(test_prov, five, 11, 12, 13, 14, 15); +} +EOF + +cat > prov.d <<EOF +provider test_prov { + probe zero(); + probe one(uintptr_t); + probe two(uintptr_t, uintptr_t); + probe three(uintptr_t, uintptr_t, uintptr_t); + probe four(uintptr_t, uintptr_t, uintptr_t, uintptr_t); + probe five(uintptr_t, uintptr_t, uintptr_t, uintptr_t, uintptr_t); +}; +EOF + +cc -c test.c +if [ $? -ne 0 ]; then + print -u2 "failed to compile test.c" + exit 1 +fi +$dtrace -G -32 -s prov.d test.o +if [ $? -ne 0 ]; then + print -u2 "failed to create DOF" + exit 1 +fi +cc -o test test.o prov.o +if [ $? -ne 0 ]; then + print -u2 "failed to link final executable" + exit 1 +fi + +cd / +/usr/bin/rm -rf $DIR diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.multiple.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.multiple.ksh new file mode 100755 index 00000000..0c8b072c --- /dev/null +++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.multiple.ksh @@ -0,0 +1,99 @@ +#!/bin/ksh -p +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2006 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# +#ident "%Z%%M% %I% %E% SMI" + +if [ $# != 1 ]; then + echo expected one argument: '<'dtrace-path'>' + exit 2 +fi + +dtrace=$1 +DIR=/var/tmp/dtest.$$ + +mkdir $DIR +cd $DIR + +cat > prov.d <<EOF +provider test_prov { + probe go(); +}; +EOF + +$dtrace -h -s prov.d +if [ $? -ne 0 ]; then + print -u2 "failed to generate header file" + exit 1 +fi + +cat > test.c <<EOF +#include <sys/types.h> +#include "prov.h" + +int +main(int argc, char **argv) +{ + TEST_PROV_GO(); + TEST_PROV_GO(); + TEST_PROV_GO(); + TEST_PROV_GO(); + + return (0); +} +EOF + +cc -c test.c +if [ $? -ne 0 ]; then + print -u2 "failed to compile test.c" + exit 1 +fi +$dtrace -G -32 -s prov.d test.o +if [ $? -ne 0 ]; then + print -u2 "failed to create DOF" + exit 1 +fi +cc -o test test.o prov.o +if [ $? -ne 0 ]; then + print -u2 "failed to link final executable" + exit 1 +fi + +script() { + $dtrace -c ./test -qs /dev/stdin <<EOF + test_prov\$target::: + { + printf("%s:%s:%s\n", probemod, probefunc, probename); + } +EOF +} + +script +status=$? + +cd / +/usr/bin/rm -rf $DIR + +exit $status diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.multiple.ksh.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.multiple.ksh.out new file mode 100644 index 00000000..5e826192 --- /dev/null +++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.multiple.ksh.out @@ -0,0 +1,5 @@ +test:main:go +test:main:go +test:main:go +test:main:go + diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.nodtrace.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.nodtrace.ksh new file mode 100644 index 00000000..a911bcdf --- /dev/null +++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.nodtrace.ksh @@ -0,0 +1,90 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2006 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# +# ident "%Z%%M% %I% %E% SMI" + +# Fake up a scenario where _DTRACE_VERSION is not defined by having our own +# <unistd.h>. This tests that dtrace -h will produce a header file which can +# be used on a system where DTrace is not present. + +if [ $# != 1 ]; then + echo expected one argument: '<'dtrace-path'>' + exit 2 +fi + +dtrace=$1 +DIR=/var/tmp/dtest.$$ + +mkdir $DIR +cd $DIR + +touch unistd.h + +cat > prov.d <<EOF +provider test_prov { + probe go(); +}; +EOF + +$dtrace -h -s prov.d +if [ $? -ne 0 ]; then + print -u2 "failed to generate header file" + exit 1 +fi + +cat > test.c <<EOF +#include "prov.h" + +int +main(int argc, char **argv) +{ + TEST_PROV_GO(); + + if (TEST_PROV_GO_ENABLED()) { + TEST_PROV_GO(); + } + + return (0); +} +EOF + +cc -I. -xarch=generic -c test.c +if [ $? -ne 0 ]; then + print -u2 "failed to compile test.c" + exit 1 +fi +cc -xarch=generic -o test test.o +if [ $? -ne 0 ]; then + print -u2 "failed to link final executable" + exit 1 +fi + +./test +status=$? + +cd / +/usr/bin/rm -rf $DIR + +exit $status diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.onlyenabled.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.onlyenabled.ksh new file mode 100644 index 00000000..989d6d32 --- /dev/null +++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.onlyenabled.ksh @@ -0,0 +1,82 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2006 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# +#ident "%Z%%M% %I% %E% SMI" + +if [ $# != 1 ]; then + echo expected one argument: '<'dtrace-path'>' + exit 2 +fi + +dtrace=$1 +DIR=/var/tmp/dtest.$$ + +mkdir $DIR +cd $DIR + +cat > prov.d <<EOF +provider test_prov { + probe go(); +}; +EOF + +$dtrace -h -s prov.d +if [ $? -ne 0 ]; then + print -u2 "failed to generate header file" + exit 1 +fi + +cat > test.c <<EOF +#include <sys/types.h> +#include "prov.h" + +int +main(int argc, char **argv) +{ + if (TEST_PROV_GO_ENABLED()) + return (2); + + return (0); +} +EOF + +cc -c test.c +if [ $? -ne 0 ]; then + print -u2 "failed to compile test.c" + exit 1 +fi +$dtrace -G -32 -s prov.d test.o +if [ $? -ne 0 ]; then + print -u2 "failed to create DOF" + exit 1 +fi +cc -o test test.o prov.o +if [ $? -ne 0 ]; then + print -u2 "failed to link final executable" + exit 1 +fi + +cd / +/usr/bin/rm -rf $DIR diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.reeval.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.reeval.ksh new file mode 100644 index 00000000..7fad4015 --- /dev/null +++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.reeval.ksh @@ -0,0 +1,98 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2007 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# +# ident "%Z%%M% %I% %E% SMI" + +if [ $# != 1 ]; then + echo expected one argument: '<'dtrace-path'>' + exit 2 +fi + +dtrace=$1 +DIR=/var/tmp/dtest.$$ + +mkdir $DIR +cd $DIR + +cat > test.c <<EOF +#include <sys/sdt.h> + +int +main(int argc, char **argv) +{ + DTRACE_PROBE(test_prov, zero); +} +EOF + +cat > prov.d <<EOF +provider test_prov { + probe zero(); +}; +EOF + +cc -c test.c +if [ $? -ne 0 ]; then + print -u2 "failed to compile test.c" + exit 1 +fi +$dtrace -G -32 -s prov.d test.o +if [ $? -ne 0 ]; then + print -u2 "failed to create DOF" + exit 1 +fi +cc -o test test.o prov.o +if [ $? -ne 0 ]; then + print -u2 "failed to link final executable" + exit 1 +fi + +script() +{ + $dtrace -wZs /dev/stdin <<EOF + BEGIN + { + system("$DIR/test"); + } + + test_prov*::: + { + seen = 1; + } + + proc:::exit + /progenyof(\$pid) && execname == "test"/ + { + exit(seen ? 0 : 2); + } +EOF +} + +script +status=$? + +cd / +/usr/bin/rm -rf $DIR + +exit $status diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.static.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.static.ksh new file mode 100644 index 00000000..1ebcdb95 --- /dev/null +++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.static.ksh @@ -0,0 +1,98 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2006 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# +#ident "%Z%%M% %I% %E% SMI" + +if [ $# != 1 ]; then + echo expected one argument: '<'dtrace-path'>' + exit 2 +fi + +dtrace=$1 +DIR=/var/tmp/dtest.$$ + +mkdir $DIR +cd $DIR + +cat > test.c <<EOF +#include <unistd.h> +#include <sys/sdt.h> + +static void +foo(void) +{ + DTRACE_PROBE(test_prov, probe1); + DTRACE_PROBE(test_prov, probe2); +} + +int +main(int argc, char **argv) +{ + DTRACE_PROBE(test_prov, probe1); + DTRACE_PROBE(test_prov, probe2); + foo(); +} +EOF + +cat > prov.d <<EOF +provider test_prov { + probe probe1(); + probe probe2(); +}; +EOF + +cc -c test.c +if [ $? -ne 0 ]; then + print -u2 "failed to compile test.c" + exit 1 +fi +$dtrace -G -32 -s prov.d test.o +if [ $? -ne 0 ]; then + print -u2 "failed to create DOF" + exit 1 +fi +cc -o test test.o prov.o +if [ $? -ne 0 ]; then + print -u2 "failed to link final executable" + exit 1 +fi + +script() +{ + $dtrace -c ./test -qs /dev/stdin <<EOF + test_prov\$target::: + { + printf("%s:%s:%s\n", probemod, probefunc, probename); + } +EOF +} + +script +status=$? + +cd / +/usr/bin/rm -rf $DIR + +exit $status diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.static.ksh.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.static.ksh.out new file mode 100644 index 00000000..a559d97a --- /dev/null +++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.static.ksh.out @@ -0,0 +1,5 @@ +test:main:probe1 +test:main:probe2 +test:foo:probe1 +test:foo:probe2 + diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.static2.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.static2.ksh new file mode 100644 index 00000000..7cf9004c --- /dev/null +++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.static2.ksh @@ -0,0 +1,108 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2006 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# +#ident "%Z%%M% %I% %E% SMI" + +# Rebuilding an object file containing DOF changes slightly when the object +# files containing the probes have already been modified. This tests that +# case by generating the DOF object, removing it, and building it again. + +if [ $# != 1 ]; then + echo expected one argument: '<'dtrace-path'>' + exit 2 +fi + +dtrace=$1 +DIR=/var/tmp/dtest.$$ + +mkdir $DIR +cd $DIR + +cat > test.c <<EOF +#include <unistd.h> +#include <sys/sdt.h> + +static void +foo(void) +{ + DTRACE_PROBE(test_prov, probe1); + DTRACE_PROBE(test_prov, probe2); +} + +int +main(int argc, char **argv) +{ + DTRACE_PROBE(test_prov, probe1); + DTRACE_PROBE(test_prov, probe2); + foo(); +} +EOF + +cat > prov.d <<EOF +provider test_prov { + probe probe1(); + probe probe2(); +}; +EOF + +cc -c test.c +if [ $? -ne 0 ]; then + print -u2 "failed to compile test.c" + exit 1 +fi +$dtrace -G -32 -s prov.d test.o +if [ $? -ne 0 ]; then + print -u2 "failed to create initial DOF" + exit 1 +fi +rm -f prov.o +$dtrace -G -32 -s prov.d test.o +if [ $? -ne 0 ]; then + print -u2 "failed to create final DOF" + exit 1 +fi +cc -o test test.o prov.o +if [ $? -ne 0 ]; then + print -u2 "failed to link final executable" + exit 1 +fi + +script() +{ + $dtrace -c ./test -qs /dev/stdin <<EOF + test_prov\$target::: + { + printf("%s:%s:%s\n", probemod, probefunc, probename); + } +EOF +} + +script +status=$? + +cd / +/usr/bin/rm -rf $DIR + +exit $status diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.static2.ksh.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.static2.ksh.out new file mode 100644 index 00000000..a559d97a --- /dev/null +++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.static2.ksh.out @@ -0,0 +1,5 @@ +test:main:probe1 +test:main:probe2 +test:foo:probe1 +test:foo:probe2 + diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.user.ksh b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.user.ksh new file mode 100755 index 00000000..d5d9fdc4 --- /dev/null +++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.user.ksh @@ -0,0 +1,96 @@ +#!/bin/ksh -p +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright 2006 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# +#ident "%Z%%M% %I% %E% SMI" + +if [ $# != 1 ]; then + echo expected one argument: '<'dtrace-path'>' + exit 2 +fi + +dtrace=$1 +DIR=/var/tmp/dtest.$$ + +mkdir $DIR +cd $DIR + +cat > prov.d <<EOF +provider test_prov { + probe go(); +}; +EOF + +$dtrace -h -s prov.d +if [ $? -ne 0 ]; then + print -u2 "failed to generate header file" + exit 1 +fi + +cat > test.c <<EOF +#include <sys/types.h> +#include "prov.h" + +int +main(int argc, char **argv) +{ + TEST_PROV_GO(); + + return (0); +} +EOF + +cc -c test.c +if [ $? -ne 0 ]; then + print -u2 "failed to compile test.c" + exit 1 +fi +$dtrace -G -32 -s prov.d test.o +if [ $? -ne 0 ]; then + print -u2 "failed to create DOF" + exit 1 +fi +cc -o test test.o prov.o +if [ $? -ne 0 ]; then + print -u2 "failed to link final executable" + exit 1 +fi + +script() { + $dtrace -c 'ppriv -e -s A=basic ./test' -Zqs /dev/stdin <<EOF + test_prov\$target::: + { + printf("%s:%s:%s\n", probemod, probefunc, probename); + } +EOF +} + +script +status=$? + +cd / +/usr/bin/rm -rf $DIR + +exit $status diff --git a/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.user.ksh.out b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.user.ksh.out new file mode 100644 index 00000000..b856cc59 --- /dev/null +++ b/src/VBox/ExtPacks/VBoxDTrace/onnv/cmd/dtrace/test/tst/common/usdt/tst.user.ksh.out @@ -0,0 +1,2 @@ +test:main:go + |