kern_sdt.c revision 1.1.2.2 1 1.1.2.2 yamt /* $NetBSD: kern_sdt.c,v 1.1.2.2 2010/03/11 15:04:17 yamt Exp $ */
2 1.1.2.2 yamt
3 1.1.2.2 yamt /*-
4 1.1.2.2 yamt * Copyright (c) 2010 The NetBSD Foundation, Inc.
5 1.1.2.2 yamt * All rights reserved.
6 1.1.2.2 yamt *
7 1.1.2.2 yamt * This code is derived from software contributed to The NetBSD Foundation
8 1.1.2.2 yamt * by CoyotePoint Systems, Inc. It was developed under contract to
9 1.1.2.2 yamt * CoyotePoint by Darran Hunt.
10 1.1.2.2 yamt *
11 1.1.2.2 yamt * Redistribution and use in source and binary forms, with or without
12 1.1.2.2 yamt * modification, are permitted provided that the following conditions
13 1.1.2.2 yamt * are met:
14 1.1.2.2 yamt * 1. Redistributions of source code must retain the above copyright
15 1.1.2.2 yamt * notice, this list of conditions and the following disclaimer.
16 1.1.2.2 yamt * 2. Redistributions in binary form must reproduce the above copyright
17 1.1.2.2 yamt * notice, this list of conditions and the following disclaimer in the
18 1.1.2.2 yamt * documentation and/or other materials provided with the distribution.
19 1.1.2.2 yamt *
20 1.1.2.2 yamt *
21 1.1.2.2 yamt * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
22 1.1.2.2 yamt * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
23 1.1.2.2 yamt * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
24 1.1.2.2 yamt * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
25 1.1.2.2 yamt * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26 1.1.2.2 yamt * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27 1.1.2.2 yamt * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28 1.1.2.2 yamt * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29 1.1.2.2 yamt * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30 1.1.2.2 yamt * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31 1.1.2.2 yamt * POSSIBILITY OF SUCH DAMAGE.
32 1.1.2.2 yamt */
33 1.1.2.2 yamt
34 1.1.2.2 yamt /*-
35 1.1.2.2 yamt * Copyright 2006-2008 John Birrell <jb (at) FreeBSD.org>
36 1.1.2.2 yamt *
37 1.1.2.2 yamt * Redistribution and use in source and binary forms, with or without
38 1.1.2.2 yamt * modification, are permitted provided that the following conditions
39 1.1.2.2 yamt * are met:
40 1.1.2.2 yamt * 1. Redistributions of source code must retain the above copyright
41 1.1.2.2 yamt * notice, this list of conditions and the following disclaimer.
42 1.1.2.2 yamt * 2. Redistributions in binary form must reproduce the above copyright
43 1.1.2.2 yamt * notice, this list of conditions and the following disclaimer in the
44 1.1.2.2 yamt * documentation and/or other materials provided with the distribution.
45 1.1.2.2 yamt *
46 1.1.2.2 yamt * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
47 1.1.2.2 yamt * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
48 1.1.2.2 yamt * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
49 1.1.2.2 yamt * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
50 1.1.2.2 yamt * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
51 1.1.2.2 yamt * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
52 1.1.2.2 yamt * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
53 1.1.2.2 yamt * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
54 1.1.2.2 yamt * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
55 1.1.2.2 yamt * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
56 1.1.2.2 yamt * SUCH DAMAGE.
57 1.1.2.2 yamt *
58 1.1.2.2 yamt * $FreeBSD: src/sys/kern/kern_sdt.c,v 1.1.4.1 2009/08/03 08:13:06 kensmith Exp $
59 1.1.2.2 yamt *
60 1.1.2.2 yamt * Backend for the Statically Defined Tracing (SDT) kernel support. This is
61 1.1.2.2 yamt * required to allow a module to load even though DTrace kernel support may
62 1.1.2.2 yamt * not be present. A module may be built with SDT probes in it.
63 1.1.2.2 yamt *
64 1.1.2.2 yamt */
65 1.1.2.2 yamt
66 1.1.2.2 yamt #include <sys/cdefs.h>
67 1.1.2.2 yamt #include <sys/param.h>
68 1.1.2.2 yamt #include <sys/systm.h>
69 1.1.2.2 yamt #include <sys/sdt.h>
70 1.1.2.2 yamt
71 1.1.2.2 yamt void sdt_probe_stub(u_int32_t, uintptr_t, uintptr_t,
72 1.1.2.2 yamt uintptr_t, uintptr_t, uintptr_t);
73 1.1.2.2 yamt
74 1.1.2.2 yamt /*
75 1.1.2.2 yamt * Hook for the DTrace probe function. The 'sdt' provider will set this
76 1.1.2.2 yamt * to dtrace_probe when it loads.
77 1.1.2.2 yamt */
78 1.1.2.2 yamt sdt_probe_func_t sdt_probe_func = sdt_probe_stub;
79 1.1.2.2 yamt
80 1.1.2.2 yamt /*
81 1.1.2.2 yamt * This is a stub for probe calls in case kernel DTrace support isn't
82 1.1.2.2 yamt * compiled in. It should never get called because there is no DTrace
83 1.1.2.2 yamt * support to enable it.
84 1.1.2.2 yamt */
85 1.1.2.2 yamt void
86 1.1.2.2 yamt sdt_probe_stub(u_int32_t id, uintptr_t arg0, uintptr_t arg1,
87 1.1.2.2 yamt uintptr_t arg2, uintptr_t arg3, uintptr_t arg4)
88 1.1.2.2 yamt {
89 1.1.2.2 yamt printf("%s: XXX should not be called\n", __func__);
90 1.1.2.2 yamt }
91 1.1.2.2 yamt
92 1.1.2.2 yamt /*
93 1.1.2.2 yamt * initialize the SDT dtrace probe function
94 1.1.2.2 yamt */
95 1.1.2.2 yamt void
96 1.1.2.2 yamt sdt_init(void *dtrace_probe)
97 1.1.2.2 yamt {
98 1.1.2.2 yamt
99 1.1.2.2 yamt sdt_probe_func = dtrace_probe;
100 1.1.2.2 yamt }
101 1.1.2.2 yamt
102 1.1.2.2 yamt /*
103 1.1.2.2 yamt * Disable the SDT dtrace probe function
104 1.1.2.2 yamt */
105 1.1.2.2 yamt void
106 1.1.2.2 yamt sdt_exit(void)
107 1.1.2.2 yamt {
108 1.1.2.2 yamt
109 1.1.2.2 yamt sdt_probe_func = sdt_probe_stub;
110 1.1.2.2 yamt }
111