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_trigger_enabler
{
48 struct lttng_enabler base
;
50 uint64_t error_counter_index
;
51 struct cds_list_head node
; /* per-app list of trigger enablers */
52 struct cds_list_head capture_bytecode_head
;
53 struct lttng_trigger_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
,
63 struct lttng_ust_bytecode_node
{
64 enum lttng_ust_bytecode_node_type type
;
65 struct cds_list_head node
;
66 struct lttng_enabler
*enabler
;
69 uint32_t reloc_offset
;
75 struct lttng_ust_excluder_node
{
76 struct cds_list_head node
;
77 struct lttng_enabler
*enabler
;
79 * struct lttng_ust_event_exclusion had variable sized array,
82 struct lttng_ust_event_exclusion excluder
;
86 struct lttng_enabler
*lttng_event_enabler_as_enabler(
87 struct lttng_event_enabler
*event_enabler
)
89 return &event_enabler
->base
;
93 struct lttng_enabler
*lttng_trigger_enabler_as_enabler(
94 struct lttng_trigger_enabler
*trigger_enabler
)
96 return &trigger_enabler
->base
;
100 * Allocate and initialize a `struct lttng_event_enabler` object.
102 * On success, returns a `struct lttng_event_enabler`,
103 * On memory error, returns NULL.
106 struct lttng_event_enabler
*lttng_event_enabler_create(
107 enum lttng_enabler_format_type format_type
,
108 struct lttng_ust_event
*event_param
,
109 struct lttng_channel
*chan
);
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 trigger).
160 * This function goes over all bytecode programs of the enabler (event or
161 * trigger enabler) to ensure each is linked to the provided instance.
164 void lttng_enabler_link_bytecode(const struct lttng_event_desc
*event_desc
,
165 struct lttng_ctx
**ctx
,
166 struct cds_list_head
*instance_bytecode_runtime_head
,
167 struct cds_list_head
*enabler_bytecode_runtime_head
);
170 * Allocate and initialize a `struct lttng_trigger_group` object.
172 * On success, returns a `struct lttng_triggre_group`,
173 * on memory error, returns NULL.
176 struct lttng_trigger_group
*lttng_trigger_group_create(void);
179 * Destroy a `struct lttng_trigger_group` object.
182 void lttng_trigger_group_destroy(
183 struct lttng_trigger_group
*trigger_group
);
186 * Allocate and initialize a `struct lttng_trigger_enabler` object.
188 * On success, returns a `struct lttng_trigger_enabler`,
189 * On memory error, returns NULL.
192 struct lttng_trigger_enabler
*lttng_trigger_enabler_create(
193 struct lttng_trigger_group
*trigger_group
,
194 enum lttng_enabler_format_type format_type
,
195 struct lttng_ust_trigger
*trigger_param
);
198 * Destroy a `struct lttng_trigger_enabler` object.
201 void lttng_trigger_enabler_destroy(struct lttng_trigger_enabler
*trigger_enabler
);
204 * Enable a `struct lttng_trigger_enabler` object and all triggers related to
208 int lttng_trigger_enabler_enable(struct lttng_trigger_enabler
*trigger_enabler
);
211 * Disable a `struct lttng_trigger_enabler` object and all triggers related to
215 int lttng_trigger_enabler_disable(struct lttng_trigger_enabler
*trigger_enabler
);
218 * Attach filter bytecode program to `struct lttng_trigger_enabler` and all
219 * triggers related to this enabler.
222 int lttng_trigger_enabler_attach_filter_bytecode(
223 struct lttng_trigger_enabler
*trigger_enabler
,
224 struct lttng_ust_bytecode_node
*bytecode
);
227 * Attach capture bytecode program to `struct lttng_trigger_enabler` and all
228 * triggers related to this enabler.
231 int lttng_trigger_enabler_attach_capture_bytecode(
232 struct lttng_trigger_enabler
*trigger_enabler
,
233 struct lttng_ust_bytecode_node
*bytecode
);
236 * Attach exclusion list to `struct lttng_trigger_enabler` and all
237 * triggers related to this enabler.
240 int lttng_trigger_enabler_attach_exclusion(
241 struct lttng_trigger_enabler
*trigger_enabler
,
242 struct lttng_ust_excluder_node
*excluder
);
245 void lttng_free_trigger_filter_runtime(struct lttng_trigger
*trigger
);
248 * Connect the probe on all enablers matching this event description.
249 * Called on library load.
252 int lttng_fix_pending_triggers(void);
254 #endif /* _LTTNG_UST_EVENTS_INTERNAL_H */