2 * SPDX-License-Identifier: MIT
4 * Copyright 2019 (c) Francis Deslauriers <francis.deslauriers@efficios.com>
7 #ifndef _LTTNG_UST_EVENTS_INTERNAL_H
8 #define _LTTNG_UST_EVENTS_INTERNAL_H
12 #include <urcu/list.h>
13 #include <urcu/hlist.h>
15 #include <ust-helper.h>
16 #include <lttng/ust-events.h>
18 enum lttng_enabler_format_type
{
19 LTTNG_ENABLER_FORMAT_STAR_GLOB
,
20 LTTNG_ENABLER_FORMAT_EVENT
,
24 * Enabler field, within whatever object is enabling an event. Target of
27 struct lttng_enabler
{
28 enum lttng_enabler_format_type format_type
;
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
;
35 struct lttng_ust_event event_param
;
36 unsigned int enabled
:1;
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
;
44 * Unused, but kept around to make it explicit that the tracer can do
47 struct lttng_ctx
*ctx
;
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
;
60 enum lttng_ust_bytecode_node_type
{
61 LTTNG_UST_BYTECODE_NODE_TYPE_FILTER
,
62 LTTNG_UST_BYTECODE_NODE_TYPE_CAPTURE
,
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
;
71 uint32_t reloc_offset
;
77 struct lttng_ust_excluder_node
{
78 struct cds_list_head node
;
79 struct lttng_enabler
*enabler
;
81 * struct lttng_ust_event_exclusion had variable sized array,
84 struct lttng_ust_event_exclusion excluder
;
88 struct lttng_enabler
*lttng_event_enabler_as_enabler(
89 struct lttng_event_enabler
*event_enabler
)
91 return &event_enabler
->base
;
95 struct lttng_enabler
*lttng_event_notifier_enabler_as_enabler(
96 struct lttng_event_notifier_enabler
*event_notifier_enabler
)
98 return &event_notifier_enabler
->base
;
102 * Allocate and initialize a `struct lttng_event_enabler` object.
104 * On success, returns a `struct lttng_event_enabler`,
105 * On memory error, returns NULL.
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
);
114 * Destroy a `struct lttng_event_enabler` object.
117 void lttng_event_enabler_destroy(struct lttng_event_enabler
*enabler
);
120 * Enable a `struct lttng_event_enabler` object and all events related to this
124 int lttng_event_enabler_enable(struct lttng_event_enabler
*enabler
);
127 * Disable a `struct lttng_event_enabler` object and all events related to this
131 int lttng_event_enabler_disable(struct lttng_event_enabler
*enabler
);
134 * Attach filter bytecode program to `struct lttng_event_enabler` and all
135 * events related to this enabler.
138 int lttng_event_enabler_attach_filter_bytecode(
139 struct lttng_event_enabler
*enabler
,
140 struct lttng_ust_bytecode_node
**bytecode
);
143 * Attach an application context to an event enabler.
148 int lttng_event_enabler_attach_context(struct lttng_event_enabler
*enabler
,
149 struct lttng_ust_context
*ctx
);
152 * Attach exclusion list to `struct lttng_event_enabler` and all
153 * events related to this enabler.
156 int lttng_event_enabler_attach_exclusion(struct lttng_event_enabler
*enabler
,
157 struct lttng_ust_excluder_node
**excluder
);
160 * Synchronize bytecodes for the enabler and the instance (event or
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.
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
);
173 * Allocate and initialize a `struct lttng_event_notifier_group` object.
175 * On success, returns a `struct lttng_triggre_group`,
176 * on memory error, returns NULL.
179 struct lttng_event_notifier_group
*lttng_event_notifier_group_create(void);
182 * Destroy a `struct lttng_event_notifier_group` object.
185 void lttng_event_notifier_group_destroy(
186 struct lttng_event_notifier_group
*event_notifier_group
);
189 * Allocate and initialize a `struct lttng_event_notifier_enabler` object.
191 * On success, returns a `struct lttng_event_notifier_enabler`,
192 * On memory error, returns NULL.
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
);
201 * Destroy a `struct lttng_event_notifier_enabler` object.
204 void lttng_event_notifier_enabler_destroy(
205 struct lttng_event_notifier_enabler
*event_notifier_enabler
);
208 * Enable a `struct lttng_event_notifier_enabler` object and all event
209 * notifiers related to this enabler.
212 int lttng_event_notifier_enabler_enable(
213 struct lttng_event_notifier_enabler
*event_notifier_enabler
);
216 * Disable a `struct lttng_event_notifier_enabler` object and all event
217 * notifiers related to this enabler.
220 int lttng_event_notifier_enabler_disable(
221 struct lttng_event_notifier_enabler
*event_notifier_enabler
);
224 * Attach filter bytecode program to `struct lttng_event_notifier_enabler` and
225 * all event notifiers related to this enabler.
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
);
233 * Attach capture bytecode program to `struct lttng_event_notifier_enabler` and
234 * all event_notifiers related to this enabler.
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
);
242 * Attach exclusion list to `struct lttng_event_notifier_enabler` and all
243 * event notifiers related to this enabler.
246 int lttng_event_notifier_enabler_attach_exclusion(
247 struct lttng_event_notifier_enabler
*event_notifier_enabler
,
248 struct lttng_ust_excluder_node
**excluder
);
251 void lttng_free_event_filter_runtime(struct lttng_event
*event
);
254 void lttng_free_event_notifier_filter_runtime(
255 struct lttng_event_notifier
*event_notifier
);
258 * Connect the probe on all enablers matching this event description.
259 * Called on library load.
262 int lttng_fix_pending_event_notifiers(void);
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
);
269 #ifdef HAVE_PERF_EVENT
272 int lttng_add_perf_counter_to_ctx(uint32_t type
,
275 struct lttng_ctx
**ctx
);
277 int lttng_perf_counter_init(void);
279 void lttng_perf_counter_exit(void);
281 #else /* #ifdef HAVE_PERF_EVENT */
284 int lttng_add_perf_counter_to_ctx(uint32_t type
,
287 struct lttng_ctx
**ctx
)
292 int lttng_perf_counter_init(void)
297 void lttng_perf_counter_exit(void)
300 #endif /* #else #ifdef HAVE_PERF_EVENT */
303 int lttng_probes_get_event_list(struct lttng_ust_tracepoint_list
*list
);
305 void lttng_probes_prune_event_list(struct lttng_ust_tracepoint_list
*list
);
308 int lttng_probes_get_field_list(struct lttng_ust_field_list
*list
);
310 void lttng_probes_prune_field_list(struct lttng_ust_field_list
*list
);
313 struct lttng_ust_tracepoint_iter
*
314 lttng_ust_tracepoint_list_get_iter_next(struct lttng_ust_tracepoint_list
*list
);
316 struct lttng_ust_field_iter
*
317 lttng_ust_field_list_get_iter_next(struct lttng_ust_field_list
*list
);
320 struct lttng_session
*lttng_session_create(void);
322 int lttng_session_enable(struct lttng_session
*session
);
324 int lttng_session_disable(struct lttng_session
*session
);
326 int lttng_session_statedump(struct lttng_session
*session
);
328 void lttng_session_destroy(struct lttng_session
*session
);
331 struct cds_list_head
*lttng_get_sessions(void);
334 void lttng_handle_pending_statedump(void *owner
);
337 struct lttng_channel
*lttng_channel_create(struct lttng_session
*session
,
338 const char *transport_name
,
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
);
348 int lttng_channel_enable(struct lttng_channel
*channel
);
350 int lttng_channel_disable(struct lttng_channel
*channel
);
353 void lttng_transport_register(struct lttng_transport
*transport
);
355 void lttng_transport_unregister(struct lttng_transport
*transport
);
358 void lttng_probe_provider_unregister_events(struct lttng_probe_desc
*desc
);
361 int lttng_fix_pending_events(void);
364 struct cds_list_head
*lttng_get_probe_list_head(void);
367 struct lttng_enum
*lttng_ust_enum_get_from_desc(struct lttng_session
*session
,
368 const struct lttng_enum_desc
*enum_desc
);
370 #endif /* _LTTNG_UST_EVENTS_INTERNAL_H */