SoW-2020-0002: Trace Hit Counters
[deliverable/lttng-ust.git] / liblttng-ust / ust-events-internal.h
... / ...
CommitLineData
1/*
2 * SPDX-License-Identifier: MIT
3 *
4 * Copyright 2019 (c) Francis Deslauriers <francis.deslauriers@efficios.com>
5 */
6
7#ifndef _LTTNG_UST_EVENTS_INTERNAL_H
8#define _LTTNG_UST_EVENTS_INTERNAL_H
9
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
18/*
19 * Enabler field, within whatever object is enabling an event. Target of
20 * backward reference.
21 */
22struct lttng_enabler {
23 enum lttng_enabler_format_type format_type;
24
25 /* head list of struct lttng_ust_filter_bytecode_node */
26 struct cds_list_head filter_bytecode_head;
27 /* head list of struct lttng_ust_excluder_node */
28 struct cds_list_head excluder_head;
29
30 struct lttng_ust_event event_param;
31 unsigned int enabled:1;
32
33 uint64_t user_token; /* User-provided token */
34};
35
36struct lttng_event_enabler {
37 struct lttng_enabler base;
38 struct cds_list_head node; /* per-session list of enablers */
39 struct lttng_event_container *container;
40 struct lttng_counter_key key;
41 /*
42 * Unused, but kept around to make it explicit that the tracer can do
43 * it.
44 */
45 struct lttng_ctx *ctx;
46};
47
48struct lttng_event_notifier_enabler {
49 struct lttng_enabler base;
50 uint64_t error_counter_index;
51 struct cds_list_head node; /* per-app list of event_notifier enablers */
52 struct cds_list_head capture_bytecode_head;
53 struct lttng_event_notifier_group *group; /* weak ref */
54 uint64_t num_captures;
55};
56
57enum lttng_ust_bytecode_node_type {
58 LTTNG_UST_BYTECODE_NODE_TYPE_FILTER,
59 LTTNG_UST_BYTECODE_NODE_TYPE_CAPTURE,
60};
61
62struct lttng_ust_bytecode_node {
63 enum lttng_ust_bytecode_node_type type;
64 struct cds_list_head node;
65 struct lttng_enabler *enabler;
66 struct {
67 uint32_t len;
68 uint32_t reloc_offset;
69 uint64_t seqnum;
70 char data[];
71 } bc;
72};
73
74struct lttng_ust_excluder_node {
75 struct cds_list_head node;
76 struct lttng_enabler *enabler;
77 /*
78 * struct lttng_ust_event_exclusion had variable sized array,
79 * must be last field.
80 */
81 struct lttng_ust_event_exclusion excluder;
82};
83
84static inline
85struct lttng_enabler *lttng_event_enabler_as_enabler(
86 struct lttng_event_enabler *event_enabler)
87{
88 return &event_enabler->base;
89}
90
91static inline
92struct lttng_enabler *lttng_event_notifier_enabler_as_enabler(
93 struct lttng_event_notifier_enabler *event_notifier_enabler)
94{
95 return &event_notifier_enabler->base;
96}
97
98/*
99 * Allocate and initialize a `struct lttng_event_enabler` object.
100 *
101 * On success, returns a `struct lttng_event_enabler`,
102 * On memory error, returns NULL.
103 */
104LTTNG_HIDDEN
105struct lttng_event_enabler *lttng_event_enabler_create(
106 enum lttng_enabler_format_type format_type,
107 struct lttng_ust_event *event_param,
108 const struct lttng_ust_counter_key *key,
109 struct lttng_event_container *container);
110
111/*
112 * Destroy a `struct lttng_event_enabler` object.
113 */
114LTTNG_HIDDEN
115void 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 */
121LTTNG_HIDDEN
122int 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 */
128LTTNG_HIDDEN
129int 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 */
135LTTNG_HIDDEN
136int 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 */
145LTTNG_HIDDEN
146int 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 */
153LTTNG_HIDDEN
154int 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
159 * event_notifier).
160 *
161 * This function goes over all bytecode programs of the enabler (event or
162 * event_notifier enabler) to ensure each is linked to the provided instance.
163 */
164LTTNG_HIDDEN
165void lttng_enabler_link_bytecode(const struct lttng_event_desc *event_desc,
166 struct lttng_ctx **ctx,
167 struct cds_list_head *instance_bytecode_runtime_head,
168 struct cds_list_head *enabler_bytecode_runtime_head);
169
170/*
171 * Allocate and initialize a `struct lttng_event_notifier_group` object.
172 *
173 * On success, returns a `struct lttng_triggre_group`,
174 * on memory error, returns NULL.
175 */
176LTTNG_HIDDEN
177struct lttng_event_notifier_group *lttng_event_notifier_group_create(void);
178
179/*
180 * Destroy a `struct lttng_event_notifier_group` object.
181 */
182LTTNG_HIDDEN
183void lttng_event_notifier_group_destroy(
184 struct lttng_event_notifier_group *event_notifier_group);
185
186/*
187 * Allocate and initialize a `struct lttng_event_notifier_enabler` object.
188 *
189 * On success, returns a `struct lttng_event_notifier_enabler`,
190 * On memory error, returns NULL.
191 */
192LTTNG_HIDDEN
193struct lttng_event_notifier_enabler *lttng_event_notifier_enabler_create(
194 struct lttng_event_notifier_group *event_notifier_group,
195 enum lttng_enabler_format_type format_type,
196 struct lttng_ust_event_notifier *event_notifier_param);
197
198/*
199 * Destroy a `struct lttng_event_notifier_enabler` object.
200 */
201LTTNG_HIDDEN
202void lttng_event_notifier_enabler_destroy(
203 struct lttng_event_notifier_enabler *event_notifier_enabler);
204
205/*
206 * Enable a `struct lttng_event_notifier_enabler` object and all event
207 * notifiers related to this enabler.
208 */
209LTTNG_HIDDEN
210int lttng_event_notifier_enabler_enable(
211 struct lttng_event_notifier_enabler *event_notifier_enabler);
212
213/*
214 * Disable a `struct lttng_event_notifier_enabler` object and all event
215 * notifiers related to this enabler.
216 */
217LTTNG_HIDDEN
218int lttng_event_notifier_enabler_disable(
219 struct lttng_event_notifier_enabler *event_notifier_enabler);
220
221/*
222 * Attach filter bytecode program to `struct lttng_event_notifier_enabler` and
223 * all event notifiers related to this enabler.
224 */
225LTTNG_HIDDEN
226int lttng_event_notifier_enabler_attach_filter_bytecode(
227 struct lttng_event_notifier_enabler *event_notifier_enabler,
228 struct lttng_ust_bytecode_node **bytecode);
229
230/*
231 * Attach capture bytecode program to `struct lttng_event_notifier_enabler` and
232 * all event_notifiers related to this enabler.
233 */
234LTTNG_HIDDEN
235int lttng_event_notifier_enabler_attach_capture_bytecode(
236 struct lttng_event_notifier_enabler *event_notifier_enabler,
237 struct lttng_ust_bytecode_node **bytecode);
238
239/*
240 * Attach exclusion list to `struct lttng_event_notifier_enabler` and all
241 * event notifiers related to this enabler.
242 */
243LTTNG_HIDDEN
244int lttng_event_notifier_enabler_attach_exclusion(
245 struct lttng_event_notifier_enabler *event_notifier_enabler,
246 struct lttng_ust_excluder_node **excluder);
247
248LTTNG_HIDDEN
249void lttng_free_event_notifier_filter_runtime(
250 struct lttng_event_notifier *event_notifier);
251
252/*
253 * Connect the probe on all enablers matching this event description.
254 * Called on library load.
255 */
256LTTNG_HIDDEN
257int lttng_fix_pending_event_notifiers(void);
258
259LTTNG_HIDDEN
260struct lttng_counter *lttng_ust_counter_create(
261 const char *counter_transport_name,
262 size_t number_dimensions,
263 const size_t *max_nr_elem,
264 int64_t global_sum_step,
265 bool coalesce_hits);
266
267LTTNG_HIDDEN
268struct lttng_counter *lttng_session_create_counter(
269 struct lttng_session *session,
270 const char *counter_transport_name,
271 size_t number_dimensions, const size_t *dimensions_sizes,
272 int64_t global_sum_step, bool coalesce_hits);
273
274#endif /* _LTTNG_UST_EVENTS_INTERNAL_H */
This page took 0.033829 seconds and 5 git commands to generate.