Move ust-events.h private functions to internal
[lttng-ust.git] / liblttng-ust / ust-events-internal.h
1 /*
2 * SPDX-License-Identifier: MIT
3 *
4 * Copyright 2019 (c) Francis Deslauriers <francis.deslauriers@efficios.com>
5 */
6
7 #ifndef _LTTNG_UST_EVENTS_INTERNAL_H
8 #define _LTTNG_UST_EVENTS_INTERNAL_H
9
10 #include <stdint.h>
11
12 #include <urcu/list.h>
13 #include <urcu/hlist.h>
14
15 #include <ust-helper.h>
16 #include <lttng/ust-events.h>
17
18 enum lttng_enabler_format_type {
19 LTTNG_ENABLER_FORMAT_STAR_GLOB,
20 LTTNG_ENABLER_FORMAT_EVENT,
21 };
22
23 /*
24 * Enabler field, within whatever object is enabling an event. Target of
25 * backward reference.
26 */
27 struct lttng_enabler {
28 enum lttng_enabler_format_type format_type;
29
30 /* head list of struct lttng_ust_filter_bytecode_node */
31 struct cds_list_head filter_bytecode_head;
32 /* head list of struct lttng_ust_excluder_node */
33 struct cds_list_head excluder_head;
34
35 struct lttng_ust_event event_param;
36 unsigned int enabled:1;
37 };
38
39 struct lttng_event_enabler {
40 struct lttng_enabler base;
41 struct cds_list_head node; /* per-session list of enablers */
42 struct lttng_channel *chan;
43 /*
44 * Unused, but kept around to make it explicit that the tracer can do
45 * it.
46 */
47 struct lttng_ctx *ctx;
48 };
49
50 struct lttng_event_notifier_enabler {
51 struct lttng_enabler base;
52 uint64_t error_counter_index;
53 struct cds_list_head node; /* per-app list of event_notifier enablers */
54 struct cds_list_head capture_bytecode_head;
55 struct lttng_event_notifier_group *group; /* weak ref */
56 uint64_t user_token; /* User-provided token */
57 uint64_t num_captures;
58 };
59
60 enum lttng_ust_bytecode_node_type {
61 LTTNG_UST_BYTECODE_NODE_TYPE_FILTER,
62 LTTNG_UST_BYTECODE_NODE_TYPE_CAPTURE,
63 };
64
65 struct lttng_ust_bytecode_node {
66 enum lttng_ust_bytecode_node_type type;
67 struct cds_list_head node;
68 struct lttng_enabler *enabler;
69 struct {
70 uint32_t len;
71 uint32_t reloc_offset;
72 uint64_t seqnum;
73 char data[];
74 } bc;
75 };
76
77 struct lttng_ust_excluder_node {
78 struct cds_list_head node;
79 struct lttng_enabler *enabler;
80 /*
81 * struct lttng_ust_event_exclusion had variable sized array,
82 * must be last field.
83 */
84 struct lttng_ust_event_exclusion excluder;
85 };
86
87 static inline
88 struct lttng_enabler *lttng_event_enabler_as_enabler(
89 struct lttng_event_enabler *event_enabler)
90 {
91 return &event_enabler->base;
92 }
93
94 static inline
95 struct lttng_enabler *lttng_event_notifier_enabler_as_enabler(
96 struct lttng_event_notifier_enabler *event_notifier_enabler)
97 {
98 return &event_notifier_enabler->base;
99 }
100
101 /*
102 * Allocate and initialize a `struct lttng_event_enabler` object.
103 *
104 * On success, returns a `struct lttng_event_enabler`,
105 * On memory error, returns NULL.
106 */
107 LTTNG_HIDDEN
108 struct lttng_event_enabler *lttng_event_enabler_create(
109 enum lttng_enabler_format_type format_type,
110 struct lttng_ust_event *event_param,
111 struct lttng_channel *chan);
112
113 /*
114 * Destroy a `struct lttng_event_enabler` object.
115 */
116 LTTNG_HIDDEN
117 void lttng_event_enabler_destroy(struct lttng_event_enabler *enabler);
118
119 /*
120 * Enable a `struct lttng_event_enabler` object and all events related to this
121 * enabler.
122 */
123 LTTNG_HIDDEN
124 int lttng_event_enabler_enable(struct lttng_event_enabler *enabler);
125
126 /*
127 * Disable a `struct lttng_event_enabler` object and all events related to this
128 * enabler.
129 */
130 LTTNG_HIDDEN
131 int lttng_event_enabler_disable(struct lttng_event_enabler *enabler);
132
133 /*
134 * Attach filter bytecode program to `struct lttng_event_enabler` and all
135 * events related to this enabler.
136 */
137 LTTNG_HIDDEN
138 int lttng_event_enabler_attach_filter_bytecode(
139 struct lttng_event_enabler *enabler,
140 struct lttng_ust_bytecode_node **bytecode);
141
142 /*
143 * Attach an application context to an event enabler.
144 *
145 * Not implemented.
146 */
147 LTTNG_HIDDEN
148 int lttng_event_enabler_attach_context(struct lttng_event_enabler *enabler,
149 struct lttng_ust_context *ctx);
150
151 /*
152 * Attach exclusion list to `struct lttng_event_enabler` and all
153 * events related to this enabler.
154 */
155 LTTNG_HIDDEN
156 int lttng_event_enabler_attach_exclusion(struct lttng_event_enabler *enabler,
157 struct lttng_ust_excluder_node **excluder);
158
159 /*
160 * Synchronize bytecodes for the enabler and the instance (event or
161 * event_notifier).
162 *
163 * This function goes over all bytecode programs of the enabler (event or
164 * event_notifier enabler) to ensure each is linked to the provided instance.
165 */
166 LTTNG_HIDDEN
167 void lttng_enabler_link_bytecode(const struct lttng_event_desc *event_desc,
168 struct lttng_ctx **ctx,
169 struct cds_list_head *instance_bytecode_runtime_head,
170 struct cds_list_head *enabler_bytecode_runtime_head);
171
172 /*
173 * Allocate and initialize a `struct lttng_event_notifier_group` object.
174 *
175 * On success, returns a `struct lttng_triggre_group`,
176 * on memory error, returns NULL.
177 */
178 LTTNG_HIDDEN
179 struct lttng_event_notifier_group *lttng_event_notifier_group_create(void);
180
181 /*
182 * Destroy a `struct lttng_event_notifier_group` object.
183 */
184 LTTNG_HIDDEN
185 void lttng_event_notifier_group_destroy(
186 struct lttng_event_notifier_group *event_notifier_group);
187
188 /*
189 * Allocate and initialize a `struct lttng_event_notifier_enabler` object.
190 *
191 * On success, returns a `struct lttng_event_notifier_enabler`,
192 * On memory error, returns NULL.
193 */
194 LTTNG_HIDDEN
195 struct lttng_event_notifier_enabler *lttng_event_notifier_enabler_create(
196 struct lttng_event_notifier_group *event_notifier_group,
197 enum lttng_enabler_format_type format_type,
198 struct lttng_ust_event_notifier *event_notifier_param);
199
200 /*
201 * Destroy a `struct lttng_event_notifier_enabler` object.
202 */
203 LTTNG_HIDDEN
204 void lttng_event_notifier_enabler_destroy(
205 struct lttng_event_notifier_enabler *event_notifier_enabler);
206
207 /*
208 * Enable 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_enable(
213 struct lttng_event_notifier_enabler *event_notifier_enabler);
214
215 /*
216 * Disable a `struct lttng_event_notifier_enabler` object and all event
217 * notifiers related to this enabler.
218 */
219 LTTNG_HIDDEN
220 int lttng_event_notifier_enabler_disable(
221 struct lttng_event_notifier_enabler *event_notifier_enabler);
222
223 /*
224 * Attach filter bytecode program to `struct lttng_event_notifier_enabler` and
225 * all event notifiers related to this enabler.
226 */
227 LTTNG_HIDDEN
228 int lttng_event_notifier_enabler_attach_filter_bytecode(
229 struct lttng_event_notifier_enabler *event_notifier_enabler,
230 struct lttng_ust_bytecode_node **bytecode);
231
232 /*
233 * Attach capture bytecode program to `struct lttng_event_notifier_enabler` and
234 * all event_notifiers related to this enabler.
235 */
236 LTTNG_HIDDEN
237 int lttng_event_notifier_enabler_attach_capture_bytecode(
238 struct lttng_event_notifier_enabler *event_notifier_enabler,
239 struct lttng_ust_bytecode_node **bytecode);
240
241 /*
242 * Attach exclusion list to `struct lttng_event_notifier_enabler` and all
243 * event notifiers related to this enabler.
244 */
245 LTTNG_HIDDEN
246 int lttng_event_notifier_enabler_attach_exclusion(
247 struct lttng_event_notifier_enabler *event_notifier_enabler,
248 struct lttng_ust_excluder_node **excluder);
249
250 LTTNG_HIDDEN
251 void lttng_free_event_filter_runtime(struct lttng_event *event);
252
253 LTTNG_HIDDEN
254 void lttng_free_event_notifier_filter_runtime(
255 struct lttng_event_notifier *event_notifier);
256
257 /*
258 * Connect the probe on all enablers matching this event description.
259 * Called on library load.
260 */
261 LTTNG_HIDDEN
262 int lttng_fix_pending_event_notifiers(void);
263
264 LTTNG_HIDDEN
265 struct lttng_counter *lttng_ust_counter_create(
266 const char *counter_transport_name,
267 size_t number_dimensions, const struct lttng_counter_dimension *dimensions);
268
269 #ifdef HAVE_PERF_EVENT
270
271 LTTNG_HIDDEN
272 int lttng_add_perf_counter_to_ctx(uint32_t type,
273 uint64_t config,
274 const char *name,
275 struct lttng_ctx **ctx);
276 LTTNG_HIDDEN
277 int lttng_perf_counter_init(void);
278 LTTNG_HIDDEN
279 void lttng_perf_counter_exit(void);
280
281 #else /* #ifdef HAVE_PERF_EVENT */
282
283 static inline
284 int lttng_add_perf_counter_to_ctx(uint32_t type,
285 uint64_t config,
286 const char *name,
287 struct lttng_ctx **ctx)
288 {
289 return -ENOSYS;
290 }
291 static inline
292 int lttng_perf_counter_init(void)
293 {
294 return 0;
295 }
296 static inline
297 void lttng_perf_counter_exit(void)
298 {
299 }
300 #endif /* #else #ifdef HAVE_PERF_EVENT */
301
302 LTTNG_HIDDEN
303 int lttng_probes_get_event_list(struct lttng_ust_tracepoint_list *list);
304 LTTNG_HIDDEN
305 void lttng_probes_prune_event_list(struct lttng_ust_tracepoint_list *list);
306
307 LTTNG_HIDDEN
308 int lttng_probes_get_field_list(struct lttng_ust_field_list *list);
309 LTTNG_HIDDEN
310 void lttng_probes_prune_field_list(struct lttng_ust_field_list *list);
311
312 LTTNG_HIDDEN
313 struct lttng_ust_tracepoint_iter *
314 lttng_ust_tracepoint_list_get_iter_next(struct lttng_ust_tracepoint_list *list);
315 LTTNG_HIDDEN
316 struct lttng_ust_field_iter *
317 lttng_ust_field_list_get_iter_next(struct lttng_ust_field_list *list);
318
319 LTTNG_HIDDEN
320 struct lttng_session *lttng_session_create(void);
321 LTTNG_HIDDEN
322 int lttng_session_enable(struct lttng_session *session);
323 LTTNG_HIDDEN
324 int lttng_session_disable(struct lttng_session *session);
325 LTTNG_HIDDEN
326 int lttng_session_statedump(struct lttng_session *session);
327 LTTNG_HIDDEN
328 void lttng_session_destroy(struct lttng_session *session);
329
330 LTTNG_HIDDEN
331 struct cds_list_head *lttng_get_sessions(void);
332
333 LTTNG_HIDDEN
334 void lttng_handle_pending_statedump(void *owner);
335
336 LTTNG_HIDDEN
337 struct lttng_channel *lttng_channel_create(struct lttng_session *session,
338 const char *transport_name,
339 void *buf_addr,
340 size_t subbuf_size, size_t num_subbuf,
341 unsigned int switch_timer_interval,
342 unsigned int read_timer_interval,
343 int **shm_fd, int **wait_fd,
344 uint64_t **memory_map_size,
345 struct lttng_channel *chan_priv_init);
346
347 LTTNG_HIDDEN
348 int lttng_channel_enable(struct lttng_channel *channel);
349 LTTNG_HIDDEN
350 int lttng_channel_disable(struct lttng_channel *channel);
351
352 LTTNG_HIDDEN
353 void lttng_transport_register(struct lttng_transport *transport);
354 LTTNG_HIDDEN
355 void lttng_transport_unregister(struct lttng_transport *transport);
356
357 LTTNG_HIDDEN
358 void lttng_probe_provider_unregister_events(struct lttng_probe_desc *desc);
359
360 LTTNG_HIDDEN
361 int lttng_fix_pending_events(void);
362
363 LTTNG_HIDDEN
364 struct cds_list_head *lttng_get_probe_list_head(void);
365
366 LTTNG_HIDDEN
367 struct lttng_enum *lttng_ust_enum_get_from_desc(struct lttng_session *session,
368 const struct lttng_enum_desc *enum_desc);
369
370 #endif /* _LTTNG_UST_EVENTS_INTERNAL_H */
This page took 0.036936 seconds and 4 git commands to generate.