Commit | Line | Data |
---|---|---|
d871c65b | 1 | /* |
c0c0989a | 2 | * SPDX-License-Identifier: MIT |
d871c65b | 3 | * |
c0c0989a | 4 | * Copyright 2019 (c) Francis Deslauriers <francis.deslauriers@efficios.com> |
d871c65b FD |
5 | */ |
6 | ||
c0c0989a MJ |
7 | #ifndef _LTTNG_UST_EVENTS_INTERNAL_H |
8 | #define _LTTNG_UST_EVENTS_INTERNAL_H | |
9 | ||
d871c65b FD |
10 | #include <stdint.h> |
11 | ||
12 | #include <urcu/list.h> | |
13 | #include <urcu/hlist.h> | |
14 | ||
15 | #include <helper.h> | |
16 | #include <lttng/ust-events.h> | |
17 | ||
bb84a1ec MD |
18 | /* |
19 | * Enabler field, within whatever object is enabling an event. Target of | |
20 | * backward reference. | |
21 | */ | |
22 | struct lttng_enabler { | |
23 | enum lttng_enabler_format_type format_type; | |
24 | ||
25 | /* head list of struct lttng_ust_filter_bytecode_node */ | |
26 | struct cds_list_head filter_bytecode_head; | |
27 | /* head list of struct lttng_ust_excluder_node */ | |
28 | struct cds_list_head excluder_head; | |
29 | ||
30 | struct lttng_ust_event event_param; | |
31 | unsigned int enabled:1; | |
32 | ||
33 | uint64_t user_token; /* User-provided token */ | |
34 | }; | |
35 | ||
d871c65b FD |
36 | struct lttng_event_enabler { |
37 | struct lttng_enabler base; | |
38 | struct cds_list_head node; /* per-session list of enablers */ | |
bb84a1ec MD |
39 | struct lttng_event_container *container; |
40 | struct lttng_counter_key key; | |
d871c65b FD |
41 | /* |
42 | * Unused, but kept around to make it explicit that the tracer can do | |
43 | * it. | |
44 | */ | |
45 | struct lttng_ctx *ctx; | |
46 | }; | |
47 | ||
d8d2416d FD |
48 | struct lttng_event_notifier_enabler { |
49 | struct lttng_enabler base; | |
6566528b | 50 | uint64_t error_counter_index; |
d37ecb3f FD |
51 | struct cds_list_head node; /* per-app list of event_notifier enablers */ |
52 | struct cds_list_head capture_bytecode_head; | |
d8d2416d | 53 | struct lttng_event_notifier_group *group; /* weak ref */ |
d37ecb3f | 54 | uint64_t num_captures; |
d8d2416d FD |
55 | }; |
56 | ||
ab249ecf FD |
57 | enum lttng_ust_bytecode_node_type { |
58 | LTTNG_UST_BYTECODE_NODE_TYPE_FILTER, | |
d37ecb3f | 59 | LTTNG_UST_BYTECODE_NODE_TYPE_CAPTURE, |
ab249ecf FD |
60 | }; |
61 | ||
62 | struct lttng_ust_bytecode_node { | |
63 | enum lttng_ust_bytecode_node_type type; | |
92495593 FD |
64 | struct cds_list_head node; |
65 | struct lttng_enabler *enabler; | |
ab249ecf FD |
66 | struct { |
67 | uint32_t len; | |
68 | uint32_t reloc_offset; | |
69 | uint64_t seqnum; | |
70 | char data[]; | |
71 | } bc; | |
92495593 FD |
72 | }; |
73 | ||
74 | struct lttng_ust_excluder_node { | |
75 | struct cds_list_head node; | |
76 | struct lttng_enabler *enabler; | |
77 | /* | |
78 | * struct lttng_ust_event_exclusion had variable sized array, | |
79 | * must be last field. | |
80 | */ | |
81 | struct lttng_ust_event_exclusion excluder; | |
82 | }; | |
83 | ||
d871c65b FD |
84 | static inline |
85 | struct lttng_enabler *lttng_event_enabler_as_enabler( | |
86 | struct lttng_event_enabler *event_enabler) | |
87 | { | |
88 | return &event_enabler->base; | |
89 | } | |
90 | ||
d8d2416d FD |
91 | static inline |
92 | struct lttng_enabler *lttng_event_notifier_enabler_as_enabler( | |
93 | struct lttng_event_notifier_enabler *event_notifier_enabler) | |
94 | { | |
95 | return &event_notifier_enabler->base; | |
96 | } | |
d871c65b FD |
97 | |
98 | /* | |
99 | * Allocate and initialize a `struct lttng_event_enabler` object. | |
100 | * | |
101 | * On success, returns a `struct lttng_event_enabler`, | |
102 | * On memory error, returns NULL. | |
103 | */ | |
104 | LTTNG_HIDDEN | |
105 | struct lttng_event_enabler *lttng_event_enabler_create( | |
106 | enum lttng_enabler_format_type format_type, | |
107 | struct lttng_ust_event *event_param, | |
bb84a1ec MD |
108 | const struct lttng_ust_counter_key *key, |
109 | struct lttng_event_container *container); | |
d871c65b FD |
110 | |
111 | /* | |
112 | * Destroy a `struct lttng_event_enabler` object. | |
113 | */ | |
114 | LTTNG_HIDDEN | |
115 | void lttng_event_enabler_destroy(struct lttng_event_enabler *enabler); | |
116 | ||
117 | /* | |
118 | * Enable a `struct lttng_event_enabler` object and all events related to this | |
119 | * enabler. | |
120 | */ | |
121 | LTTNG_HIDDEN | |
122 | int lttng_event_enabler_enable(struct lttng_event_enabler *enabler); | |
123 | ||
124 | /* | |
125 | * Disable a `struct lttng_event_enabler` object and all events related to this | |
126 | * enabler. | |
127 | */ | |
128 | LTTNG_HIDDEN | |
129 | int lttng_event_enabler_disable(struct lttng_event_enabler *enabler); | |
130 | ||
131 | /* | |
132 | * Attach filter bytecode program to `struct lttng_event_enabler` and all | |
133 | * events related to this enabler. | |
134 | */ | |
135 | LTTNG_HIDDEN | |
a56fd376 FD |
136 | int lttng_event_enabler_attach_filter_bytecode( |
137 | struct lttng_event_enabler *enabler, | |
ab89263e | 138 | struct lttng_ust_bytecode_node **bytecode); |
d871c65b FD |
139 | |
140 | /* | |
141 | * Attach an application context to an event enabler. | |
142 | * | |
143 | * Not implemented. | |
144 | */ | |
145 | LTTNG_HIDDEN | |
146 | int lttng_event_enabler_attach_context(struct lttng_event_enabler *enabler, | |
147 | struct lttng_ust_context *ctx); | |
148 | ||
149 | /* | |
150 | * Attach exclusion list to `struct lttng_event_enabler` and all | |
151 | * events related to this enabler. | |
152 | */ | |
153 | LTTNG_HIDDEN | |
154 | int lttng_event_enabler_attach_exclusion(struct lttng_event_enabler *enabler, | |
e9fe6aad | 155 | struct lttng_ust_excluder_node **excluder); |
d871c65b FD |
156 | |
157 | /* | |
d37ecb3f FD |
158 | * Synchronize bytecodes for the enabler and the instance (event or |
159 | * event_notifier). | |
d871c65b | 160 | * |
621c07fc | 161 | * This function goes over all bytecode programs of the enabler (event or |
d37ecb3f | 162 | * event_notifier enabler) to ensure each is linked to the provided instance. |
d871c65b FD |
163 | */ |
164 | LTTNG_HIDDEN | |
53b9d7db FD |
165 | void lttng_enabler_link_bytecode(const struct lttng_event_desc *event_desc, |
166 | struct lttng_ctx **ctx, | |
621c07fc FD |
167 | struct cds_list_head *instance_bytecode_runtime_head, |
168 | struct cds_list_head *enabler_bytecode_runtime_head); | |
d871c65b | 169 | |
d8d2416d FD |
170 | /* |
171 | * Allocate and initialize a `struct lttng_event_notifier_group` object. | |
172 | * | |
173 | * On success, returns a `struct lttng_triggre_group`, | |
174 | * on memory error, returns NULL. | |
175 | */ | |
176 | LTTNG_HIDDEN | |
177 | struct lttng_event_notifier_group *lttng_event_notifier_group_create(void); | |
178 | ||
179 | /* | |
180 | * Destroy a `struct lttng_event_notifier_group` object. | |
181 | */ | |
182 | LTTNG_HIDDEN | |
183 | void lttng_event_notifier_group_destroy( | |
184 | struct lttng_event_notifier_group *event_notifier_group); | |
185 | ||
186 | /* | |
187 | * Allocate and initialize a `struct lttng_event_notifier_enabler` object. | |
188 | * | |
189 | * On success, returns a `struct lttng_event_notifier_enabler`, | |
190 | * On memory error, returns NULL. | |
191 | */ | |
192 | LTTNG_HIDDEN | |
193 | struct lttng_event_notifier_enabler *lttng_event_notifier_enabler_create( | |
194 | struct lttng_event_notifier_group *event_notifier_group, | |
195 | enum lttng_enabler_format_type format_type, | |
196 | struct lttng_ust_event_notifier *event_notifier_param); | |
197 | ||
198 | /* | |
199 | * Destroy a `struct lttng_event_notifier_enabler` object. | |
200 | */ | |
201 | LTTNG_HIDDEN | |
202 | void lttng_event_notifier_enabler_destroy( | |
203 | struct lttng_event_notifier_enabler *event_notifier_enabler); | |
204 | ||
205 | /* | |
206 | * Enable a `struct lttng_event_notifier_enabler` object and all event | |
207 | * notifiers related to this enabler. | |
208 | */ | |
209 | LTTNG_HIDDEN | |
210 | int lttng_event_notifier_enabler_enable( | |
211 | struct lttng_event_notifier_enabler *event_notifier_enabler); | |
212 | ||
213 | /* | |
214 | * Disable a `struct lttng_event_notifier_enabler` object and all event | |
215 | * notifiers related to this enabler. | |
216 | */ | |
217 | LTTNG_HIDDEN | |
218 | int lttng_event_notifier_enabler_disable( | |
219 | struct lttng_event_notifier_enabler *event_notifier_enabler); | |
220 | ||
221 | /* | |
222 | * Attach filter bytecode program to `struct lttng_event_notifier_enabler` and | |
223 | * all event notifiers related to this enabler. | |
224 | */ | |
225 | LTTNG_HIDDEN | |
a56fd376 | 226 | int lttng_event_notifier_enabler_attach_filter_bytecode( |
d8d2416d | 227 | struct lttng_event_notifier_enabler *event_notifier_enabler, |
ab89263e | 228 | struct lttng_ust_bytecode_node **bytecode); |
d8d2416d | 229 | |
d37ecb3f FD |
230 | /* |
231 | * Attach capture bytecode program to `struct lttng_event_notifier_enabler` and | |
232 | * all event_notifiers related to this enabler. | |
233 | */ | |
234 | LTTNG_HIDDEN | |
235 | int lttng_event_notifier_enabler_attach_capture_bytecode( | |
236 | struct lttng_event_notifier_enabler *event_notifier_enabler, | |
49cde654 | 237 | struct lttng_ust_bytecode_node **bytecode); |
d37ecb3f | 238 | |
d8d2416d FD |
239 | /* |
240 | * Attach exclusion list to `struct lttng_event_notifier_enabler` and all | |
241 | * event notifiers related to this enabler. | |
242 | */ | |
243 | LTTNG_HIDDEN | |
244 | int lttng_event_notifier_enabler_attach_exclusion( | |
245 | struct lttng_event_notifier_enabler *event_notifier_enabler, | |
e9fe6aad | 246 | struct lttng_ust_excluder_node **excluder); |
d8d2416d FD |
247 | |
248 | LTTNG_HIDDEN | |
249 | void lttng_free_event_notifier_filter_runtime( | |
250 | struct lttng_event_notifier *event_notifier); | |
251 | ||
252 | /* | |
253 | * Connect the probe on all enablers matching this event description. | |
254 | * Called on library load. | |
255 | */ | |
256 | LTTNG_HIDDEN | |
257 | int lttng_fix_pending_event_notifiers(void); | |
258 | ||
67d4e8f5 MJ |
259 | LTTNG_HIDDEN |
260 | struct lttng_counter *lttng_ust_counter_create( | |
261 | const char *counter_transport_name, | |
bb84a1ec MD |
262 | size_t number_dimensions, |
263 | const size_t *max_nr_elem, | |
264 | int64_t global_sum_step, | |
265 | bool coalesce_hits); | |
266 | ||
267 | LTTNG_HIDDEN | |
268 | struct lttng_counter *lttng_session_create_counter( | |
269 | struct lttng_session *session, | |
270 | const char *counter_transport_name, | |
271 | size_t number_dimensions, const size_t *dimensions_sizes, | |
272 | int64_t global_sum_step, bool coalesce_hits); | |
67d4e8f5 | 273 | |
d871c65b | 274 | #endif /* _LTTNG_UST_EVENTS_INTERNAL_H */ |