/*-1* Copyright 2008 John Birrell <[email protected]>2*3* Redistribution and use in source and binary forms, with or without4* modification, are permitted provided that the following conditions5* are met:6* 1. Redistributions of source code must retain the above copyright7* notice, this list of conditions and the following disclaimer.8* 2. Redistributions in binary form must reproduce the above copyright9* notice, this list of conditions and the following disclaimer in the10* documentation and/or other materials provided with the distribution.11*12* THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND13* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE14* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE15* ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE16* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL17* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS18* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)19* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT20* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY21* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF22* SUCH DAMAGE.23*24*/2526#include <sys/types.h>27#include <sys/param.h>28#include <sys/systm.h>2930#include <sys/conf.h>31#include <sys/kernel.h>32#include <sys/module.h>33#include <sys/sdt.h>34#include <sys/sysctl.h>35#include <sys/vnode.h>3637SDT_PROVIDER_DEFINE(test);3839SDT_PROBE_DEFINE6(test, , , sdttest, "int", "int", "int", "int", "int",40"int");4142/*43* These are variables that the DTrace test suite references in the44* Solaris kernel. We define them here so that the tests function45* unaltered.46*/47int kmem_flags;4849typedef struct vnode vnode_t;50vnode_t dummy;51vnode_t *rootvp = &dummy;5253enum argtest {54ARGTEST_SDT,55ARGTEST_FBT,56};5758extern void fbttest(int, int, int, int, int, int, int, int, int, int);5960void __noinline61fbttest(int a, int b, int c, int d, int e, int f, int g, int h, int i, int j)62{63printf("fbttest(%d, %d, %d, %d, %d, %d, %d, %d, %d, %d)\n",64a, b, c, d, e, f, g, h, i, j);65}6667/*68* Test SDT probes with more than 5 arguments. On amd64, such probes require69* special handling since only the first 5 arguments will be passed to70* dtrace_probe() in registers; the rest must be fetched off the stack.71*/72static int73dtrace_test_argtest(SYSCTL_HANDLER_ARGS)74{75int val, error;7677val = 0;78error = sysctl_handle_int(oidp, &val, 0, req);79if (error || req->newptr == NULL)80return (error);81else if (val == 0)82return (0);8384if (arg2 == ARGTEST_SDT)85SDT_PROBE6(test, , , sdttest, 1, 2, 3, 4, 5, 6);86else87fbttest(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);8889return (error);90}9192static SYSCTL_NODE(_debug, OID_AUTO, dtracetest,93CTLFLAG_RD | CTLFLAG_MPSAFE, 0,94"");9596SYSCTL_PROC(_debug_dtracetest, OID_AUTO, sdttest,97CTLTYPE_INT | CTLFLAG_MPSAFE | CTLFLAG_RW, NULL, ARGTEST_SDT,98dtrace_test_argtest,99"I", "Trigger the SDT test probe");100SYSCTL_PROC(_debug_dtracetest, OID_AUTO, fbttest,101CTLTYPE_INT | CTLFLAG_MPSAFE | CTLFLAG_RW, NULL, ARGTEST_FBT,102dtrace_test_argtest,103"I", "Trigger the FBT test probe");104105static int106dtrace_test_modevent(module_t mod, int type, void *data)107{108int error = 0;109110switch (type) {111case MOD_LOAD:112break;113114case MOD_UNLOAD:115break;116117case MOD_SHUTDOWN:118break;119120default:121error = EOPNOTSUPP;122break;123124}125return (error);126}127128DEV_MODULE(dtrace_test, dtrace_test_modevent, NULL);129MODULE_VERSION(dtrace_test, 1);130131132