1 #ifndef _LTTNG_UST_EVENTS_INTERNAL_H
2 #define _LTTNG_UST_EVENTS_INTERNAL_H
5 * ust-events-internal.h
7 * Copyright 2019 (c) - Francis Deslauriers <francis.deslauriers@efficios.com>
9 * Permission is hereby granted, free of charge, to any person obtaining a copy
10 * of this software and associated documentation files (the "Software"), to deal
11 * in the Software without restriction, including without limitation the rights
12 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 * copies of the Software, and to permit persons to whom the Software is
14 * furnished to do so, subject to the following conditions:
16 * The above copyright notice and this permission notice shall be included in
17 * all copies or substantial portions of the Software.
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
30 #include <urcu/list.h>
31 #include <urcu/hlist.h>
34 #include <lttng/ust-events.h>
36 struct lttng_event_enabler
{
37 struct lttng_enabler base
;
38 struct cds_list_head node
; /* per-session list of enablers */
39 struct lttng_channel
*chan
;
41 * Unused, but kept around to make it explicit that the tracer can do
44 struct lttng_ctx
*ctx
;
47 struct lttng_event_notifier_enabler
{
48 struct lttng_enabler base
;
49 struct cds_list_head node
; /* per-app list of event notifier enablers */
50 struct lttng_event_notifier_group
*group
; /* weak ref */
51 uint64_t user_token
; /* User-provided token */
54 struct lttng_ust_filter_bytecode_node
{
55 struct cds_list_head node
;
56 struct lttng_enabler
*enabler
;
58 * struct lttng_ust_filter_bytecode has var. sized array, must
61 struct lttng_ust_filter_bytecode bc
;
64 struct lttng_ust_excluder_node
{
65 struct cds_list_head node
;
66 struct lttng_enabler
*enabler
;
68 * struct lttng_ust_event_exclusion had variable sized array,
71 struct lttng_ust_event_exclusion excluder
;
75 struct lttng_enabler
*lttng_event_enabler_as_enabler(
76 struct lttng_event_enabler
*event_enabler
)
78 return &event_enabler
->base
;
82 struct lttng_enabler
*lttng_event_notifier_enabler_as_enabler(
83 struct lttng_event_notifier_enabler
*event_notifier_enabler
)
85 return &event_notifier_enabler
->base
;
89 * Allocate and initialize a `struct lttng_event_enabler` object.
91 * On success, returns a `struct lttng_event_enabler`,
92 * On memory error, returns NULL.
95 struct lttng_event_enabler
*lttng_event_enabler_create(
96 enum lttng_enabler_format_type format_type
,
97 struct lttng_ust_event
*event_param
,
98 struct lttng_channel
*chan
);
101 * Destroy a `struct lttng_event_enabler` object.
104 void lttng_event_enabler_destroy(struct lttng_event_enabler
*enabler
);
107 * Enable a `struct lttng_event_enabler` object and all events related to this
111 int lttng_event_enabler_enable(struct lttng_event_enabler
*enabler
);
114 * Disable a `struct lttng_event_enabler` object and all events related to this
118 int lttng_event_enabler_disable(struct lttng_event_enabler
*enabler
);
121 * Attach filter bytecode program to `struct lttng_event_enabler` and all
122 * events related to this enabler.
125 int lttng_event_enabler_attach_filter_bytecode(
126 struct lttng_event_enabler
*enabler
,
127 struct lttng_ust_filter_bytecode_node
*bytecode
);
130 * Attach an application context to an event enabler.
135 int lttng_event_enabler_attach_context(struct lttng_event_enabler
*enabler
,
136 struct lttng_ust_context
*ctx
);
139 * Attach exclusion list to `struct lttng_event_enabler` and all
140 * events related to this enabler.
143 int lttng_event_enabler_attach_exclusion(struct lttng_event_enabler
*enabler
,
144 struct lttng_ust_excluder_node
*excluder
);
147 * Synchronize bytecodes for the enabler and the event.
149 * This function goes over all bytecode programs of the event enabler to ensure
150 * each is linked to the provided event.
153 void lttng_enabler_link_bytecode(const struct lttng_event_desc
*event_desc
,
154 struct lttng_ctx
**ctx
,
155 struct cds_list_head
*bytecode_runtime_head
,
156 struct lttng_enabler
*enabler
);
159 * Allocate and initialize a `struct lttng_event_notifier_group` object.
161 * On success, returns a `struct lttng_triggre_group`,
162 * on memory error, returns NULL.
165 struct lttng_event_notifier_group
*lttng_event_notifier_group_create(void);
168 * Destroy a `struct lttng_event_notifier_group` object.
171 void lttng_event_notifier_group_destroy(
172 struct lttng_event_notifier_group
*event_notifier_group
);
175 * Allocate and initialize a `struct lttng_event_notifier_enabler` object.
177 * On success, returns a `struct lttng_event_notifier_enabler`,
178 * On memory error, returns NULL.
181 struct lttng_event_notifier_enabler
*lttng_event_notifier_enabler_create(
182 struct lttng_event_notifier_group
*event_notifier_group
,
183 enum lttng_enabler_format_type format_type
,
184 struct lttng_ust_event_notifier
*event_notifier_param
);
187 * Destroy a `struct lttng_event_notifier_enabler` object.
190 void lttng_event_notifier_enabler_destroy(
191 struct lttng_event_notifier_enabler
*event_notifier_enabler
);
194 * Enable a `struct lttng_event_notifier_enabler` object and all event
195 * notifiers related to this enabler.
198 int lttng_event_notifier_enabler_enable(
199 struct lttng_event_notifier_enabler
*event_notifier_enabler
);
202 * Disable a `struct lttng_event_notifier_enabler` object and all event
203 * notifiers related to this enabler.
206 int lttng_event_notifier_enabler_disable(
207 struct lttng_event_notifier_enabler
*event_notifier_enabler
);
210 * Attach filter bytecode program to `struct lttng_event_notifier_enabler` and
211 * all event notifiers related to this enabler.
214 int lttng_event_notifier_enabler_attach_filter_bytecode(
215 struct lttng_event_notifier_enabler
*event_notifier_enabler
,
216 struct lttng_ust_filter_bytecode_node
*bytecode
);
219 * Attach exclusion list to `struct lttng_event_notifier_enabler` and all
220 * event notifiers related to this enabler.
223 int lttng_event_notifier_enabler_attach_exclusion(
224 struct lttng_event_notifier_enabler
*event_notifier_enabler
,
225 struct lttng_ust_excluder_node
*excluder
);
228 void lttng_free_event_notifier_filter_runtime(
229 struct lttng_event_notifier
*event_notifier
);
232 * Connect the probe on all enablers matching this event description.
233 * Called on library load.
236 int lttng_fix_pending_event_notifiers(void);
238 #endif /* _LTTNG_UST_EVENTS_INTERNAL_H */