diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/fbtprovider/tst.argtest.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/fbtprovider/tst.argtest.ksh new file mode 100644 index 000000000000..dc3641b01101 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/fbtprovider/tst.argtest.ksh @@ -0,0 +1,34 @@ +# +# 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 (c) 2024 Mark Johnston +# + +dtrace=$1 + +$dtrace -q -s /dev/stdin -c "sysctl debug.dtracetest.fbttest=1" <<__EOF__ +fbt:dtrace_test:fbttest:entry +{ + printf("%d %d %d %d %d %d %d %d %d %d\n", args[0], args[1], args[2], + args[3], args[4], args[5], args[6], args[7], args[8], args[9]); +} +__EOF__ diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/fbtprovider/tst.argtest.ksh.out b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/fbtprovider/tst.argtest.ksh.out new file mode 100644 index 000000000000..301e154b3339 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/fbtprovider/tst.argtest.ksh.out @@ -0,0 +1,3 @@ +debug.dtracetest.fbttest: 0 -> 0 +1 2 3 4 5 6 7 8 9 10 + diff --git a/cddl/usr.sbin/dtrace/tests/common/fbtprovider/Makefile b/cddl/usr.sbin/dtrace/tests/common/fbtprovider/Makefile index 3ca540fd77f1..0dee8f807065 100644 --- a/cddl/usr.sbin/dtrace/tests/common/fbtprovider/Makefile +++ b/cddl/usr.sbin/dtrace/tests/common/fbtprovider/Makefile @@ -1,26 +1,28 @@ # # This Makefile was generated by $srcdir/cddl/usr.sbin/dtrace/tests/tools/genmakefiles.sh. # PACKAGE= tests ${PACKAGE}FILES= \ err.D_PDESC_ZERO.notreturn.d \ + tst.argtest.ksh \ + tst.argtest.ksh.out \ tst.basic.d \ tst.functionentry.d \ tst.functionreturnvalue.d \ tst.ioctlargs.d \ tst.offset.d \ tst.offsetzero.d \ tst.return.d \ tst.return0.d \ tst.tailcall.d \ TESTEXES= \ CFILES= \ .include "../../dtrace.test.mk" diff --git a/sys/cddl/dev/dtrace/dtrace_test.c b/sys/cddl/dev/dtrace/dtrace_test.c index e36debc27a49..a61958d9184a 100644 --- a/sys/cddl/dev/dtrace/dtrace_test.c +++ b/sys/cddl/dev/dtrace/dtrace_test.c @@ -1,108 +1,130 @@ /*- * Copyright 2008 John Birrell * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * */ #include #include #include #include #include #include #include #include #include SDT_PROVIDER_DEFINE(test); SDT_PROBE_DEFINE6(test, , , sdttest, "int", "int", "int", "int", "int", "int"); /* * These are variables that the DTrace test suite references in the * Solaris kernel. We define them here so that the tests function * unaltered. */ int kmem_flags; typedef struct vnode vnode_t; vnode_t dummy; vnode_t *rootvp = &dummy; +enum argtest { + ARGTEST_SDT, + ARGTEST_FBT, +}; + +extern void fbttest(int, int, int, int, int, int, int, int, int, int); + +void __noinline +fbttest(int a, int b, int c, int d, int e, int f, int g, int h, int i, int j) +{ + printf("fbttest(%d, %d, %d, %d, %d, %d, %d, %d, %d, %d)\n", + a, b, c, d, e, f, g, h, i, j); +} + /* * Test SDT probes with more than 5 arguments. On amd64, such probes require * special handling since only the first 5 arguments will be passed to * dtrace_probe() in registers; the rest must be fetched off the stack. */ static int -dtrace_test_sdttest(SYSCTL_HANDLER_ARGS) +dtrace_test_argtest(SYSCTL_HANDLER_ARGS) { int val, error; val = 0; error = sysctl_handle_int(oidp, &val, 0, req); if (error || req->newptr == NULL) return (error); else if (val == 0) return (0); - SDT_PROBE6(test, , , sdttest, 1, 2, 3, 4, 5, 6); + if (arg2 == ARGTEST_SDT) + SDT_PROBE6(test, , , sdttest, 1, 2, 3, 4, 5, 6); + else + fbttest(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); return (error); } static SYSCTL_NODE(_debug, OID_AUTO, dtracetest, CTLFLAG_RD | CTLFLAG_MPSAFE, 0, ""); SYSCTL_PROC(_debug_dtracetest, OID_AUTO, sdttest, - CTLTYPE_INT | CTLFLAG_MPSAFE | CTLFLAG_RW, NULL, 0, dtrace_test_sdttest, + CTLTYPE_INT | CTLFLAG_MPSAFE | CTLFLAG_RW, NULL, ARGTEST_SDT, + dtrace_test_argtest, "I", "Trigger the SDT test probe"); +SYSCTL_PROC(_debug_dtracetest, OID_AUTO, fbttest, + CTLTYPE_INT | CTLFLAG_MPSAFE | CTLFLAG_RW, NULL, ARGTEST_FBT, + dtrace_test_argtest, + "I", "Trigger the FBT test probe"); static int dtrace_test_modevent(module_t mod, int type, void *data) { int error = 0; switch (type) { case MOD_LOAD: break; case MOD_UNLOAD: break; case MOD_SHUTDOWN: break; default: error = EOPNOTSUPP; break; } return (error); } DEV_MODULE(dtrace_test, dtrace_test_modevent, NULL); MODULE_VERSION(dtrace_test, 1);