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