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 * $FreeBSD$ 26 * 27 */ 28 #include <sys/cdefs.h> 29 #include <sys/types.h> 30 #include <sys/param.h> 31 #include <sys/systm.h> 32 33 #include <sys/conf.h> 34 #include <sys/kernel.h> 35 #include <sys/module.h> 36 #include <sys/sdt.h> 37 #include <sys/sysctl.h> 38 #include <sys/vnode.h> 39 40 SDT_PROVIDER_DEFINE(test); 41 42 SDT_PROBE_DEFINE7(test, , , sdttest, "int", "int", "int", "int", "int", 43 "int", "int"); 44 45 /* 46 * These are variables that the DTrace test suite references in the 47 * Solaris kernel. We define them here so that the tests function 48 * unaltered. 49 */ 50 int kmem_flags; 51 52 typedef struct vnode vnode_t; 53 vnode_t dummy; 54 vnode_t *rootvp = &dummy; 55 56 /* 57 * Test SDT probes with more than 5 arguments. On amd64, such probes require 58 * special handling since only the first 5 arguments will be passed to 59 * dtrace_probe() in registers; the rest must be fetched off the stack. 60 */ 61 static int 62 dtrace_test_sdttest(SYSCTL_HANDLER_ARGS) 63 { 64 int val, error; 65 66 val = 0; 67 error = sysctl_handle_int(oidp, &val, 0, req); 68 if (error || req->newptr == NULL) 69 return (error); 70 else if (val == 0) 71 return (0); 72 73 SDT_PROBE7(test, , , sdttest, 1, 2, 3, 4, 5, 6, 7); 74 75 return (error); 76 } 77 78 static SYSCTL_NODE(_debug, OID_AUTO, dtracetest, CTLFLAG_RD, 0, ""); 79 80 SYSCTL_PROC(_debug_dtracetest, OID_AUTO, sdttest, CTLTYPE_INT | CTLFLAG_RW, 81 NULL, 0, dtrace_test_sdttest, "I", "Trigger the SDT test probe"); 82 83 static int 84 dtrace_test_modevent(module_t mod, int type, void *data) 85 { 86 int error = 0; 87 88 switch (type) { 89 case MOD_LOAD: 90 break; 91 92 case MOD_UNLOAD: 93 break; 94 95 case MOD_SHUTDOWN: 96 break; 97 98 default: 99 error = EOPNOTSUPP; 100 break; 101 102 } 103 return (error); 104 } 105 106 DEV_MODULE(dtrace_test, dtrace_test_modevent, NULL); 107 MODULE_VERSION(dtrace_test, 1); 108 MODULE_DEPEND(dtrace_test, dtraceall, 1, 1, 1); 109