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>
16 #include <lttng/ust-events.h>
19 * Enabler field, within whatever object is enabling an event. Target of
22 struct lttng_enabler
{
23 enum lttng_enabler_format_type format_type
;
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
;
30 struct lttng_ust_event event_param
;
31 unsigned int enabled
:1;
33 uint64_t user_token
; /* User-provided token */
36 struct lttng_event_enabler
{
37 struct lttng_enabler base
;
38 struct cds_list_head node
; /* per-session list of enablers */
39 struct lttng_event_container
*container
;
40 struct lttng_counter_key key
;
42 * Unused, but kept around to make it explicit that the tracer can do
45 struct lttng_ctx
*ctx
;
48 struct lttng_event_notifier_enabler
{
49 struct lttng_enabler base
;
50 uint64_t error_counter_index
;
51 struct cds_list_head node
; /* per-app list of event_notifier enablers */
52 struct cds_list_head capture_bytecode_head
;
53 struct lttng_event_notifier_group
*group
; /* weak ref */
54 uint64_t num_captures
;
57 enum lttng_ust_bytecode_node_type
{
58 LTTNG_UST_BYTECODE_NODE_TYPE_FILTER
,
59 LTTNG_UST_BYTECODE_NODE_TYPE_CAPTURE
,
62 struct lttng_ust_bytecode_node
{
63 enum lttng_ust_bytecode_node_type type
;
64 struct cds_list_head node
;
65 struct lttng_enabler
*enabler
;
68 uint32_t reloc_offset
;
74 struct lttng_ust_excluder_node
{
75 struct cds_list_head node
;
76 struct lttng_enabler
*enabler
;
78 * struct lttng_ust_event_exclusion had variable sized array,
81 struct lttng_ust_event_exclusion excluder
;
85 struct lttng_enabler
*lttng_event_enabler_as_enabler(
86 struct lttng_event_enabler
*event_enabler
)
88 return &event_enabler
->base
;
92 struct lttng_enabler
*lttng_event_notifier_enabler_as_enabler(
93 struct lttng_event_notifier_enabler
*event_notifier_enabler
)
95 return &event_notifier_enabler
->base
;
99 * Allocate and initialize a `struct lttng_event_enabler` object.
101 * On success, returns a `struct lttng_event_enabler`,
102 * On memory error, returns NULL.
105 struct lttng_event_enabler
*lttng_event_enabler_create(
106 enum lttng_enabler_format_type format_type
,
107 struct lttng_ust_event
*event_param
,
108 const struct lttng_ust_counter_key
*key
,
109 struct lttng_event_container
*container
);
112 * Destroy a `struct lttng_event_enabler` object.
115 void lttng_event_enabler_destroy(struct lttng_event_enabler
*enabler
);
118 * Enable a `struct lttng_event_enabler` object and all events related to this
122 int lttng_event_enabler_enable(struct lttng_event_enabler
*enabler
);
125 * Disable a `struct lttng_event_enabler` object and all events related to this
129 int lttng_event_enabler_disable(struct lttng_event_enabler
*enabler
);
132 * Attach filter bytecode program to `struct lttng_event_enabler` and all
133 * events related to this enabler.
136 int lttng_event_enabler_attach_filter_bytecode(
137 struct lttng_event_enabler
*enabler
,
138 struct lttng_ust_bytecode_node
**bytecode
);
141 * Attach an application context to an event enabler.
146 int lttng_event_enabler_attach_context(struct lttng_event_enabler
*enabler
,
147 struct lttng_ust_context
*ctx
);
150 * Attach exclusion list to `struct lttng_event_enabler` and all
151 * events related to this enabler.
154 int lttng_event_enabler_attach_exclusion(struct lttng_event_enabler
*enabler
,
155 struct lttng_ust_excluder_node
**excluder
);
158 * Synchronize bytecodes for the enabler and the instance (event or
161 * This function goes over all bytecode programs of the enabler (event or
162 * event_notifier enabler) to ensure each is linked to the provided instance.
165 void lttng_enabler_link_bytecode(const struct lttng_event_desc
*event_desc
,
166 struct lttng_ctx
**ctx
,
167 struct cds_list_head
*instance_bytecode_runtime_head
,
168 struct cds_list_head
*enabler_bytecode_runtime_head
);
171 * Allocate and initialize a `struct lttng_event_notifier_group` object.
173 * On success, returns a `struct lttng_triggre_group`,
174 * on memory error, returns NULL.
177 struct lttng_event_notifier_group
*lttng_event_notifier_group_create(void);
180 * Destroy a `struct lttng_event_notifier_group` object.
183 void lttng_event_notifier_group_destroy(
184 struct lttng_event_notifier_group
*event_notifier_group
);
187 * Allocate and initialize a `struct lttng_event_notifier_enabler` object.
189 * On success, returns a `struct lttng_event_notifier_enabler`,
190 * On memory error, returns NULL.
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
);
199 * Destroy a `struct lttng_event_notifier_enabler` object.
202 void lttng_event_notifier_enabler_destroy(
203 struct lttng_event_notifier_enabler
*event_notifier_enabler
);
206 * Enable a `struct lttng_event_notifier_enabler` object and all event
207 * notifiers related to this enabler.
210 int lttng_event_notifier_enabler_enable(
211 struct lttng_event_notifier_enabler
*event_notifier_enabler
);
214 * Disable a `struct lttng_event_notifier_enabler` object and all event
215 * notifiers related to this enabler.
218 int lttng_event_notifier_enabler_disable(
219 struct lttng_event_notifier_enabler
*event_notifier_enabler
);
222 * Attach filter bytecode program to `struct lttng_event_notifier_enabler` and
223 * all event notifiers related to this enabler.
226 int lttng_event_notifier_enabler_attach_filter_bytecode(
227 struct lttng_event_notifier_enabler
*event_notifier_enabler
,
228 struct lttng_ust_bytecode_node
**bytecode
);
231 * Attach capture bytecode program to `struct lttng_event_notifier_enabler` and
232 * all event_notifiers related to this enabler.
235 int lttng_event_notifier_enabler_attach_capture_bytecode(
236 struct lttng_event_notifier_enabler
*event_notifier_enabler
,
237 struct lttng_ust_bytecode_node
**bytecode
);
240 * Attach exclusion list to `struct lttng_event_notifier_enabler` and all
241 * event notifiers related to this enabler.
244 int lttng_event_notifier_enabler_attach_exclusion(
245 struct lttng_event_notifier_enabler
*event_notifier_enabler
,
246 struct lttng_ust_excluder_node
**excluder
);
249 void lttng_free_event_notifier_filter_runtime(
250 struct lttng_event_notifier
*event_notifier
);
253 * Connect the probe on all enablers matching this event description.
254 * Called on library load.
257 int lttng_fix_pending_event_notifiers(void);
260 struct lttng_counter
*lttng_ust_counter_create(
261 const char *counter_transport_name
,
262 size_t number_dimensions
,
263 const size_t *max_nr_elem
,
264 int64_t global_sum_step
,
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
);
274 #endif /* _LTTNG_UST_EVENTS_INTERNAL_H */