SoW-2020-0002: Trace Hit Counters: Implement key-addressed counters in shared memory...
[deliverable/lttng-ust.git] / liblttng-ust / ust-events-internal.h
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
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;
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
47 struct lttng_trigger_enabler {
48 struct lttng_enabler base;
49 uint64_t id;
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;
55 };
56
57 enum lttng_ust_bytecode_node_type{
58 LTTNG_UST_BYTECODE_NODE_TYPE_FILTER,
59 LTTNG_UST_BYTECODE_NODE_TYPE_CAPTURE,
60 };
61
62
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;
67 struct {
68 uint32_t len;
69 uint32_t reloc_offset;
70 uint64_t seqnum;
71 char data[];
72 } bc;
73 };
74
75 struct lttng_ust_excluder_node {
76 struct cds_list_head node;
77 struct lttng_enabler *enabler;
78 /*
79 * struct lttng_ust_event_exclusion had variable sized array,
80 * must be last field.
81 */
82 struct lttng_ust_event_exclusion excluder;
83 };
84
85 static inline
86 struct lttng_enabler *lttng_event_enabler_as_enabler(
87 struct lttng_event_enabler *event_enabler)
88 {
89 return &event_enabler->base;
90 }
91
92 static inline
93 struct lttng_enabler *lttng_trigger_enabler_as_enabler(
94 struct lttng_trigger_enabler *trigger_enabler)
95 {
96 return &trigger_enabler->base;
97 }
98
99 /*
100 * Allocate and initialize a `struct lttng_event_enabler` object.
101 *
102 * On success, returns a `struct lttng_event_enabler`,
103 * On memory error, returns NULL.
104 */
105 LTTNG_HIDDEN
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);
110
111 /*
112 * Destroy a `struct lttng_event_enabler` object.
113 */
114 LTTNG_HIDDEN
115 void lttng_event_enabler_destroy(struct lttng_event_enabler *enabler);
116
117 /*
118 * Enable a `struct lttng_event_enabler` object and all events related to this
119 * enabler.
120 */
121 LTTNG_HIDDEN
122 int lttng_event_enabler_enable(struct lttng_event_enabler *enabler);
123
124 /*
125 * Disable a `struct lttng_event_enabler` object and all events related to this
126 * enabler.
127 */
128 LTTNG_HIDDEN
129 int lttng_event_enabler_disable(struct lttng_event_enabler *enabler);
130
131 /*
132 * Attach filter bytecode program to `struct lttng_event_enabler` and all
133 * events related to this enabler.
134 */
135 LTTNG_HIDDEN
136 int lttng_event_enabler_attach_filter_bytecode(
137 struct lttng_event_enabler *enabler,
138 struct lttng_ust_bytecode_node *bytecode);
139
140 /*
141 * Attach an application context to an event enabler.
142 *
143 * Not implemented.
144 */
145 LTTNG_HIDDEN
146 int lttng_event_enabler_attach_context(struct lttng_event_enabler *enabler,
147 struct lttng_ust_context *ctx);
148
149 /*
150 * Attach exclusion list to `struct lttng_event_enabler` and all
151 * events related to this enabler.
152 */
153 LTTNG_HIDDEN
154 int lttng_event_enabler_attach_exclusion(struct lttng_event_enabler *enabler,
155 struct lttng_ust_excluder_node *excluder);
156
157 /*
158 * Synchronize bytecodes for the enabler and the instance (event or trigger).
159 *
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.
162 */
163 LTTNG_HIDDEN
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);
168
169 /*
170 * Allocate and initialize a `struct lttng_trigger_group` object.
171 *
172 * On success, returns a `struct lttng_triggre_group`,
173 * on memory error, returns NULL.
174 */
175 LTTNG_HIDDEN
176 struct lttng_trigger_group *lttng_trigger_group_create(void);
177
178 /*
179 * Destroy a `struct lttng_trigger_group` object.
180 */
181 LTTNG_HIDDEN
182 void lttng_trigger_group_destroy(
183 struct lttng_trigger_group *trigger_group);
184
185 /*
186 * Allocate and initialize a `struct lttng_trigger_enabler` object.
187 *
188 * On success, returns a `struct lttng_trigger_enabler`,
189 * On memory error, returns NULL.
190 */
191 LTTNG_HIDDEN
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);
196
197 /*
198 * Destroy a `struct lttng_trigger_enabler` object.
199 */
200 LTTNG_HIDDEN
201 void lttng_trigger_enabler_destroy(struct lttng_trigger_enabler *trigger_enabler);
202
203 /*
204 * Enable a `struct lttng_trigger_enabler` object and all triggers related to
205 * this enabler.
206 */
207 LTTNG_HIDDEN
208 int lttng_trigger_enabler_enable(struct lttng_trigger_enabler *trigger_enabler);
209
210 /*
211 * Disable a `struct lttng_trigger_enabler` object and all triggers related to
212 * this enabler.
213 */
214 LTTNG_HIDDEN
215 int lttng_trigger_enabler_disable(struct lttng_trigger_enabler *trigger_enabler);
216
217 /*
218 * Attach filter bytecode program to `struct lttng_trigger_enabler` and all
219 * triggers related to this enabler.
220 */
221 LTTNG_HIDDEN
222 int lttng_trigger_enabler_attach_filter_bytecode(
223 struct lttng_trigger_enabler *trigger_enabler,
224 struct lttng_ust_bytecode_node *bytecode);
225
226 /*
227 * Attach capture bytecode program to `struct lttng_trigger_enabler` and all
228 * triggers related to this enabler.
229 */
230 LTTNG_HIDDEN
231 int lttng_trigger_enabler_attach_capture_bytecode(
232 struct lttng_trigger_enabler *trigger_enabler,
233 struct lttng_ust_bytecode_node *bytecode);
234
235 /*
236 * Attach exclusion list to `struct lttng_trigger_enabler` and all
237 * triggers related to this enabler.
238 */
239 LTTNG_HIDDEN
240 int lttng_trigger_enabler_attach_exclusion(
241 struct lttng_trigger_enabler *trigger_enabler,
242 struct lttng_ust_excluder_node *excluder);
243
244 LTTNG_HIDDEN
245 void lttng_free_trigger_filter_runtime(struct lttng_trigger *trigger);
246
247 /*
248 * Connect the probe on all enablers matching this event description.
249 * Called on library load.
250 */
251 LTTNG_HIDDEN
252 int lttng_fix_pending_triggers(void);
253
254 #endif /* _LTTNG_UST_EVENTS_INTERNAL_H */
This page took 0.041096 seconds and 5 git commands to generate.