Commit | Line | Data |
---|---|---|
d871c65b FD |
1 | #ifndef _LTTNG_UST_EVENTS_INTERNAL_H |
2 | #define _LTTNG_UST_EVENTS_INTERNAL_H | |
3 | ||
4 | /* | |
5 | * ust-events-internal.h | |
6 | * | |
7 | * Copyright 2019 (c) - Francis Deslauriers <francis.deslauriers@efficios.com> | |
8 | * | |
9 | * Permission is hereby granted, free of charge, to any person obtaining a copy | |
10 | * of this software and associated documentation files (the "Software"), to deal | |
11 | * in the Software without restriction, including without limitation the rights | |
12 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
13 | * copies of the Software, and to permit persons to whom the Software is | |
14 | * furnished to do so, subject to the following conditions: | |
15 | * | |
16 | * The above copyright notice and this permission notice shall be included in | |
17 | * all copies or substantial portions of the Software. | |
18 | * | |
19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | |
22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |
23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | |
24 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | |
25 | * SOFTWARE. | |
26 | */ | |
27 | ||
28 | #include <stdint.h> | |
29 | ||
30 | #include <urcu/list.h> | |
31 | #include <urcu/hlist.h> | |
32 | ||
33 | #include <helper.h> | |
34 | #include <lttng/ust-events.h> | |
35 | ||
36 | struct lttng_event_enabler { | |
37 | struct lttng_enabler base; | |
38 | struct cds_list_head node; /* per-session list of enablers */ | |
39 | struct lttng_channel *chan; | |
40 | /* | |
41 | * Unused, but kept around to make it explicit that the tracer can do | |
42 | * it. | |
43 | */ | |
44 | struct lttng_ctx *ctx; | |
45 | }; | |
46 | ||
d8d2416d FD |
47 | struct lttng_event_notifier_enabler { |
48 | struct lttng_enabler base; | |
49 | struct cds_list_head node; /* per-app list of event notifier enablers */ | |
50 | struct lttng_event_notifier_group *group; /* weak ref */ | |
51 | uint64_t user_token; /* User-provided token */ | |
52 | }; | |
53 | ||
92495593 FD |
54 | struct lttng_ust_filter_bytecode_node { |
55 | struct cds_list_head node; | |
56 | struct lttng_enabler *enabler; | |
57 | /* | |
58 | * struct lttng_ust_filter_bytecode has var. sized array, must | |
59 | * be last field. | |
60 | */ | |
61 | struct lttng_ust_filter_bytecode bc; | |
62 | }; | |
63 | ||
64 | struct lttng_ust_excluder_node { | |
65 | struct cds_list_head node; | |
66 | struct lttng_enabler *enabler; | |
67 | /* | |
68 | * struct lttng_ust_event_exclusion had variable sized array, | |
69 | * must be last field. | |
70 | */ | |
71 | struct lttng_ust_event_exclusion excluder; | |
72 | }; | |
73 | ||
d871c65b FD |
74 | static inline |
75 | struct lttng_enabler *lttng_event_enabler_as_enabler( | |
76 | struct lttng_event_enabler *event_enabler) | |
77 | { | |
78 | return &event_enabler->base; | |
79 | } | |
80 | ||
d8d2416d FD |
81 | static inline |
82 | struct lttng_enabler *lttng_event_notifier_enabler_as_enabler( | |
83 | struct lttng_event_notifier_enabler *event_notifier_enabler) | |
84 | { | |
85 | return &event_notifier_enabler->base; | |
86 | } | |
d871c65b FD |
87 | |
88 | /* | |
89 | * Allocate and initialize a `struct lttng_event_enabler` object. | |
90 | * | |
91 | * On success, returns a `struct lttng_event_enabler`, | |
92 | * On memory error, returns NULL. | |
93 | */ | |
94 | LTTNG_HIDDEN | |
95 | struct lttng_event_enabler *lttng_event_enabler_create( | |
96 | enum lttng_enabler_format_type format_type, | |
97 | struct lttng_ust_event *event_param, | |
98 | struct lttng_channel *chan); | |
99 | ||
100 | /* | |
101 | * Destroy a `struct lttng_event_enabler` object. | |
102 | */ | |
103 | LTTNG_HIDDEN | |
104 | void lttng_event_enabler_destroy(struct lttng_event_enabler *enabler); | |
105 | ||
106 | /* | |
107 | * Enable a `struct lttng_event_enabler` object and all events related to this | |
108 | * enabler. | |
109 | */ | |
110 | LTTNG_HIDDEN | |
111 | int lttng_event_enabler_enable(struct lttng_event_enabler *enabler); | |
112 | ||
113 | /* | |
114 | * Disable a `struct lttng_event_enabler` object and all events related to this | |
115 | * enabler. | |
116 | */ | |
117 | LTTNG_HIDDEN | |
118 | int lttng_event_enabler_disable(struct lttng_event_enabler *enabler); | |
119 | ||
120 | /* | |
121 | * Attach filter bytecode program to `struct lttng_event_enabler` and all | |
122 | * events related to this enabler. | |
123 | */ | |
124 | LTTNG_HIDDEN | |
125 | int lttng_event_enabler_attach_bytecode(struct lttng_event_enabler *enabler, | |
126 | struct lttng_ust_filter_bytecode_node *bytecode); | |
127 | ||
128 | /* | |
129 | * Attach an application context to an event enabler. | |
130 | * | |
131 | * Not implemented. | |
132 | */ | |
133 | LTTNG_HIDDEN | |
134 | int lttng_event_enabler_attach_context(struct lttng_event_enabler *enabler, | |
135 | struct lttng_ust_context *ctx); | |
136 | ||
137 | /* | |
138 | * Attach exclusion list to `struct lttng_event_enabler` and all | |
139 | * events related to this enabler. | |
140 | */ | |
141 | LTTNG_HIDDEN | |
142 | int lttng_event_enabler_attach_exclusion(struct lttng_event_enabler *enabler, | |
143 | struct lttng_ust_excluder_node *excluder); | |
144 | ||
145 | /* | |
146 | * Synchronize bytecodes for the enabler and the event. | |
147 | * | |
148 | * This function goes over all bytecode programs of the event enabler to ensure | |
149 | * each is linked to the provided event. | |
150 | */ | |
151 | LTTNG_HIDDEN | |
53b9d7db FD |
152 | void lttng_enabler_link_bytecode(const struct lttng_event_desc *event_desc, |
153 | struct lttng_ctx **ctx, | |
154 | struct cds_list_head *bytecode_runtime_head, | |
155 | struct lttng_enabler *enabler); | |
d871c65b | 156 | |
d8d2416d FD |
157 | /* |
158 | * Allocate and initialize a `struct lttng_event_notifier_group` object. | |
159 | * | |
160 | * On success, returns a `struct lttng_triggre_group`, | |
161 | * on memory error, returns NULL. | |
162 | */ | |
163 | LTTNG_HIDDEN | |
164 | struct lttng_event_notifier_group *lttng_event_notifier_group_create(void); | |
165 | ||
166 | /* | |
167 | * Destroy a `struct lttng_event_notifier_group` object. | |
168 | */ | |
169 | LTTNG_HIDDEN | |
170 | void lttng_event_notifier_group_destroy( | |
171 | struct lttng_event_notifier_group *event_notifier_group); | |
172 | ||
173 | /* | |
174 | * Allocate and initialize a `struct lttng_event_notifier_enabler` object. | |
175 | * | |
176 | * On success, returns a `struct lttng_event_notifier_enabler`, | |
177 | * On memory error, returns NULL. | |
178 | */ | |
179 | LTTNG_HIDDEN | |
180 | struct lttng_event_notifier_enabler *lttng_event_notifier_enabler_create( | |
181 | struct lttng_event_notifier_group *event_notifier_group, | |
182 | enum lttng_enabler_format_type format_type, | |
183 | struct lttng_ust_event_notifier *event_notifier_param); | |
184 | ||
185 | /* | |
186 | * Destroy a `struct lttng_event_notifier_enabler` object. | |
187 | */ | |
188 | LTTNG_HIDDEN | |
189 | void lttng_event_notifier_enabler_destroy( | |
190 | struct lttng_event_notifier_enabler *event_notifier_enabler); | |
191 | ||
192 | /* | |
193 | * Enable a `struct lttng_event_notifier_enabler` object and all event | |
194 | * notifiers related to this enabler. | |
195 | */ | |
196 | LTTNG_HIDDEN | |
197 | int lttng_event_notifier_enabler_enable( | |
198 | struct lttng_event_notifier_enabler *event_notifier_enabler); | |
199 | ||
200 | /* | |
201 | * Disable a `struct lttng_event_notifier_enabler` object and all event | |
202 | * notifiers related to this enabler. | |
203 | */ | |
204 | LTTNG_HIDDEN | |
205 | int lttng_event_notifier_enabler_disable( | |
206 | struct lttng_event_notifier_enabler *event_notifier_enabler); | |
207 | ||
208 | /* | |
209 | * Attach filter bytecode program to `struct lttng_event_notifier_enabler` and | |
210 | * all event notifiers related to this enabler. | |
211 | */ | |
212 | LTTNG_HIDDEN | |
213 | int lttng_event_notifier_enabler_attach_bytecode( | |
214 | struct lttng_event_notifier_enabler *event_notifier_enabler, | |
215 | struct lttng_ust_filter_bytecode_node *bytecode); | |
216 | ||
217 | /* | |
218 | * Attach exclusion list to `struct lttng_event_notifier_enabler` and all | |
219 | * event notifiers related to this enabler. | |
220 | */ | |
221 | LTTNG_HIDDEN | |
222 | int lttng_event_notifier_enabler_attach_exclusion( | |
223 | struct lttng_event_notifier_enabler *event_notifier_enabler, | |
224 | struct lttng_ust_excluder_node *excluder); | |
225 | ||
226 | LTTNG_HIDDEN | |
227 | void lttng_free_event_notifier_filter_runtime( | |
228 | struct lttng_event_notifier *event_notifier); | |
229 | ||
230 | /* | |
231 | * Connect the probe on all enablers matching this event description. | |
232 | * Called on library load. | |
233 | */ | |
234 | LTTNG_HIDDEN | |
235 | int lttng_fix_pending_event_notifiers(void); | |
236 | ||
d871c65b | 237 | #endif /* _LTTNG_UST_EVENTS_INTERNAL_H */ |