1 /*- 2 * Copyright 2008 John Birrell <jb@FreeBSD.org> 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * are met: 7 * 1. Redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer. 9 * 2. Redistributions in binary form must reproduce the above copyright 10 * notice, this list of conditions and the following disclaimer in the 11 * documentation and/or other materials provided with the distribution. 12 * 13 * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND 14 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 16 * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE 17 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 19 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 21 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 22 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 23 * SUCH DAMAGE. 24 * 25 */ 26 27 #include <sys/types.h> 28 #include <sys/param.h> 29 #include <sys/systm.h> 30 31 #include <sys/conf.h> 32 #include <sys/kernel.h> 33 #include <sys/module.h> 34 #include <sys/sdt.h> 35 #include <sys/sysctl.h> 36 #include <sys/vnode.h> 37 38 SDT_PROVIDER_DEFINE(test); 39 40 SDT_PROBE_DEFINE7(test, , , sdttest, "int", "int", "int", "int", "int", 41 "int", "int"); 42 43 /* 44 * These are variables that the DTrace test suite references in the 45 * Solaris kernel. We define them here so that the tests function 46 * unaltered. 47 */ 48 int kmem_flags; 49 50 typedef struct vnode vnode_t; 51 vnode_t dummy; 52 vnode_t *rootvp = &dummy; 53 54 /* 55 * Test SDT probes with more than 5 arguments. On amd64, such probes require 56 * special handling since only the first 5 arguments will be passed to 57 * dtrace_probe() in registers; the rest must be fetched off the stack. 58 */ 59 static int 60 dtrace_test_sdttest(SYSCTL_HANDLER_ARGS) 61 { 62 int val, error; 63 64 val = 0; 65 error = sysctl_handle_int(oidp, &val, 0, req); 66 if (error || req->newptr == NULL) 67 return (error); 68 else if (val == 0) 69 return (0); 70 71 SDT_PROBE7(test, , , sdttest, 1, 2, 3, 4, 5, 6, 7); 72 73 return (error); 74 } 75 76 static SYSCTL_NODE(_debug, OID_AUTO, dtracetest, 77 CTLFLAG_RD | CTLFLAG_MPSAFE, 0, 78 ""); 79 80 SYSCTL_PROC(_debug_dtracetest, OID_AUTO, sdttest, 81 CTLTYPE_INT | CTLFLAG_MPSAFE | CTLFLAG_RW, NULL, 0, dtrace_test_sdttest, 82 "I", "Trigger the SDT test probe"); 83 84 static int 85 dtrace_test_modevent(module_t mod, int type, void *data) 86 { 87 int error = 0; 88 89 switch (type) { 90 case MOD_LOAD: 91 break; 92 93 case MOD_UNLOAD: 94 break; 95 96 case MOD_SHUTDOWN: 97 break; 98 99 default: 100 error = EOPNOTSUPP; 101 break; 102 103 } 104 return (error); 105 } 106 107 DEV_MODULE(dtrace_test, dtrace_test_modevent, NULL); 108 MODULE_VERSION(dtrace_test, 1); 109 MODULE_DEPEND(dtrace_test, dtraceall, 1, 1, 1); 110