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 struct lttng_event_enabler
{
19 struct lttng_enabler base
;
20 struct cds_list_head node
; /* per-session list of enablers */
21 struct lttng_channel
*chan
;
23 * Unused, but kept around to make it explicit that the tracer can do
26 struct lttng_ctx
*ctx
;
29 struct lttng_event_notifier_enabler
{
30 struct lttng_enabler base
;
31 uint64_t error_counter_index
;
32 struct cds_list_head node
; /* per-app list of event_notifier enablers */
33 struct cds_list_head capture_bytecode_head
;
34 struct lttng_event_notifier_group
*group
; /* weak ref */
35 uint64_t user_token
; /* User-provided token */
36 uint64_t num_captures
;
39 enum lttng_ust_bytecode_node_type
{
40 LTTNG_UST_BYTECODE_NODE_TYPE_FILTER
,
41 LTTNG_UST_BYTECODE_NODE_TYPE_CAPTURE
,
44 struct lttng_ust_bytecode_node
{
45 enum lttng_ust_bytecode_node_type type
;
46 struct cds_list_head node
;
47 struct lttng_enabler
*enabler
;
50 uint32_t reloc_offset
;
56 struct lttng_ust_excluder_node
{
57 struct cds_list_head node
;
58 struct lttng_enabler
*enabler
;
60 * struct lttng_ust_event_exclusion had variable sized array,
63 struct lttng_ust_event_exclusion excluder
;
67 struct lttng_enabler
*lttng_event_enabler_as_enabler(
68 struct lttng_event_enabler
*event_enabler
)
70 return &event_enabler
->base
;
74 struct lttng_enabler
*lttng_event_notifier_enabler_as_enabler(
75 struct lttng_event_notifier_enabler
*event_notifier_enabler
)
77 return &event_notifier_enabler
->base
;
81 * Allocate and initialize a `struct lttng_event_enabler` object.
83 * On success, returns a `struct lttng_event_enabler`,
84 * On memory error, returns NULL.
87 struct lttng_event_enabler
*lttng_event_enabler_create(
88 enum lttng_enabler_format_type format_type
,
89 struct lttng_ust_event
*event_param
,
90 struct lttng_channel
*chan
);
93 * Destroy a `struct lttng_event_enabler` object.
96 void lttng_event_enabler_destroy(struct lttng_event_enabler
*enabler
);
99 * Enable a `struct lttng_event_enabler` object and all events related to this
103 int lttng_event_enabler_enable(struct lttng_event_enabler
*enabler
);
106 * Disable a `struct lttng_event_enabler` object and all events related to this
110 int lttng_event_enabler_disable(struct lttng_event_enabler
*enabler
);
113 * Attach filter bytecode program to `struct lttng_event_enabler` and all
114 * events related to this enabler.
117 int lttng_event_enabler_attach_filter_bytecode(
118 struct lttng_event_enabler
*enabler
,
119 struct lttng_ust_bytecode_node
**bytecode
);
122 * Attach an application context to an event enabler.
127 int lttng_event_enabler_attach_context(struct lttng_event_enabler
*enabler
,
128 struct lttng_ust_context
*ctx
);
131 * Attach exclusion list to `struct lttng_event_enabler` and all
132 * events related to this enabler.
135 int lttng_event_enabler_attach_exclusion(struct lttng_event_enabler
*enabler
,
136 struct lttng_ust_excluder_node
**excluder
);
139 * Synchronize bytecodes for the enabler and the instance (event or
142 * This function goes over all bytecode programs of the enabler (event or
143 * event_notifier enabler) to ensure each is linked to the provided instance.
146 void lttng_enabler_link_bytecode(const struct lttng_event_desc
*event_desc
,
147 struct lttng_ctx
**ctx
,
148 struct cds_list_head
*instance_bytecode_runtime_head
,
149 struct cds_list_head
*enabler_bytecode_runtime_head
);
152 * Allocate and initialize a `struct lttng_event_notifier_group` object.
154 * On success, returns a `struct lttng_triggre_group`,
155 * on memory error, returns NULL.
158 struct lttng_event_notifier_group
*lttng_event_notifier_group_create(void);
161 * Destroy a `struct lttng_event_notifier_group` object.
164 void lttng_event_notifier_group_destroy(
165 struct lttng_event_notifier_group
*event_notifier_group
);
168 * Allocate and initialize a `struct lttng_event_notifier_enabler` object.
170 * On success, returns a `struct lttng_event_notifier_enabler`,
171 * On memory error, returns NULL.
174 struct lttng_event_notifier_enabler
*lttng_event_notifier_enabler_create(
175 struct lttng_event_notifier_group
*event_notifier_group
,
176 enum lttng_enabler_format_type format_type
,
177 struct lttng_ust_event_notifier
*event_notifier_param
);
180 * Destroy a `struct lttng_event_notifier_enabler` object.
183 void lttng_event_notifier_enabler_destroy(
184 struct lttng_event_notifier_enabler
*event_notifier_enabler
);
187 * Enable a `struct lttng_event_notifier_enabler` object and all event
188 * notifiers related to this enabler.
191 int lttng_event_notifier_enabler_enable(
192 struct lttng_event_notifier_enabler
*event_notifier_enabler
);
195 * Disable a `struct lttng_event_notifier_enabler` object and all event
196 * notifiers related to this enabler.
199 int lttng_event_notifier_enabler_disable(
200 struct lttng_event_notifier_enabler
*event_notifier_enabler
);
203 * Attach filter bytecode program to `struct lttng_event_notifier_enabler` and
204 * all event notifiers related to this enabler.
207 int lttng_event_notifier_enabler_attach_filter_bytecode(
208 struct lttng_event_notifier_enabler
*event_notifier_enabler
,
209 struct lttng_ust_bytecode_node
**bytecode
);
212 * Attach capture bytecode program to `struct lttng_event_notifier_enabler` and
213 * all event_notifiers related to this enabler.
216 int lttng_event_notifier_enabler_attach_capture_bytecode(
217 struct lttng_event_notifier_enabler
*event_notifier_enabler
,
218 struct lttng_ust_bytecode_node
**bytecode
);
221 * Attach exclusion list to `struct lttng_event_notifier_enabler` and all
222 * event notifiers related to this enabler.
225 int lttng_event_notifier_enabler_attach_exclusion(
226 struct lttng_event_notifier_enabler
*event_notifier_enabler
,
227 struct lttng_ust_excluder_node
**excluder
);
230 void lttng_free_event_notifier_filter_runtime(
231 struct lttng_event_notifier
*event_notifier
);
234 * Connect the probe on all enablers matching this event description.
235 * Called on library load.
238 int lttng_fix_pending_event_notifiers(void);
241 struct lttng_counter
*lttng_ust_counter_create(
242 const char *counter_transport_name
,
243 size_t number_dimensions
, const struct lttng_counter_dimension
*dimensions
);
245 #ifdef HAVE_PERF_EVENT
248 int lttng_add_perf_counter_to_ctx(uint32_t type
,
251 struct lttng_ctx
**ctx
);
253 int lttng_perf_counter_init(void);
255 void lttng_perf_counter_exit(void);
257 #else /* #ifdef HAVE_PERF_EVENT */
260 int lttng_add_perf_counter_to_ctx(uint32_t type
,
263 struct lttng_ctx
**ctx
)
268 int lttng_perf_counter_init(void)
273 void lttng_perf_counter_exit(void)
276 #endif /* #else #ifdef HAVE_PERF_EVENT */
278 #endif /* _LTTNG_UST_EVENTS_INTERNAL_H */