Move to kernel style SPDX license identifiers
[lttng-ust.git] / liblttng-ust / ust-events-internal.h
CommitLineData
d871c65b 1/*
c0c0989a 2 * SPDX-License-Identifier: MIT
d871c65b 3 *
c0c0989a 4 * Copyright 2019 (c) Francis Deslauriers <francis.deslauriers@efficios.com>
d871c65b
FD
5 */
6
c0c0989a
MJ
7#ifndef _LTTNG_UST_EVENTS_INTERNAL_H
8#define _LTTNG_UST_EVENTS_INTERNAL_H
9
d871c65b
FD
10#include <stdint.h>
11
12#include <urcu/list.h>
13#include <urcu/hlist.h>
14
15#include <helper.h>
16#include <lttng/ust-events.h>
17
18struct lttng_event_enabler {
19 struct lttng_enabler base;
20 struct cds_list_head node; /* per-session list of enablers */
21 struct lttng_channel *chan;
22 /*
23 * Unused, but kept around to make it explicit that the tracer can do
24 * it.
25 */
26 struct lttng_ctx *ctx;
27};
28
d8d2416d
FD
29struct lttng_event_notifier_enabler {
30 struct lttng_enabler base;
6566528b 31 uint64_t error_counter_index;
d37ecb3f
FD
32 struct cds_list_head node; /* per-app list of event_notifier enablers */
33 struct cds_list_head capture_bytecode_head;
d8d2416d
FD
34 struct lttng_event_notifier_group *group; /* weak ref */
35 uint64_t user_token; /* User-provided token */
d37ecb3f 36 uint64_t num_captures;
d8d2416d
FD
37};
38
ab249ecf
FD
39enum lttng_ust_bytecode_node_type {
40 LTTNG_UST_BYTECODE_NODE_TYPE_FILTER,
d37ecb3f 41 LTTNG_UST_BYTECODE_NODE_TYPE_CAPTURE,
ab249ecf
FD
42};
43
44struct lttng_ust_bytecode_node {
45 enum lttng_ust_bytecode_node_type type;
92495593
FD
46 struct cds_list_head node;
47 struct lttng_enabler *enabler;
ab249ecf
FD
48 struct {
49 uint32_t len;
50 uint32_t reloc_offset;
51 uint64_t seqnum;
52 char data[];
53 } bc;
92495593
FD
54};
55
56struct lttng_ust_excluder_node {
57 struct cds_list_head node;
58 struct lttng_enabler *enabler;
59 /*
60 * struct lttng_ust_event_exclusion had variable sized array,
61 * must be last field.
62 */
63 struct lttng_ust_event_exclusion excluder;
64};
65
d871c65b
FD
66static inline
67struct lttng_enabler *lttng_event_enabler_as_enabler(
68 struct lttng_event_enabler *event_enabler)
69{
70 return &event_enabler->base;
71}
72
d8d2416d
FD
73static inline
74struct lttng_enabler *lttng_event_notifier_enabler_as_enabler(
75 struct lttng_event_notifier_enabler *event_notifier_enabler)
76{
77 return &event_notifier_enabler->base;
78}
d871c65b
FD
79
80/*
81 * Allocate and initialize a `struct lttng_event_enabler` object.
82 *
83 * On success, returns a `struct lttng_event_enabler`,
84 * On memory error, returns NULL.
85 */
86LTTNG_HIDDEN
87struct 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);
91
92/*
93 * Destroy a `struct lttng_event_enabler` object.
94 */
95LTTNG_HIDDEN
96void lttng_event_enabler_destroy(struct lttng_event_enabler *enabler);
97
98/*
99 * Enable a `struct lttng_event_enabler` object and all events related to this
100 * enabler.
101 */
102LTTNG_HIDDEN
103int lttng_event_enabler_enable(struct lttng_event_enabler *enabler);
104
105/*
106 * Disable a `struct lttng_event_enabler` object and all events related to this
107 * enabler.
108 */
109LTTNG_HIDDEN
110int lttng_event_enabler_disable(struct lttng_event_enabler *enabler);
111
112/*
113 * Attach filter bytecode program to `struct lttng_event_enabler` and all
114 * events related to this enabler.
115 */
116LTTNG_HIDDEN
a56fd376
FD
117int lttng_event_enabler_attach_filter_bytecode(
118 struct lttng_event_enabler *enabler,
ab89263e 119 struct lttng_ust_bytecode_node **bytecode);
d871c65b
FD
120
121/*
122 * Attach an application context to an event enabler.
123 *
124 * Not implemented.
125 */
126LTTNG_HIDDEN
127int lttng_event_enabler_attach_context(struct lttng_event_enabler *enabler,
128 struct lttng_ust_context *ctx);
129
130/*
131 * Attach exclusion list to `struct lttng_event_enabler` and all
132 * events related to this enabler.
133 */
134LTTNG_HIDDEN
135int lttng_event_enabler_attach_exclusion(struct lttng_event_enabler *enabler,
e9fe6aad 136 struct lttng_ust_excluder_node **excluder);
d871c65b
FD
137
138/*
d37ecb3f
FD
139 * Synchronize bytecodes for the enabler and the instance (event or
140 * event_notifier).
d871c65b 141 *
621c07fc 142 * This function goes over all bytecode programs of the enabler (event or
d37ecb3f 143 * event_notifier enabler) to ensure each is linked to the provided instance.
d871c65b
FD
144 */
145LTTNG_HIDDEN
53b9d7db
FD
146void lttng_enabler_link_bytecode(const struct lttng_event_desc *event_desc,
147 struct lttng_ctx **ctx,
621c07fc
FD
148 struct cds_list_head *instance_bytecode_runtime_head,
149 struct cds_list_head *enabler_bytecode_runtime_head);
d871c65b 150
d8d2416d
FD
151/*
152 * Allocate and initialize a `struct lttng_event_notifier_group` object.
153 *
154 * On success, returns a `struct lttng_triggre_group`,
155 * on memory error, returns NULL.
156 */
157LTTNG_HIDDEN
158struct lttng_event_notifier_group *lttng_event_notifier_group_create(void);
159
160/*
161 * Destroy a `struct lttng_event_notifier_group` object.
162 */
163LTTNG_HIDDEN
164void lttng_event_notifier_group_destroy(
165 struct lttng_event_notifier_group *event_notifier_group);
166
167/*
168 * Allocate and initialize a `struct lttng_event_notifier_enabler` object.
169 *
170 * On success, returns a `struct lttng_event_notifier_enabler`,
171 * On memory error, returns NULL.
172 */
173LTTNG_HIDDEN
174struct 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);
178
179/*
180 * Destroy a `struct lttng_event_notifier_enabler` object.
181 */
182LTTNG_HIDDEN
183void lttng_event_notifier_enabler_destroy(
184 struct lttng_event_notifier_enabler *event_notifier_enabler);
185
186/*
187 * Enable a `struct lttng_event_notifier_enabler` object and all event
188 * notifiers related to this enabler.
189 */
190LTTNG_HIDDEN
191int lttng_event_notifier_enabler_enable(
192 struct lttng_event_notifier_enabler *event_notifier_enabler);
193
194/*
195 * Disable a `struct lttng_event_notifier_enabler` object and all event
196 * notifiers related to this enabler.
197 */
198LTTNG_HIDDEN
199int lttng_event_notifier_enabler_disable(
200 struct lttng_event_notifier_enabler *event_notifier_enabler);
201
202/*
203 * Attach filter bytecode program to `struct lttng_event_notifier_enabler` and
204 * all event notifiers related to this enabler.
205 */
206LTTNG_HIDDEN
a56fd376 207int lttng_event_notifier_enabler_attach_filter_bytecode(
d8d2416d 208 struct lttng_event_notifier_enabler *event_notifier_enabler,
ab89263e 209 struct lttng_ust_bytecode_node **bytecode);
d8d2416d 210
d37ecb3f
FD
211/*
212 * Attach capture bytecode program to `struct lttng_event_notifier_enabler` and
213 * all event_notifiers related to this enabler.
214 */
215LTTNG_HIDDEN
216int lttng_event_notifier_enabler_attach_capture_bytecode(
217 struct lttng_event_notifier_enabler *event_notifier_enabler,
49cde654 218 struct lttng_ust_bytecode_node **bytecode);
d37ecb3f 219
d8d2416d
FD
220/*
221 * Attach exclusion list to `struct lttng_event_notifier_enabler` and all
222 * event notifiers related to this enabler.
223 */
224LTTNG_HIDDEN
225int lttng_event_notifier_enabler_attach_exclusion(
226 struct lttng_event_notifier_enabler *event_notifier_enabler,
e9fe6aad 227 struct lttng_ust_excluder_node **excluder);
d8d2416d
FD
228
229LTTNG_HIDDEN
230void lttng_free_event_notifier_filter_runtime(
231 struct lttng_event_notifier *event_notifier);
232
233/*
234 * Connect the probe on all enablers matching this event description.
235 * Called on library load.
236 */
237LTTNG_HIDDEN
238int lttng_fix_pending_event_notifiers(void);
239
67d4e8f5
MJ
240LTTNG_HIDDEN
241struct lttng_counter *lttng_ust_counter_create(
242 const char *counter_transport_name,
243 size_t number_dimensions, const struct lttng_counter_dimension *dimensions);
244
d871c65b 245#endif /* _LTTNG_UST_EVENTS_INTERNAL_H */
This page took 0.032356 seconds and 4 git commands to generate.