Rename filter string to filter expression in liblttng-ctl
[lttng-tools.git] / include / lttng / event.h
1 /*
2 * Copyright (C) 2014 - David Goulet <dgoulet@efficios.com>
3 * Copyright (C) 2016 - Jérémie Galarneau <jeremie.galarneau@efficios.com>
4 *
5 * This library is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU Lesser General Public License, version 2.1 only,
7 * as published by the Free Software Foundation.
8 *
9 * This library is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
12 * for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with this library; if not, write to the Free Software Foundation,
16 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18
19 #ifndef LTTNG_EVENT_H
20 #define LTTNG_EVENT_H
21
22 #ifdef __cplusplus
23 extern "C" {
24 #endif
25
26 #include <lttng/handle.h>
27
28 /*
29 * Instrumentation type of tracing event.
30 */
31 enum lttng_event_type {
32 LTTNG_EVENT_ALL = -1,
33 LTTNG_EVENT_TRACEPOINT = 0,
34 LTTNG_EVENT_PROBE = 1,
35 LTTNG_EVENT_FUNCTION = 2,
36 LTTNG_EVENT_FUNCTION_ENTRY = 3,
37 LTTNG_EVENT_NOOP = 4,
38 LTTNG_EVENT_SYSCALL = 5,
39 };
40
41 /*
42 * Loglevel information.
43 */
44 enum lttng_loglevel_type {
45 LTTNG_EVENT_LOGLEVEL_ALL = 0,
46 LTTNG_EVENT_LOGLEVEL_RANGE = 1,
47 LTTNG_EVENT_LOGLEVEL_SINGLE = 2,
48 };
49
50 /*
51 * Available loglevels.
52 */
53 enum lttng_loglevel {
54 LTTNG_LOGLEVEL_EMERG = 0,
55 LTTNG_LOGLEVEL_ALERT = 1,
56 LTTNG_LOGLEVEL_CRIT = 2,
57 LTTNG_LOGLEVEL_ERR = 3,
58 LTTNG_LOGLEVEL_WARNING = 4,
59 LTTNG_LOGLEVEL_NOTICE = 5,
60 LTTNG_LOGLEVEL_INFO = 6,
61 LTTNG_LOGLEVEL_DEBUG_SYSTEM = 7,
62 LTTNG_LOGLEVEL_DEBUG_PROGRAM = 8,
63 LTTNG_LOGLEVEL_DEBUG_PROCESS = 9,
64 LTTNG_LOGLEVEL_DEBUG_MODULE = 10,
65 LTTNG_LOGLEVEL_DEBUG_UNIT = 11,
66 LTTNG_LOGLEVEL_DEBUG_FUNCTION = 12,
67 LTTNG_LOGLEVEL_DEBUG_LINE = 13,
68 LTTNG_LOGLEVEL_DEBUG = 14,
69 };
70
71 /*
72 * Available loglevels for the JUL domain. Those are an exact map from the
73 * class java.util.logging.Level.
74 */
75 enum lttng_loglevel_jul {
76 LTTNG_LOGLEVEL_JUL_OFF = INT32_MAX,
77 LTTNG_LOGLEVEL_JUL_SEVERE = 1000,
78 LTTNG_LOGLEVEL_JUL_WARNING = 900,
79 LTTNG_LOGLEVEL_JUL_INFO = 800,
80 LTTNG_LOGLEVEL_JUL_CONFIG = 700,
81 LTTNG_LOGLEVEL_JUL_FINE = 500,
82 LTTNG_LOGLEVEL_JUL_FINER = 400,
83 LTTNG_LOGLEVEL_JUL_FINEST = 300,
84 LTTNG_LOGLEVEL_JUL_ALL = INT32_MIN,
85 };
86
87 /*
88 * Available loglevels for the LOG4j domain. Those are an exact map from the
89 * class org.apache.log4j.Level.
90 */
91 enum lttng_loglevel_log4j {
92 LTTNG_LOGLEVEL_LOG4J_OFF = INT32_MAX,
93 LTTNG_LOGLEVEL_LOG4J_FATAL = 50000,
94 LTTNG_LOGLEVEL_LOG4J_ERROR = 40000,
95 LTTNG_LOGLEVEL_LOG4J_WARN = 30000,
96 LTTNG_LOGLEVEL_LOG4J_INFO = 20000,
97 LTTNG_LOGLEVEL_LOG4J_DEBUG = 10000,
98 LTTNG_LOGLEVEL_LOG4J_TRACE = 5000,
99 LTTNG_LOGLEVEL_LOG4J_ALL = INT32_MIN,
100 };
101
102 /*
103 * Available loglevels for the Python domain. Those are an exact map from the
104 * Level class.
105 */
106 enum lttng_loglevel_python {
107 LTTNG_LOGLEVEL_PYTHON_CRITICAL = 50,
108 LTTNG_LOGLEVEL_PYTHON_ERROR = 40,
109 LTTNG_LOGLEVEL_PYTHON_WARNING = 30,
110 LTTNG_LOGLEVEL_PYTHON_INFO = 20,
111 LTTNG_LOGLEVEL_PYTHON_DEBUG = 10,
112 LTTNG_LOGLEVEL_PYTHON_NOTSET = 0,
113 };
114
115 /*
116 * LTTng consumer mode
117 */
118 enum lttng_event_output {
119 LTTNG_EVENT_SPLICE = 0,
120 LTTNG_EVENT_MMAP = 1,
121 };
122
123 /* Event context possible type */
124 enum lttng_event_context_type {
125 LTTNG_EVENT_CONTEXT_PID = 0,
126 LTTNG_EVENT_CONTEXT_PERF_COUNTER = 1, /* Backward compat. */
127 LTTNG_EVENT_CONTEXT_PROCNAME = 2,
128 LTTNG_EVENT_CONTEXT_PRIO = 3,
129 LTTNG_EVENT_CONTEXT_NICE = 4,
130 LTTNG_EVENT_CONTEXT_VPID = 5,
131 LTTNG_EVENT_CONTEXT_TID = 6,
132 LTTNG_EVENT_CONTEXT_VTID = 7,
133 LTTNG_EVENT_CONTEXT_PPID = 8,
134 LTTNG_EVENT_CONTEXT_VPPID = 9,
135 LTTNG_EVENT_CONTEXT_PTHREAD_ID = 10,
136 LTTNG_EVENT_CONTEXT_HOSTNAME = 11,
137 LTTNG_EVENT_CONTEXT_IP = 12,
138 LTTNG_EVENT_CONTEXT_PERF_CPU_COUNTER = 13,
139 LTTNG_EVENT_CONTEXT_PERF_THREAD_COUNTER = 14,
140 LTTNG_EVENT_CONTEXT_APP_CONTEXT = 15,
141 };
142
143 enum lttng_event_field_type {
144 LTTNG_EVENT_FIELD_OTHER = 0,
145 LTTNG_EVENT_FIELD_INTEGER = 1,
146 LTTNG_EVENT_FIELD_ENUM = 2,
147 LTTNG_EVENT_FIELD_FLOAT = 3,
148 LTTNG_EVENT_FIELD_STRING = 4,
149 };
150
151 enum lttng_event_flag {
152 LTTNG_EVENT_FLAG_SYSCALL_32 = (1U << 0),
153 LTTNG_EVENT_FLAG_SYSCALL_64 = (1U << 1),
154 };
155
156 /*
157 * Perf counter attributes
158 *
159 * The structures should be initialized to zero before use.
160 */
161 #define LTTNG_PERF_EVENT_PADDING1 16
162 struct lttng_event_perf_counter_ctx {
163 uint32_t type;
164 uint64_t config;
165 char name[LTTNG_SYMBOL_NAME_LEN];
166
167 char padding[LTTNG_PERF_EVENT_PADDING1];
168 };
169
170 /*
171 * Event/channel context
172 *
173 * The structures should be initialized to zero before use.
174 */
175 #define LTTNG_EVENT_CONTEXT_PADDING1 16
176 #define LTTNG_EVENT_CONTEXT_PADDING2 LTTNG_SYMBOL_NAME_LEN + 32
177 struct lttng_event_context {
178 enum lttng_event_context_type ctx;
179 char padding[LTTNG_EVENT_CONTEXT_PADDING1];
180
181 union {
182 struct lttng_event_perf_counter_ctx perf_counter;
183 struct {
184 char *provider_name;
185 char *ctx_name;
186 } app_ctx;
187 char padding[LTTNG_EVENT_CONTEXT_PADDING2];
188 } u;
189 };
190
191 /*
192 * Event probe.
193 *
194 * Either addr is used or symbol_name and offset.
195 *
196 * The structures should be initialized to zero before use.
197 */
198 #define LTTNG_EVENT_PROBE_PADDING1 16
199 struct lttng_event_probe_attr {
200 uint64_t addr;
201
202 uint64_t offset;
203 char symbol_name[LTTNG_SYMBOL_NAME_LEN];
204
205 char padding[LTTNG_EVENT_PROBE_PADDING1];
206 };
207
208 /*
209 * Function tracer
210 *
211 * The structures should be initialized to zero before use.
212 */
213 #define LTTNG_EVENT_FUNCTION_PADDING1 16
214 struct lttng_event_function_attr {
215 char symbol_name[LTTNG_SYMBOL_NAME_LEN];
216
217 char padding[LTTNG_EVENT_FUNCTION_PADDING1];
218 };
219
220 /*
221 * Generic lttng event
222 *
223 * The structures should be initialized to zero before use.
224 */
225 #define LTTNG_EVENT_PADDING1 12
226 #define LTTNG_EVENT_PADDING2 LTTNG_SYMBOL_NAME_LEN + 32
227 struct lttng_event {
228 /* Offset 0 */
229 enum lttng_event_type type;
230
231 /* Offset 4 */
232 char name[LTTNG_SYMBOL_NAME_LEN];
233
234 /* Offset 260 */
235 enum lttng_loglevel_type loglevel_type;
236
237 /* Offset 264 */
238 int loglevel;
239
240 /* Offset 268 */
241 int32_t enabled; /* Does not apply: -1 */
242
243 /* Offset 272 */
244 pid_t pid;
245
246 /* Offset 276 */
247 unsigned char filter; /* filter enabled ? */
248
249 /* Offset 277 */
250 unsigned char exclusion; /* exclusions added ? */
251
252 /* Offset 278 */
253 char padding2[2];
254
255 /* Offset 280 */
256 /* Event flag, from 2.6 and above. */
257 enum lttng_event_flag flags;
258
259 /* Offset 284 */
260 char padding[4];
261
262 /* Offset 288 */
263 union {
264 uint64_t padding;
265 void *ptr;
266 } extended;
267
268 /* Offset 296 */
269 /* Per event type configuration */
270 union {
271 struct lttng_event_probe_attr probe;
272 struct lttng_event_function_attr ftrace;
273
274 char padding[LTTNG_EVENT_PADDING2];
275 } attr;
276 };
277
278 #define LTTNG_EVENT_FIELD_PADDING LTTNG_SYMBOL_NAME_LEN + 32
279 struct lttng_event_field {
280 char field_name[LTTNG_SYMBOL_NAME_LEN];
281 enum lttng_event_field_type type;
282 char padding[LTTNG_EVENT_FIELD_PADDING];
283 struct lttng_event event;
284 int nowrite;
285 };
286
287 /*
288 * List the event(s) of a session channel.
289 *
290 * Both handle and channel_name CAN NOT be NULL.
291 *
292 * Return the size (number of entries) of the "lttng_event" array. Caller must
293 * free events. On error a negative LTTng error code is returned.
294 */
295 extern int lttng_list_events(struct lttng_handle *handle,
296 const char *channel_name, struct lttng_event **events);
297
298 /*
299 * Get the filter expression of a specific LTTng event.
300 *
301 * If the call is successful, then the filter expression's address is put
302 * in *filter_expression. If the event has no filter expression,
303 * *filter_expression is set to NULL. The caller does NOT own
304 * *filter_expression.
305 *
306 * Returns 0 on success, or a negative LTTng error code on error.
307 */
308 extern int lttng_event_get_filter_expression(struct lttng_event *event,
309 const char **filter_string);
310
311 /*
312 * Get the number of exclusion names of a specific LTTng event.
313 *
314 * Returns the number of exclusion names on success, or a negative
315 * LTTng error code on error.
316 */
317 extern int lttng_event_get_exclusion_name_count(struct lttng_event *event);
318
319 /*
320 * Get an LTTng event's exclusion name at a given index.
321 *
322 * If the call is successful, then the exclusion name string's address
323 * is put in *exclusion_name. The caller does NOT own *exclusion_name.
324 *
325 * Returns 0 on success, or a negative LTTng error code on error.
326 */
327 extern int lttng_event_get_exclusion_name(struct lttng_event *event,
328 size_t index, const char **exclusion_name);
329
330 /*
331 * List the available tracepoints of a specific lttng domain.
332 *
333 * The handle CAN NOT be NULL.
334 *
335 * Return the size (number of entries) of the "lttng_event" array. Caller must
336 * free events. On error a negative LTTng error code is returned.
337 */
338 extern int lttng_list_tracepoints(struct lttng_handle *handle,
339 struct lttng_event **events);
340
341 /*
342 * List the available tracepoints fields of a specific lttng domain.
343 *
344 * The handle CAN NOT be NULL.
345 *
346 * Return the size (number of entries) of the "lttng_event_field" array.
347 * Caller must free fields. On error a negative LTTng error code is
348 * returned.
349 */
350 extern int lttng_list_tracepoint_fields(struct lttng_handle *handle,
351 struct lttng_event_field **fields);
352
353 /*
354 * List the available kernel syscall.
355 *
356 * Return the size (number of entries) of the allocated "lttng_event" array.
357 * All events in will be of type syscall. Caller must free events. On error a
358 * negative LTTng error code is returned.
359 */
360 extern int lttng_list_syscalls(struct lttng_event **events);
361
362 /*
363 * Add context to event(s) for a specific channel (or for all).
364 *
365 * If the channel_name is NULL and they are no channel for the domain, the
366 * default channel is created (channel0). The context is then added on ALL
367 * channels since no name was specified.
368 *
369 * The event_name is ignored since adding a context to an event is not possible
370 * for now.
371 *
372 * Return 0 on success else a negative LTTng error code.
373 */
374 extern int lttng_add_context(struct lttng_handle *handle,
375 struct lttng_event_context *ctx, const char *event_name,
376 const char *channel_name);
377
378 /*
379 * Create or enable an event (or events) for a channel.
380 *
381 * If the event you are trying to enable does not exist, it will be created,
382 * else it is enabled. If channel_name is NULL, the default channel is used
383 * (channel0).
384 *
385 * The handle and ev params can not be NULL.
386 *
387 * Return 0 on success else a negative LTTng error code.
388 */
389 extern int lttng_enable_event(struct lttng_handle *handle,
390 struct lttng_event *ev, const char *channel_name);
391
392 /*
393 * Create or enable an event with a specific filter.
394 *
395 * If the event you are trying to enable does not exist, it will be created,
396 * else it is enabled.
397 * If ev is NULL, all events are enabled with that filter.
398 * If channel_name is NULL, the default channel is used (channel0) and created
399 * if not found.
400 * If filter_expression is NULL, an event without associated filter is
401 * created.
402 *
403 * Return 0 on success else a negative LTTng error code.
404 */
405 extern int lttng_enable_event_with_filter(struct lttng_handle *handle,
406 struct lttng_event *event, const char *channel_name,
407 const char *filter_expression);
408
409 /*
410 * Create or enable an event with a filter and/or exclusions.
411 *
412 * If the event you are trying to enable does not exist, it will be created,
413 * else it is enabled.
414 * If ev is NULL, all events are enabled with the filter and exclusion options.
415 * If channel_name is NULL, the default channel is used (channel0) and created
416 * if not found.
417 * If filter_expression is NULL, an event without associated filter is
418 * created.
419 * If exclusion count is zero, the event will be created without exclusions.
420 *
421 * Return 0 on success else a negative LTTng error code.
422 */
423 extern int lttng_enable_event_with_exclusions(struct lttng_handle *handle,
424 struct lttng_event *event, const char *channel_name,
425 const char *filter_expression,
426 int exclusion_count, char **exclusion_names);
427
428 /*
429 * Disable event(s) of a channel and domain.
430 *
431 * If name is NULL, all events are disabled.
432 * If channel_name is NULL, the default channel is used (channel0).
433 *
434 * Return 0 on success else a negative LTTng error code.
435 */
436 extern int lttng_disable_event(struct lttng_handle *handle,
437 const char *name, const char *channel_name);
438
439 /*
440 * Disable event(s) of a channel and domain.
441 *
442 * Takes a struct lttng_event as parameter.
443 * If channel_name is NULL, the default channel is used (channel0).
444 *
445 * Currently, @filter_expression must be NULL. (disabling specific
446 * filter expressions not implemented)
447 * Currently, only LTTNG_EVENT_ALL and LTTNG_EVENT_SYSCALL event types
448 * are implemented for field @ev.
449 *
450 * Return 0 on success else a negative LTTng error code.
451 */
452 int lttng_disable_event_ext(struct lttng_handle *handle,
453 struct lttng_event *ev, const char *channel_name,
454 const char *filter_expression);
455
456 #ifdef __cplusplus
457 }
458 #endif
459
460 #endif /* LTTNG_EVENT_H */
This page took 0.058861 seconds and 4 git commands to generate.