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_notifier_filter_runtime(
252 struct lttng_event_notifier
*event_notifier
);
255 * Connect the probe on all enablers matching this event description.
256 * Called on library load.
259 int lttng_fix_pending_event_notifiers(void);
262 struct lttng_counter
*lttng_ust_counter_create(
263 const char *counter_transport_name
,
264 size_t number_dimensions
, const struct lttng_counter_dimension
*dimensions
);
266 #ifdef HAVE_PERF_EVENT
269 int lttng_add_perf_counter_to_ctx(uint32_t type
,
272 struct lttng_ctx
**ctx
);
274 int lttng_perf_counter_init(void);
276 void lttng_perf_counter_exit(void);
278 #else /* #ifdef HAVE_PERF_EVENT */
281 int lttng_add_perf_counter_to_ctx(uint32_t type
,
284 struct lttng_ctx
**ctx
)
289 int lttng_perf_counter_init(void)
294 void lttng_perf_counter_exit(void)
297 #endif /* #else #ifdef HAVE_PERF_EVENT */
299 #endif /* _LTTNG_UST_EVENTS_INTERNAL_H */