]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/sys/dtrace_bsd.h
Update tcpdump to 4.9.2
[FreeBSD/FreeBSD.git] / sys / sys / dtrace_bsd.h
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$
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: */
37 struct mbuf;
38 struct trapframe;
39 struct thread;
40 struct vattr;
41 struct vnode;
42 struct reg;
43
44 int dtrace_trap(struct trapframe *, u_int);
45
46 /*
47  * The dtrace module handles traps that occur during a DTrace probe.
48  * This type definition is used in the trap handler to provide a
49  * hook for the dtrace module to register its handler with.
50  */
51 typedef int (*dtrace_trap_func_t)(struct trapframe *, u_int);
52 extern dtrace_trap_func_t       dtrace_trap_func;
53
54 /*
55  * A hook which removes active FBT probes before executing the double fault
56  * handler. We want to ensure that DTrace doesn't trigger another trap, which
57  * would result in a reset.
58  */
59 typedef void (*dtrace_doubletrap_func_t)(void);
60 extern  dtrace_doubletrap_func_t        dtrace_doubletrap_func;
61
62 /* Pid provider hooks */
63 typedef int (*dtrace_pid_probe_ptr_t)(struct reg *);
64 extern  dtrace_pid_probe_ptr_t  dtrace_pid_probe_ptr;
65 typedef int (*dtrace_return_probe_ptr_t)(struct reg *);
66 extern  dtrace_return_probe_ptr_t       dtrace_return_probe_ptr;
67
68 /* Virtual time hook function type. */
69 typedef void (*dtrace_vtime_switch_func_t)(struct thread *);
70
71 extern int                      dtrace_vtime_active;
72 extern dtrace_vtime_switch_func_t       dtrace_vtime_switch_func;
73
74 /* The fasttrap module hooks into the fork, exit and exit. */
75 typedef void (*dtrace_fork_func_t)(struct proc *, struct proc *);
76 typedef void (*dtrace_execexit_func_t)(struct proc *);
77
78 /* Global variable in kern_fork.c */
79 extern dtrace_fork_func_t       dtrace_fasttrap_fork;
80
81 /* Global variable in kern_exec.c */
82 extern dtrace_execexit_func_t   dtrace_fasttrap_exec;
83
84 /* Global variable in kern_exit.c */
85 extern dtrace_execexit_func_t   dtrace_fasttrap_exit;
86
87 /* The dtmalloc provider hooks into malloc. */
88 typedef void (*dtrace_malloc_probe_func_t)(u_int32_t, uintptr_t arg0,
89     uintptr_t arg1, uintptr_t arg2, uintptr_t arg3, uintptr_t arg4);
90
91 extern dtrace_malloc_probe_func_t   dtrace_malloc_probe;
92
93 /* dtnfsclient NFSv[34] access cache provider hooks. */
94 typedef void (*dtrace_nfsclient_accesscache_flush_probe_func_t)(uint32_t,
95     struct vnode *);
96 extern dtrace_nfsclient_accesscache_flush_probe_func_t
97     dtrace_nfsclient_accesscache_flush_done_probe;
98 extern dtrace_nfsclient_accesscache_flush_probe_func_t
99     dtrace_nfscl_accesscache_flush_done_probe;
100
101 typedef void (*dtrace_nfsclient_accesscache_get_probe_func_t)(uint32_t,
102     struct vnode *, uid_t, uint32_t);
103 extern dtrace_nfsclient_accesscache_get_probe_func_t
104     dtrace_nfsclient_accesscache_get_hit_probe,
105     dtrace_nfsclient_accesscache_get_miss_probe;
106 extern dtrace_nfsclient_accesscache_get_probe_func_t
107     dtrace_nfscl_accesscache_get_hit_probe,
108     dtrace_nfscl_accesscache_get_miss_probe;
109
110 typedef void (*dtrace_nfsclient_accesscache_load_probe_func_t)(uint32_t,
111     struct vnode *, uid_t, uint32_t, int);
112 extern dtrace_nfsclient_accesscache_load_probe_func_t
113     dtrace_nfsclient_accesscache_load_done_probe;
114 extern dtrace_nfsclient_accesscache_load_probe_func_t
115     dtrace_nfscl_accesscache_load_done_probe;
116
117 /* dtnfsclient NFSv[234] attribute cache provider hooks. */
118 typedef void (*dtrace_nfsclient_attrcache_flush_probe_func_t)(uint32_t,
119     struct vnode *);
120 extern dtrace_nfsclient_attrcache_flush_probe_func_t
121     dtrace_nfsclient_attrcache_flush_done_probe;
122 extern dtrace_nfsclient_attrcache_flush_probe_func_t
123     dtrace_nfscl_attrcache_flush_done_probe;
124
125 typedef void (*dtrace_nfsclient_attrcache_get_hit_probe_func_t)(uint32_t,
126     struct vnode *, struct vattr *);
127 extern dtrace_nfsclient_attrcache_get_hit_probe_func_t
128     dtrace_nfsclient_attrcache_get_hit_probe;
129 extern dtrace_nfsclient_attrcache_get_hit_probe_func_t
130     dtrace_nfscl_attrcache_get_hit_probe;
131
132 typedef void (*dtrace_nfsclient_attrcache_get_miss_probe_func_t)(uint32_t,
133     struct vnode *);
134 extern dtrace_nfsclient_attrcache_get_miss_probe_func_t
135     dtrace_nfsclient_attrcache_get_miss_probe;
136 extern dtrace_nfsclient_attrcache_get_miss_probe_func_t
137     dtrace_nfscl_attrcache_get_miss_probe;
138
139 typedef void (*dtrace_nfsclient_attrcache_load_probe_func_t)(uint32_t,
140     struct vnode *, struct vattr *, int);
141 extern dtrace_nfsclient_attrcache_load_probe_func_t
142     dtrace_nfsclient_attrcache_load_done_probe;
143 extern dtrace_nfsclient_attrcache_load_probe_func_t
144     dtrace_nfscl_attrcache_load_done_probe;
145
146 /* dtnfsclient NFSv[234] RPC provider hooks. */
147 typedef void (*dtrace_nfsclient_nfs23_start_probe_func_t)(uint32_t,
148     struct vnode *, struct mbuf *, struct ucred *, int);
149 extern dtrace_nfsclient_nfs23_start_probe_func_t
150     dtrace_nfsclient_nfs23_start_probe;
151 extern dtrace_nfsclient_nfs23_start_probe_func_t
152     dtrace_nfscl_nfs234_start_probe;
153
154 typedef void (*dtrace_nfsclient_nfs23_done_probe_func_t)(uint32_t,
155     struct vnode *, struct mbuf *, struct ucred *, int, int);
156 extern dtrace_nfsclient_nfs23_done_probe_func_t
157     dtrace_nfsclient_nfs23_done_probe;
158 extern dtrace_nfsclient_nfs23_done_probe_func_t
159     dtrace_nfscl_nfs234_done_probe;
160
161 /*
162  * Functions which allow the dtrace module to check that the kernel 
163  * hooks have been compiled with sufficient space for it's private
164  * structures.
165  */
166 size_t  kdtrace_proc_size(void);
167 size_t  kdtrace_thread_size(void);
168
169 /*
170  * OpenSolaris compatible time functions returning nanoseconds.
171  * On OpenSolaris these return hrtime_t which we define as uint64_t.
172  */
173 uint64_t        dtrace_gethrtime(void);
174 uint64_t        dtrace_gethrestime(void);
175
176 #endif /* _SYS_DTRACE_BSD_H */