Computer Laboratory

tesla_dtrace.c
Go to the documentation of this file.
1 /*-
2  * Copyright (c) 2013 Robert N. M. Watson
3  * All rights reserved.
4  *
5  * This software was developed by SRI International and the University of
6  * Cambridge Computer Laboratory under DARPA/AFRL contract (FA8750-10-C-0237)
7  * ("CTSRD"), as part of the DARPA CRASH research programme.
8  *
9  * Redistribution and use in source and binary forms, with or without
10  * modification, are permitted provided that the following conditions
11  * are met:
12  * 1. Redistributions of source code must retain the above copyright
13  * notice, this list of conditions and the following disclaimer.
14  * 2. Redistributions in binary form must reproduce the above copyright
15  * notice, this list of conditions and the following disclaimer in the
16  * documentation and/or other materials provided with the distribution.
17  *
18  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
19  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21  * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
22  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28  * SUCH DAMAGE.
29  *
30  * $Id$
31  */
32 
33 #include "tesla_internal.h"
34 
35 #ifdef _KERNEL
36 #include "opt_kdtrace.h"
37 #include <sys/sdt.h>
38 
39 SDT_PROVIDER_DEFINE(tesla);
40 
41 SDT_PROBE_DEFINE2(tesla, automata, instance, create, create,
42  "struct tesla_class *", "struct tesla_instance *");
43 SDT_PROBE_DEFINE3(tesla, automata, event, transition, state-transition,
44  "struct tesla_class *", "struct tesla_instance *",
45  "struct tesla_transition *");
46 SDT_PROBE_DEFINE4(tesla, automata, instance, clone, clone,
47  "struct tesla_class *", "struct tesla_instance *",
48  "struct tesla_instance *", "struct tesla_transition *");
49 SDT_PROBE_DEFINE3(tesla, automata, fail, no_instance, no-instance-match,
50  "struct tesla_class *", "struct tesla_key *",
51  "struct tesla_transitions *");
52 SDT_PROBE_DEFINE3(tesla, automata, fail, bad_transition, bad-transition,
53  "struct tesla_class *", "struct tesla_instance *",
54  "struct tesla_transitions *");
55 SDT_PROBE_DEFINE3(tesla, automata, fail, other_err, other-error,
56  "struct tesla_class *", "int", "const char *");
57 SDT_PROBE_DEFINE2(tesla, automata, success, accept, accept,
58  "struct tesla_class *", "struct tesla_instance *");
59 SDT_PROBE_DEFINE3(tesla, automata, event, ignored, ignored-event,
60  "struct tesla_class *", "struct tesla_key *",
61  "struct tesla_transitions *");
62 
63 static void
64 new_instance(struct tesla_class *tcp, struct tesla_instance *tip)
65 {
66 
67  SDT_PROBE(tesla, automata, instance, create, tcp, tip, 0, 0, 0);
68 }
69 
70 static void
71 transition(struct tesla_class *tcp, struct tesla_instance *tip,
72  const struct tesla_transition *ttp)
73 {
74 
75  SDT_PROBE(tesla, automata, event, transition, tcp, tip, ttp, 0, 0);
76 }
77 
78 static void
79 clone(struct tesla_class *tcp, struct tesla_instance *origp,
80  struct tesla_instance *copyp, const struct tesla_transition *ttp)
81 {
82 
83  SDT_PROBE(tesla, automata, instance, clone, tcp, origp, copyp, ttp, 0);
84 }
85 
86 static void
87 no_instance(struct tesla_class *tcp, const struct tesla_key *tkp,
88  const struct tesla_transitions *ttp)
89 {
90 
91  SDT_PROBE(tesla, automata, fail, no_instance, tcp, tkp, ttp, 0, 0);
92 }
93 
94 static void
95 bad_transition(struct tesla_class *tcp, struct tesla_instance *tip,
96  const struct tesla_transitions *ttp)
97 {
98 
99  SDT_PROBE(tesla, automata, fail, bad_transition, tcp, tip, ttp, 0, 0);
100 }
101 
102 static void
103 err(struct tesla_class *tcp, int errno, const char *message)
104 {
105 
106  SDT_PROBE(tesla, automata, fail, other_err, tcp, errno, message, 0, 0);
107 }
108 
109 static void
110 accept(struct tesla_class *tcp, struct tesla_instance *tip)
111 {
112 
113  SDT_PROBE(tesla, automata, success, accept, tcp, tip, 0, 0, 0);
114 }
115 
116 static void
117 ignored(const struct tesla_class *tcp, const struct tesla_key *tkp,
118  const struct tesla_transitions *ttp)
119 {
120 
121  SDT_PROBE(tesla, automata, event, ignored, tcp, tkp, ttp, 0, 0);
122 }
123 
124 const struct tesla_event_handlers dtrace_handlers = {
125  .teh_init = new_instance,
126  .teh_transition = transition,
127  .teh_clone = clone,
128  .teh_fail_no_instance = no_instance,
129  .teh_bad_transition = bad_transition,
130  .teh_err = err,
131  .teh_accept = accept,
132  .teh_ignored = ignored,
133 };
134 
135 #endif /* _KERNEL */