Move ust-events.h private functions to internal
[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
864a1eda 15#include <ust-helper.h>
d871c65b
FD
16#include <lttng/ust-events.h>
17
8665f6a4
MJ
18enum lttng_enabler_format_type {
19 LTTNG_ENABLER_FORMAT_STAR_GLOB,
20 LTTNG_ENABLER_FORMAT_EVENT,
21};
22
23/*
24 * Enabler field, within whatever object is enabling an event. Target of
25 * backward reference.
26 */
27struct lttng_enabler {
28 enum lttng_enabler_format_type format_type;
29
30 /* head list of struct lttng_ust_filter_bytecode_node */
31 struct cds_list_head filter_bytecode_head;
32 /* head list of struct lttng_ust_excluder_node */
33 struct cds_list_head excluder_head;
34
35 struct lttng_ust_event event_param;
36 unsigned int enabled:1;
37};
38
d871c65b
FD
39struct lttng_event_enabler {
40 struct lttng_enabler base;
41 struct cds_list_head node; /* per-session list of enablers */
42 struct lttng_channel *chan;
43 /*
44 * Unused, but kept around to make it explicit that the tracer can do
45 * it.
46 */
47 struct lttng_ctx *ctx;
48};
49
d8d2416d
FD
50struct lttng_event_notifier_enabler {
51 struct lttng_enabler base;
6566528b 52 uint64_t error_counter_index;
d37ecb3f
FD
53 struct cds_list_head node; /* per-app list of event_notifier enablers */
54 struct cds_list_head capture_bytecode_head;
d8d2416d
FD
55 struct lttng_event_notifier_group *group; /* weak ref */
56 uint64_t user_token; /* User-provided token */
d37ecb3f 57 uint64_t num_captures;
d8d2416d
FD
58};
59
ab249ecf
FD
60enum lttng_ust_bytecode_node_type {
61 LTTNG_UST_BYTECODE_NODE_TYPE_FILTER,
d37ecb3f 62 LTTNG_UST_BYTECODE_NODE_TYPE_CAPTURE,
ab249ecf
FD
63};
64
65struct lttng_ust_bytecode_node {
66 enum lttng_ust_bytecode_node_type type;
92495593
FD
67 struct cds_list_head node;
68 struct lttng_enabler *enabler;
ab249ecf
FD
69 struct {
70 uint32_t len;
71 uint32_t reloc_offset;
72 uint64_t seqnum;
73 char data[];
74 } bc;
92495593
FD
75};
76
77struct lttng_ust_excluder_node {
78 struct cds_list_head node;
79 struct lttng_enabler *enabler;
80 /*
81 * struct lttng_ust_event_exclusion had variable sized array,
82 * must be last field.
83 */
84 struct lttng_ust_event_exclusion excluder;
85};
86
d871c65b
FD
87static inline
88struct lttng_enabler *lttng_event_enabler_as_enabler(
89 struct lttng_event_enabler *event_enabler)
90{
91 return &event_enabler->base;
92}
93
d8d2416d
FD
94static inline
95struct lttng_enabler *lttng_event_notifier_enabler_as_enabler(
96 struct lttng_event_notifier_enabler *event_notifier_enabler)
97{
98 return &event_notifier_enabler->base;
99}
d871c65b
FD
100
101/*
102 * Allocate and initialize a `struct lttng_event_enabler` object.
103 *
104 * On success, returns a `struct lttng_event_enabler`,
105 * On memory error, returns NULL.
106 */
107LTTNG_HIDDEN
108struct lttng_event_enabler *lttng_event_enabler_create(
109 enum lttng_enabler_format_type format_type,
110 struct lttng_ust_event *event_param,
111 struct lttng_channel *chan);
112
113/*
114 * Destroy a `struct lttng_event_enabler` object.
115 */
116LTTNG_HIDDEN
117void lttng_event_enabler_destroy(struct lttng_event_enabler *enabler);
118
119/*
120 * Enable a `struct lttng_event_enabler` object and all events related to this
121 * enabler.
122 */
123LTTNG_HIDDEN
124int lttng_event_enabler_enable(struct lttng_event_enabler *enabler);
125
126/*
127 * Disable a `struct lttng_event_enabler` object and all events related to this
128 * enabler.
129 */
130LTTNG_HIDDEN
131int lttng_event_enabler_disable(struct lttng_event_enabler *enabler);
132
133/*
134 * Attach filter bytecode program to `struct lttng_event_enabler` and all
135 * events related to this enabler.
136 */
137LTTNG_HIDDEN
a56fd376
FD
138int lttng_event_enabler_attach_filter_bytecode(
139 struct lttng_event_enabler *enabler,
ab89263e 140 struct lttng_ust_bytecode_node **bytecode);
d871c65b
FD
141
142/*
143 * Attach an application context to an event enabler.
144 *
145 * Not implemented.
146 */
147LTTNG_HIDDEN
148int lttng_event_enabler_attach_context(struct lttng_event_enabler *enabler,
149 struct lttng_ust_context *ctx);
150
151/*
152 * Attach exclusion list to `struct lttng_event_enabler` and all
153 * events related to this enabler.
154 */
155LTTNG_HIDDEN
156int lttng_event_enabler_attach_exclusion(struct lttng_event_enabler *enabler,
e9fe6aad 157 struct lttng_ust_excluder_node **excluder);
d871c65b
FD
158
159/*
d37ecb3f
FD
160 * Synchronize bytecodes for the enabler and the instance (event or
161 * event_notifier).
d871c65b 162 *
621c07fc 163 * This function goes over all bytecode programs of the enabler (event or
d37ecb3f 164 * event_notifier enabler) to ensure each is linked to the provided instance.
d871c65b
FD
165 */
166LTTNG_HIDDEN
53b9d7db
FD
167void lttng_enabler_link_bytecode(const struct lttng_event_desc *event_desc,
168 struct lttng_ctx **ctx,
621c07fc
FD
169 struct cds_list_head *instance_bytecode_runtime_head,
170 struct cds_list_head *enabler_bytecode_runtime_head);
d871c65b 171
d8d2416d
FD
172/*
173 * Allocate and initialize a `struct lttng_event_notifier_group` object.
174 *
175 * On success, returns a `struct lttng_triggre_group`,
176 * on memory error, returns NULL.
177 */
178LTTNG_HIDDEN
179struct lttng_event_notifier_group *lttng_event_notifier_group_create(void);
180
181/*
182 * Destroy a `struct lttng_event_notifier_group` object.
183 */
184LTTNG_HIDDEN
185void lttng_event_notifier_group_destroy(
186 struct lttng_event_notifier_group *event_notifier_group);
187
188/*
189 * Allocate and initialize a `struct lttng_event_notifier_enabler` object.
190 *
191 * On success, returns a `struct lttng_event_notifier_enabler`,
192 * On memory error, returns NULL.
193 */
194LTTNG_HIDDEN
195struct lttng_event_notifier_enabler *lttng_event_notifier_enabler_create(
196 struct lttng_event_notifier_group *event_notifier_group,
197 enum lttng_enabler_format_type format_type,
198 struct lttng_ust_event_notifier *event_notifier_param);
199
200/*
201 * Destroy a `struct lttng_event_notifier_enabler` object.
202 */
203LTTNG_HIDDEN
204void lttng_event_notifier_enabler_destroy(
205 struct lttng_event_notifier_enabler *event_notifier_enabler);
206
207/*
208 * Enable a `struct lttng_event_notifier_enabler` object and all event
209 * notifiers related to this enabler.
210 */
211LTTNG_HIDDEN
212int lttng_event_notifier_enabler_enable(
213 struct lttng_event_notifier_enabler *event_notifier_enabler);
214
215/*
216 * Disable a `struct lttng_event_notifier_enabler` object and all event
217 * notifiers related to this enabler.
218 */
219LTTNG_HIDDEN
220int lttng_event_notifier_enabler_disable(
221 struct lttng_event_notifier_enabler *event_notifier_enabler);
222
223/*
224 * Attach filter bytecode program to `struct lttng_event_notifier_enabler` and
225 * all event notifiers related to this enabler.
226 */
227LTTNG_HIDDEN
a56fd376 228int lttng_event_notifier_enabler_attach_filter_bytecode(
d8d2416d 229 struct lttng_event_notifier_enabler *event_notifier_enabler,
ab89263e 230 struct lttng_ust_bytecode_node **bytecode);
d8d2416d 231
d37ecb3f
FD
232/*
233 * Attach capture bytecode program to `struct lttng_event_notifier_enabler` and
234 * all event_notifiers related to this enabler.
235 */
236LTTNG_HIDDEN
237int lttng_event_notifier_enabler_attach_capture_bytecode(
238 struct lttng_event_notifier_enabler *event_notifier_enabler,
49cde654 239 struct lttng_ust_bytecode_node **bytecode);
d37ecb3f 240
d8d2416d
FD
241/*
242 * Attach exclusion list to `struct lttng_event_notifier_enabler` and all
243 * event notifiers related to this enabler.
244 */
245LTTNG_HIDDEN
246int lttng_event_notifier_enabler_attach_exclusion(
247 struct lttng_event_notifier_enabler *event_notifier_enabler,
e9fe6aad 248 struct lttng_ust_excluder_node **excluder);
d8d2416d 249
7753d283
MJ
250LTTNG_HIDDEN
251void lttng_free_event_filter_runtime(struct lttng_event *event);
252
d8d2416d
FD
253LTTNG_HIDDEN
254void lttng_free_event_notifier_filter_runtime(
255 struct lttng_event_notifier *event_notifier);
256
257/*
258 * Connect the probe on all enablers matching this event description.
259 * Called on library load.
260 */
261LTTNG_HIDDEN
262int lttng_fix_pending_event_notifiers(void);
263
67d4e8f5
MJ
264LTTNG_HIDDEN
265struct lttng_counter *lttng_ust_counter_create(
266 const char *counter_transport_name,
267 size_t number_dimensions, const struct lttng_counter_dimension *dimensions);
268
bd8c1787
MJ
269#ifdef HAVE_PERF_EVENT
270
271LTTNG_HIDDEN
272int lttng_add_perf_counter_to_ctx(uint32_t type,
273 uint64_t config,
274 const char *name,
275 struct lttng_ctx **ctx);
276LTTNG_HIDDEN
277int lttng_perf_counter_init(void);
278LTTNG_HIDDEN
279void lttng_perf_counter_exit(void);
280
281#else /* #ifdef HAVE_PERF_EVENT */
282
283static inline
284int lttng_add_perf_counter_to_ctx(uint32_t type,
285 uint64_t config,
286 const char *name,
287 struct lttng_ctx **ctx)
288{
289 return -ENOSYS;
290}
291static inline
292int lttng_perf_counter_init(void)
293{
294 return 0;
295}
296static inline
297void lttng_perf_counter_exit(void)
298{
299}
300#endif /* #else #ifdef HAVE_PERF_EVENT */
301
7753d283
MJ
302LTTNG_HIDDEN
303int lttng_probes_get_event_list(struct lttng_ust_tracepoint_list *list);
304LTTNG_HIDDEN
305void lttng_probes_prune_event_list(struct lttng_ust_tracepoint_list *list);
306
307LTTNG_HIDDEN
308int lttng_probes_get_field_list(struct lttng_ust_field_list *list);
309LTTNG_HIDDEN
310void lttng_probes_prune_field_list(struct lttng_ust_field_list *list);
311
312LTTNG_HIDDEN
313struct lttng_ust_tracepoint_iter *
314 lttng_ust_tracepoint_list_get_iter_next(struct lttng_ust_tracepoint_list *list);
315LTTNG_HIDDEN
316struct lttng_ust_field_iter *
317 lttng_ust_field_list_get_iter_next(struct lttng_ust_field_list *list);
318
319LTTNG_HIDDEN
320struct lttng_session *lttng_session_create(void);
321LTTNG_HIDDEN
322int lttng_session_enable(struct lttng_session *session);
323LTTNG_HIDDEN
324int lttng_session_disable(struct lttng_session *session);
325LTTNG_HIDDEN
326int lttng_session_statedump(struct lttng_session *session);
327LTTNG_HIDDEN
328void lttng_session_destroy(struct lttng_session *session);
329
330LTTNG_HIDDEN
331struct cds_list_head *lttng_get_sessions(void);
332
333LTTNG_HIDDEN
334void lttng_handle_pending_statedump(void *owner);
335
336LTTNG_HIDDEN
337struct lttng_channel *lttng_channel_create(struct lttng_session *session,
338 const char *transport_name,
339 void *buf_addr,
340 size_t subbuf_size, size_t num_subbuf,
341 unsigned int switch_timer_interval,
342 unsigned int read_timer_interval,
343 int **shm_fd, int **wait_fd,
344 uint64_t **memory_map_size,
345 struct lttng_channel *chan_priv_init);
346
347LTTNG_HIDDEN
348int lttng_channel_enable(struct lttng_channel *channel);
349LTTNG_HIDDEN
350int lttng_channel_disable(struct lttng_channel *channel);
351
352LTTNG_HIDDEN
353void lttng_transport_register(struct lttng_transport *transport);
354LTTNG_HIDDEN
355void lttng_transport_unregister(struct lttng_transport *transport);
356
357LTTNG_HIDDEN
358void lttng_probe_provider_unregister_events(struct lttng_probe_desc *desc);
359
360LTTNG_HIDDEN
361int lttng_fix_pending_events(void);
362
363LTTNG_HIDDEN
364struct cds_list_head *lttng_get_probe_list_head(void);
365
366LTTNG_HIDDEN
367struct lttng_enum *lttng_ust_enum_get_from_desc(struct lttng_session *session,
368 const struct lttng_enum_desc *enum_desc);
369
d871c65b 370#endif /* _LTTNG_UST_EVENTS_INTERNAL_H */
This page took 0.053529 seconds and 4 git commands to generate.