dtrace_bsd.h revision 330897
1/*- 2 * SPDX-License-Identifier: BSD-2-Clause-FreeBSD 3 * 4 * Copyright (c) 2007-2008 John Birrell (jb@freebsd.org) 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions 9 * are met: 10 * 1. Redistributions of source code must retain the above copyright 11 * notice, this list of conditions and the following disclaimer. 12 * 2. Redistributions in binary form must reproduce the above copyright 13 * notice, this list of conditions and the following disclaimer in the 14 * documentation and/or other materials provided with the distribution. 15 * 16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 * SUCH DAMAGE. 27 * 28 * $FreeBSD: stable/11/sys/sys/dtrace_bsd.h 330897 2018-03-14 03:19:51Z eadler $ 29 * 30 * This file contains BSD shims for Sun's DTrace code. 31 */ 32 33#ifndef _SYS_DTRACE_BSD_H 34#define _SYS_DTRACE_BSD_H 35 36/* Forward definitions: */ 37struct mbuf; 38struct trapframe; 39struct thread; 40struct vattr; 41struct vnode; 42 43int dtrace_trap(struct trapframe *, u_int); 44 45/* 46 * The dtrace module handles traps that occur during a DTrace probe. 47 * This type definition is used in the trap handler to provide a 48 * hook for the dtrace module to register its handler with. 49 */ 50typedef int (*dtrace_trap_func_t)(struct trapframe *, u_int); 51extern dtrace_trap_func_t dtrace_trap_func; 52 53/* 54 * A hook which removes active FBT probes before executing the double fault 55 * handler. We want to ensure that DTrace doesn't trigger another trap, which 56 * would result in a reset. 57 */ 58typedef void (*dtrace_doubletrap_func_t)(void); 59extern dtrace_doubletrap_func_t dtrace_doubletrap_func; 60 61/* Pid provider hooks */ 62typedef int (*dtrace_pid_probe_ptr_t)(struct trapframe *); 63extern dtrace_pid_probe_ptr_t dtrace_pid_probe_ptr; 64typedef int (*dtrace_return_probe_ptr_t)(struct trapframe *); 65extern dtrace_return_probe_ptr_t dtrace_return_probe_ptr; 66 67/* Virtual time hook function type. */ 68typedef void (*dtrace_vtime_switch_func_t)(struct thread *); 69 70extern int dtrace_vtime_active; 71extern dtrace_vtime_switch_func_t dtrace_vtime_switch_func; 72 73/* The fasttrap module hooks into the fork, exit and exit. */ 74typedef void (*dtrace_fork_func_t)(struct proc *, struct proc *); 75typedef void (*dtrace_execexit_func_t)(struct proc *); 76 77/* Global variable in kern_fork.c */ 78extern dtrace_fork_func_t dtrace_fasttrap_fork; 79 80/* Global variable in kern_exec.c */ 81extern dtrace_execexit_func_t dtrace_fasttrap_exec; 82 83/* Global variable in kern_exit.c */ 84extern dtrace_execexit_func_t dtrace_fasttrap_exit; 85 86/* The dtmalloc provider hooks into malloc. */ 87typedef void (*dtrace_malloc_probe_func_t)(u_int32_t, uintptr_t arg0, 88 uintptr_t arg1, uintptr_t arg2, uintptr_t arg3, uintptr_t arg4); 89 90extern dtrace_malloc_probe_func_t dtrace_malloc_probe; 91 92/* dtnfsclient NFSv[34] access cache provider hooks. */ 93typedef void (*dtrace_nfsclient_accesscache_flush_probe_func_t)(uint32_t, 94 struct vnode *); 95extern dtrace_nfsclient_accesscache_flush_probe_func_t 96 dtrace_nfsclient_accesscache_flush_done_probe; 97extern dtrace_nfsclient_accesscache_flush_probe_func_t 98 dtrace_nfscl_accesscache_flush_done_probe; 99 100typedef void (*dtrace_nfsclient_accesscache_get_probe_func_t)(uint32_t, 101 struct vnode *, uid_t, uint32_t); 102extern dtrace_nfsclient_accesscache_get_probe_func_t 103 dtrace_nfsclient_accesscache_get_hit_probe, 104 dtrace_nfsclient_accesscache_get_miss_probe; 105extern dtrace_nfsclient_accesscache_get_probe_func_t 106 dtrace_nfscl_accesscache_get_hit_probe, 107 dtrace_nfscl_accesscache_get_miss_probe; 108 109typedef void (*dtrace_nfsclient_accesscache_load_probe_func_t)(uint32_t, 110 struct vnode *, uid_t, uint32_t, int); 111extern dtrace_nfsclient_accesscache_load_probe_func_t 112 dtrace_nfsclient_accesscache_load_done_probe; 113extern dtrace_nfsclient_accesscache_load_probe_func_t 114 dtrace_nfscl_accesscache_load_done_probe; 115 116/* dtnfsclient NFSv[234] attribute cache provider hooks. */ 117typedef void (*dtrace_nfsclient_attrcache_flush_probe_func_t)(uint32_t, 118 struct vnode *); 119extern dtrace_nfsclient_attrcache_flush_probe_func_t 120 dtrace_nfsclient_attrcache_flush_done_probe; 121extern dtrace_nfsclient_attrcache_flush_probe_func_t 122 dtrace_nfscl_attrcache_flush_done_probe; 123 124typedef void (*dtrace_nfsclient_attrcache_get_hit_probe_func_t)(uint32_t, 125 struct vnode *, struct vattr *); 126extern dtrace_nfsclient_attrcache_get_hit_probe_func_t 127 dtrace_nfsclient_attrcache_get_hit_probe; 128extern dtrace_nfsclient_attrcache_get_hit_probe_func_t 129 dtrace_nfscl_attrcache_get_hit_probe; 130 131typedef void (*dtrace_nfsclient_attrcache_get_miss_probe_func_t)(uint32_t, 132 struct vnode *); 133extern dtrace_nfsclient_attrcache_get_miss_probe_func_t 134 dtrace_nfsclient_attrcache_get_miss_probe; 135extern dtrace_nfsclient_attrcache_get_miss_probe_func_t 136 dtrace_nfscl_attrcache_get_miss_probe; 137 138typedef void (*dtrace_nfsclient_attrcache_load_probe_func_t)(uint32_t, 139 struct vnode *, struct vattr *, int); 140extern dtrace_nfsclient_attrcache_load_probe_func_t 141 dtrace_nfsclient_attrcache_load_done_probe; 142extern dtrace_nfsclient_attrcache_load_probe_func_t 143 dtrace_nfscl_attrcache_load_done_probe; 144 145/* dtnfsclient NFSv[234] RPC provider hooks. */ 146typedef void (*dtrace_nfsclient_nfs23_start_probe_func_t)(uint32_t, 147 struct vnode *, struct mbuf *, struct ucred *, int); 148extern dtrace_nfsclient_nfs23_start_probe_func_t 149 dtrace_nfsclient_nfs23_start_probe; 150extern dtrace_nfsclient_nfs23_start_probe_func_t 151 dtrace_nfscl_nfs234_start_probe; 152 153typedef void (*dtrace_nfsclient_nfs23_done_probe_func_t)(uint32_t, 154 struct vnode *, struct mbuf *, struct ucred *, int, int); 155extern dtrace_nfsclient_nfs23_done_probe_func_t 156 dtrace_nfsclient_nfs23_done_probe; 157extern dtrace_nfsclient_nfs23_done_probe_func_t 158 dtrace_nfscl_nfs234_done_probe; 159 160/* 161 * Functions which allow the dtrace module to check that the kernel 162 * hooks have been compiled with sufficient space for it's private 163 * structures. 164 */ 165size_t kdtrace_proc_size(void); 166size_t kdtrace_thread_size(void); 167 168/* 169 * OpenSolaris compatible time functions returning nanoseconds. 170 * On OpenSolaris these return hrtime_t which we define as uint64_t. 171 */ 172uint64_t dtrace_gethrtime(void); 173uint64_t dtrace_gethrestime(void); 174 175#endif /* _SYS_DTRACE_BSD_H */ 176