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 | ||
ab249ecf FD |
54 | enum lttng_ust_bytecode_node_type { |
55 | LTTNG_UST_BYTECODE_NODE_TYPE_FILTER, | |
56 | }; | |
57 | ||
58 | struct lttng_ust_bytecode_node { | |
59 | enum lttng_ust_bytecode_node_type type; | |
92495593 FD |
60 | struct cds_list_head node; |
61 | struct lttng_enabler *enabler; | |
ab249ecf FD |
62 | struct { |
63 | uint32_t len; | |
64 | uint32_t reloc_offset; | |
65 | uint64_t seqnum; | |
66 | char data[]; | |
67 | } bc; | |
92495593 FD |
68 | }; |
69 | ||
70 | struct lttng_ust_excluder_node { | |
71 | struct cds_list_head node; | |
72 | struct lttng_enabler *enabler; | |
73 | /* | |
74 | * struct lttng_ust_event_exclusion had variable sized array, | |
75 | * must be last field. | |
76 | */ | |
77 | struct lttng_ust_event_exclusion excluder; | |
78 | }; | |
79 | ||
d871c65b FD |
80 | static inline |
81 | struct lttng_enabler *lttng_event_enabler_as_enabler( | |
82 | struct lttng_event_enabler *event_enabler) | |
83 | { | |
84 | return &event_enabler->base; | |
85 | } | |
86 | ||
d8d2416d FD |
87 | static inline |
88 | struct lttng_enabler *lttng_event_notifier_enabler_as_enabler( | |
89 | struct lttng_event_notifier_enabler *event_notifier_enabler) | |
90 | { | |
91 | return &event_notifier_enabler->base; | |
92 | } | |
d871c65b FD |
93 | |
94 | /* | |
95 | * Allocate and initialize a `struct lttng_event_enabler` object. | |
96 | * | |
97 | * On success, returns a `struct lttng_event_enabler`, | |
98 | * On memory error, returns NULL. | |
99 | */ | |
100 | LTTNG_HIDDEN | |
101 | struct lttng_event_enabler *lttng_event_enabler_create( | |
102 | enum lttng_enabler_format_type format_type, | |
103 | struct lttng_ust_event *event_param, | |
104 | struct lttng_channel *chan); | |
105 | ||
106 | /* | |
107 | * Destroy a `struct lttng_event_enabler` object. | |
108 | */ | |
109 | LTTNG_HIDDEN | |
110 | void lttng_event_enabler_destroy(struct lttng_event_enabler *enabler); | |
111 | ||
112 | /* | |
113 | * Enable a `struct lttng_event_enabler` object and all events related to this | |
114 | * enabler. | |
115 | */ | |
116 | LTTNG_HIDDEN | |
117 | int lttng_event_enabler_enable(struct lttng_event_enabler *enabler); | |
118 | ||
119 | /* | |
120 | * Disable a `struct lttng_event_enabler` object and all events related to this | |
121 | * enabler. | |
122 | */ | |
123 | LTTNG_HIDDEN | |
124 | int lttng_event_enabler_disable(struct lttng_event_enabler *enabler); | |
125 | ||
126 | /* | |
127 | * Attach filter bytecode program to `struct lttng_event_enabler` and all | |
128 | * events related to this enabler. | |
129 | */ | |
130 | LTTNG_HIDDEN | |
a56fd376 FD |
131 | int lttng_event_enabler_attach_filter_bytecode( |
132 | struct lttng_event_enabler *enabler, | |
ab249ecf | 133 | struct lttng_ust_bytecode_node *bytecode); |
d871c65b FD |
134 | |
135 | /* | |
136 | * Attach an application context to an event enabler. | |
137 | * | |
138 | * Not implemented. | |
139 | */ | |
140 | LTTNG_HIDDEN | |
141 | int lttng_event_enabler_attach_context(struct lttng_event_enabler *enabler, | |
142 | struct lttng_ust_context *ctx); | |
143 | ||
144 | /* | |
145 | * Attach exclusion list to `struct lttng_event_enabler` and all | |
146 | * events related to this enabler. | |
147 | */ | |
148 | LTTNG_HIDDEN | |
149 | int lttng_event_enabler_attach_exclusion(struct lttng_event_enabler *enabler, | |
150 | struct lttng_ust_excluder_node *excluder); | |
151 | ||
152 | /* | |
153 | * Synchronize bytecodes for the enabler and the event. | |
154 | * | |
155 | * This function goes over all bytecode programs of the event enabler to ensure | |
156 | * each is linked to the provided event. | |
157 | */ | |
158 | LTTNG_HIDDEN | |
53b9d7db FD |
159 | void lttng_enabler_link_bytecode(const struct lttng_event_desc *event_desc, |
160 | struct lttng_ctx **ctx, | |
161 | struct cds_list_head *bytecode_runtime_head, | |
162 | struct lttng_enabler *enabler); | |
d871c65b | 163 | |
d8d2416d FD |
164 | /* |
165 | * Allocate and initialize a `struct lttng_event_notifier_group` object. | |
166 | * | |
167 | * On success, returns a `struct lttng_triggre_group`, | |
168 | * on memory error, returns NULL. | |
169 | */ | |
170 | LTTNG_HIDDEN | |
171 | struct lttng_event_notifier_group *lttng_event_notifier_group_create(void); | |
172 | ||
173 | /* | |
174 | * Destroy a `struct lttng_event_notifier_group` object. | |
175 | */ | |
176 | LTTNG_HIDDEN | |
177 | void lttng_event_notifier_group_destroy( | |
178 | struct lttng_event_notifier_group *event_notifier_group); | |
179 | ||
180 | /* | |
181 | * Allocate and initialize a `struct lttng_event_notifier_enabler` object. | |
182 | * | |
183 | * On success, returns a `struct lttng_event_notifier_enabler`, | |
184 | * On memory error, returns NULL. | |
185 | */ | |
186 | LTTNG_HIDDEN | |
187 | struct lttng_event_notifier_enabler *lttng_event_notifier_enabler_create( | |
188 | struct lttng_event_notifier_group *event_notifier_group, | |
189 | enum lttng_enabler_format_type format_type, | |
190 | struct lttng_ust_event_notifier *event_notifier_param); | |
191 | ||
192 | /* | |
193 | * Destroy a `struct lttng_event_notifier_enabler` object. | |
194 | */ | |
195 | LTTNG_HIDDEN | |
196 | void lttng_event_notifier_enabler_destroy( | |
197 | struct lttng_event_notifier_enabler *event_notifier_enabler); | |
198 | ||
199 | /* | |
200 | * Enable a `struct lttng_event_notifier_enabler` object and all event | |
201 | * notifiers related to this enabler. | |
202 | */ | |
203 | LTTNG_HIDDEN | |
204 | int lttng_event_notifier_enabler_enable( | |
205 | struct lttng_event_notifier_enabler *event_notifier_enabler); | |
206 | ||
207 | /* | |
208 | * Disable a `struct lttng_event_notifier_enabler` object and all event | |
209 | * notifiers related to this enabler. | |
210 | */ | |
211 | LTTNG_HIDDEN | |
212 | int lttng_event_notifier_enabler_disable( | |
213 | struct lttng_event_notifier_enabler *event_notifier_enabler); | |
214 | ||
215 | /* | |
216 | * Attach filter bytecode program to `struct lttng_event_notifier_enabler` and | |
217 | * all event notifiers related to this enabler. | |
218 | */ | |
219 | LTTNG_HIDDEN | |
a56fd376 | 220 | int lttng_event_notifier_enabler_attach_filter_bytecode( |
d8d2416d | 221 | struct lttng_event_notifier_enabler *event_notifier_enabler, |
ab249ecf | 222 | struct lttng_ust_bytecode_node *bytecode); |
d8d2416d FD |
223 | |
224 | /* | |
225 | * Attach exclusion list to `struct lttng_event_notifier_enabler` and all | |
226 | * event notifiers related to this enabler. | |
227 | */ | |
228 | LTTNG_HIDDEN | |
229 | int lttng_event_notifier_enabler_attach_exclusion( | |
230 | struct lttng_event_notifier_enabler *event_notifier_enabler, | |
231 | struct lttng_ust_excluder_node *excluder); | |
232 | ||
233 | LTTNG_HIDDEN | |
234 | void lttng_free_event_notifier_filter_runtime( | |
235 | struct lttng_event_notifier *event_notifier); | |
236 | ||
237 | /* | |
238 | * Connect the probe on all enablers matching this event description. | |
239 | * Called on library load. | |
240 | */ | |
241 | LTTNG_HIDDEN | |
242 | int lttng_fix_pending_event_notifiers(void); | |
243 | ||
d871c65b | 244 | #endif /* _LTTNG_UST_EVENTS_INTERNAL_H */ |