Decouple `struct lttng_event` from filter code
[deliverable/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
92495593
FD
47struct lttng_ust_filter_bytecode_node {
48 struct cds_list_head node;
49 struct lttng_enabler *enabler;
50 /*
51 * struct lttng_ust_filter_bytecode has var. sized array, must
52 * be last field.
53 */
54 struct lttng_ust_filter_bytecode bc;
55};
56
57struct lttng_ust_excluder_node {
58 struct cds_list_head node;
59 struct lttng_enabler *enabler;
60 /*
61 * struct lttng_ust_event_exclusion had variable sized array,
62 * must be last field.
63 */
64 struct lttng_ust_event_exclusion excluder;
65};
66
d871c65b
FD
67static inline
68struct lttng_enabler *lttng_event_enabler_as_enabler(
69 struct lttng_event_enabler *event_enabler)
70{
71 return &event_enabler->base;
72}
73
74
75/*
76 * Allocate and initialize a `struct lttng_event_enabler` object.
77 *
78 * On success, returns a `struct lttng_event_enabler`,
79 * On memory error, returns NULL.
80 */
81LTTNG_HIDDEN
82struct lttng_event_enabler *lttng_event_enabler_create(
83 enum lttng_enabler_format_type format_type,
84 struct lttng_ust_event *event_param,
85 struct lttng_channel *chan);
86
87/*
88 * Destroy a `struct lttng_event_enabler` object.
89 */
90LTTNG_HIDDEN
91void lttng_event_enabler_destroy(struct lttng_event_enabler *enabler);
92
93/*
94 * Enable a `struct lttng_event_enabler` object and all events related to this
95 * enabler.
96 */
97LTTNG_HIDDEN
98int lttng_event_enabler_enable(struct lttng_event_enabler *enabler);
99
100/*
101 * Disable a `struct lttng_event_enabler` object and all events related to this
102 * enabler.
103 */
104LTTNG_HIDDEN
105int lttng_event_enabler_disable(struct lttng_event_enabler *enabler);
106
107/*
108 * Attach filter bytecode program to `struct lttng_event_enabler` and all
109 * events related to this enabler.
110 */
111LTTNG_HIDDEN
112int lttng_event_enabler_attach_bytecode(struct lttng_event_enabler *enabler,
113 struct lttng_ust_filter_bytecode_node *bytecode);
114
115/*
116 * Attach an application context to an event enabler.
117 *
118 * Not implemented.
119 */
120LTTNG_HIDDEN
121int lttng_event_enabler_attach_context(struct lttng_event_enabler *enabler,
122 struct lttng_ust_context *ctx);
123
124/*
125 * Attach exclusion list to `struct lttng_event_enabler` and all
126 * events related to this enabler.
127 */
128LTTNG_HIDDEN
129int lttng_event_enabler_attach_exclusion(struct lttng_event_enabler *enabler,
130 struct lttng_ust_excluder_node *excluder);
131
132/*
133 * Synchronize bytecodes for the enabler and the event.
134 *
135 * This function goes over all bytecode programs of the event enabler to ensure
136 * each is linked to the provided event.
137 */
138LTTNG_HIDDEN
53b9d7db
FD
139void lttng_enabler_link_bytecode(const struct lttng_event_desc *event_desc,
140 struct lttng_ctx **ctx,
141 struct cds_list_head *bytecode_runtime_head,
142 struct lttng_enabler *enabler);
d871c65b
FD
143
144#endif /* _LTTNG_UST_EVENTS_INTERNAL_H */
This page took 0.061297 seconds and 5 git commands to generate.