Refactoring: introduce lttng_tracker_ids data structure
[lttng-tools.git] / include / lttng / event.h
CommitLineData
1239a312
DG
1/*
2 * Copyright (C) 2014 - David Goulet <dgoulet@efficios.com>
2001793c 3 * Copyright (C) 2016 - Jérémie Galarneau <jeremie.galarneau@efficios.com>
1239a312
DG
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
23extern "C" {
24#endif
25
26#include <lttng/handle.h>
ef0e06bc 27#include <lttng/userspace-probe.h>
1239a312
DG
28
29/*
30 * Instrumentation type of tracing event.
31 */
32enum lttng_event_type {
33 LTTNG_EVENT_ALL = -1,
34 LTTNG_EVENT_TRACEPOINT = 0,
35 LTTNG_EVENT_PROBE = 1,
36 LTTNG_EVENT_FUNCTION = 2,
37 LTTNG_EVENT_FUNCTION_ENTRY = 3,
38 LTTNG_EVENT_NOOP = 4,
39 LTTNG_EVENT_SYSCALL = 5,
410b78a0 40 LTTNG_EVENT_USERSPACE_PROBE = 6,
1239a312
DG
41};
42
43/*
44 * Loglevel information.
45 */
46enum lttng_loglevel_type {
47 LTTNG_EVENT_LOGLEVEL_ALL = 0,
48 LTTNG_EVENT_LOGLEVEL_RANGE = 1,
49 LTTNG_EVENT_LOGLEVEL_SINGLE = 2,
50};
51
52/*
53 * Available loglevels.
54 */
55enum lttng_loglevel {
56 LTTNG_LOGLEVEL_EMERG = 0,
57 LTTNG_LOGLEVEL_ALERT = 1,
58 LTTNG_LOGLEVEL_CRIT = 2,
59 LTTNG_LOGLEVEL_ERR = 3,
60 LTTNG_LOGLEVEL_WARNING = 4,
61 LTTNG_LOGLEVEL_NOTICE = 5,
62 LTTNG_LOGLEVEL_INFO = 6,
63 LTTNG_LOGLEVEL_DEBUG_SYSTEM = 7,
64 LTTNG_LOGLEVEL_DEBUG_PROGRAM = 8,
65 LTTNG_LOGLEVEL_DEBUG_PROCESS = 9,
66 LTTNG_LOGLEVEL_DEBUG_MODULE = 10,
67 LTTNG_LOGLEVEL_DEBUG_UNIT = 11,
68 LTTNG_LOGLEVEL_DEBUG_FUNCTION = 12,
69 LTTNG_LOGLEVEL_DEBUG_LINE = 13,
70 LTTNG_LOGLEVEL_DEBUG = 14,
71};
72
73/*
74 * Available loglevels for the JUL domain. Those are an exact map from the
75 * class java.util.logging.Level.
76 */
77enum lttng_loglevel_jul {
78 LTTNG_LOGLEVEL_JUL_OFF = INT32_MAX,
79 LTTNG_LOGLEVEL_JUL_SEVERE = 1000,
80 LTTNG_LOGLEVEL_JUL_WARNING = 900,
81 LTTNG_LOGLEVEL_JUL_INFO = 800,
82 LTTNG_LOGLEVEL_JUL_CONFIG = 700,
83 LTTNG_LOGLEVEL_JUL_FINE = 500,
84 LTTNG_LOGLEVEL_JUL_FINER = 400,
85 LTTNG_LOGLEVEL_JUL_FINEST = 300,
86 LTTNG_LOGLEVEL_JUL_ALL = INT32_MIN,
87};
88
5cdb6027
DG
89/*
90 * Available loglevels for the LOG4j domain. Those are an exact map from the
91 * class org.apache.log4j.Level.
92 */
93enum lttng_loglevel_log4j {
94 LTTNG_LOGLEVEL_LOG4J_OFF = INT32_MAX,
95 LTTNG_LOGLEVEL_LOG4J_FATAL = 50000,
96 LTTNG_LOGLEVEL_LOG4J_ERROR = 40000,
97 LTTNG_LOGLEVEL_LOG4J_WARN = 30000,
98 LTTNG_LOGLEVEL_LOG4J_INFO = 20000,
99 LTTNG_LOGLEVEL_LOG4J_DEBUG = 10000,
100 LTTNG_LOGLEVEL_LOG4J_TRACE = 5000,
101 LTTNG_LOGLEVEL_LOG4J_ALL = INT32_MIN,
102};
103
0e115563
DG
104/*
105 * Available loglevels for the Python domain. Those are an exact map from the
106 * Level class.
107 */
108enum lttng_loglevel_python {
109 LTTNG_LOGLEVEL_PYTHON_CRITICAL = 50,
110 LTTNG_LOGLEVEL_PYTHON_ERROR = 40,
111 LTTNG_LOGLEVEL_PYTHON_WARNING = 30,
112 LTTNG_LOGLEVEL_PYTHON_INFO = 20,
113 LTTNG_LOGLEVEL_PYTHON_DEBUG = 10,
114 LTTNG_LOGLEVEL_PYTHON_NOTSET = 0,
115};
116
1239a312
DG
117/*
118 * LTTng consumer mode
119 */
120enum lttng_event_output {
121 LTTNG_EVENT_SPLICE = 0,
122 LTTNG_EVENT_MMAP = 1,
123};
124
125/* Event context possible type */
126enum lttng_event_context_type {
2001793c
JG
127 LTTNG_EVENT_CONTEXT_PID = 0,
128 LTTNG_EVENT_CONTEXT_PERF_COUNTER = 1, /* Backward compat. */
129 LTTNG_EVENT_CONTEXT_PROCNAME = 2,
130 LTTNG_EVENT_CONTEXT_PRIO = 3,
131 LTTNG_EVENT_CONTEXT_NICE = 4,
132 LTTNG_EVENT_CONTEXT_VPID = 5,
133 LTTNG_EVENT_CONTEXT_TID = 6,
134 LTTNG_EVENT_CONTEXT_VTID = 7,
135 LTTNG_EVENT_CONTEXT_PPID = 8,
136 LTTNG_EVENT_CONTEXT_VPPID = 9,
137 LTTNG_EVENT_CONTEXT_PTHREAD_ID = 10,
138 LTTNG_EVENT_CONTEXT_HOSTNAME = 11,
139 LTTNG_EVENT_CONTEXT_IP = 12,
140 LTTNG_EVENT_CONTEXT_PERF_CPU_COUNTER = 13,
1239a312 141 LTTNG_EVENT_CONTEXT_PERF_THREAD_COUNTER = 14,
2001793c 142 LTTNG_EVENT_CONTEXT_APP_CONTEXT = 15,
1ae5e83e
JD
143 LTTNG_EVENT_CONTEXT_INTERRUPTIBLE = 16,
144 LTTNG_EVENT_CONTEXT_PREEMPTIBLE = 17,
145 LTTNG_EVENT_CONTEXT_NEED_RESCHEDULE = 18,
146 LTTNG_EVENT_CONTEXT_MIGRATABLE = 19,
373148e9
FG
147 LTTNG_EVENT_CONTEXT_CALLSTACK_KERNEL = 20,
148 LTTNG_EVENT_CONTEXT_CALLSTACK_USER = 21, /* Supported on x86_32 and x86_64 only. */
40e14884
MJ
149 LTTNG_EVENT_CONTEXT_CGROUP_NS = 22,
150 LTTNG_EVENT_CONTEXT_IPC_NS = 23,
151 LTTNG_EVENT_CONTEXT_MNT_NS = 24,
152 LTTNG_EVENT_CONTEXT_NET_NS = 25,
153 LTTNG_EVENT_CONTEXT_PID_NS = 26,
154 LTTNG_EVENT_CONTEXT_USER_NS = 27,
155 LTTNG_EVENT_CONTEXT_UTS_NS = 28,
499cbfa1
MJ
156 LTTNG_EVENT_CONTEXT_UID = 29,
157 LTTNG_EVENT_CONTEXT_EUID = 30,
158 LTTNG_EVENT_CONTEXT_SUID = 31,
159 LTTNG_EVENT_CONTEXT_GID = 32,
160 LTTNG_EVENT_CONTEXT_EGID = 33,
161 LTTNG_EVENT_CONTEXT_SGID = 34,
162 LTTNG_EVENT_CONTEXT_VUID = 35,
163 LTTNG_EVENT_CONTEXT_VEUID = 36,
164 LTTNG_EVENT_CONTEXT_VSUID = 37,
165 LTTNG_EVENT_CONTEXT_VGID = 38,
166 LTTNG_EVENT_CONTEXT_VEGID = 39,
167 LTTNG_EVENT_CONTEXT_VSGID = 40,
1239a312
DG
168};
169
170enum lttng_event_field_type {
171 LTTNG_EVENT_FIELD_OTHER = 0,
172 LTTNG_EVENT_FIELD_INTEGER = 1,
173 LTTNG_EVENT_FIELD_ENUM = 2,
174 LTTNG_EVENT_FIELD_FLOAT = 3,
175 LTTNG_EVENT_FIELD_STRING = 4,
176};
177
834978fd
DG
178enum lttng_event_flag {
179 LTTNG_EVENT_FLAG_SYSCALL_32 = (1U << 0),
180 LTTNG_EVENT_FLAG_SYSCALL_64 = (1U << 1),
181};
182
1239a312
DG
183/*
184 * Perf counter attributes
185 *
186 * The structures should be initialized to zero before use.
187 */
188#define LTTNG_PERF_EVENT_PADDING1 16
189struct lttng_event_perf_counter_ctx {
190 uint32_t type;
191 uint64_t config;
192 char name[LTTNG_SYMBOL_NAME_LEN];
193
194 char padding[LTTNG_PERF_EVENT_PADDING1];
195};
196
197/*
198 * Event/channel context
199 *
200 * The structures should be initialized to zero before use.
201 */
202#define LTTNG_EVENT_CONTEXT_PADDING1 16
203#define LTTNG_EVENT_CONTEXT_PADDING2 LTTNG_SYMBOL_NAME_LEN + 32
204struct lttng_event_context {
205 enum lttng_event_context_type ctx;
206 char padding[LTTNG_EVENT_CONTEXT_PADDING1];
207
208 union {
209 struct lttng_event_perf_counter_ctx perf_counter;
2001793c
JG
210 struct {
211 char *provider_name;
212 char *ctx_name;
213 } app_ctx;
1239a312
DG
214 char padding[LTTNG_EVENT_CONTEXT_PADDING2];
215 } u;
216};
217
218/*
219 * Event probe.
220 *
221 * Either addr is used or symbol_name and offset.
222 *
223 * The structures should be initialized to zero before use.
224 */
225#define LTTNG_EVENT_PROBE_PADDING1 16
226struct lttng_event_probe_attr {
227 uint64_t addr;
228
229 uint64_t offset;
230 char symbol_name[LTTNG_SYMBOL_NAME_LEN];
231
232 char padding[LTTNG_EVENT_PROBE_PADDING1];
233};
234
235/*
236 * Function tracer
237 *
238 * The structures should be initialized to zero before use.
239 */
240#define LTTNG_EVENT_FUNCTION_PADDING1 16
241struct lttng_event_function_attr {
242 char symbol_name[LTTNG_SYMBOL_NAME_LEN];
243
244 char padding[LTTNG_EVENT_FUNCTION_PADDING1];
245};
246
247/*
248 * Generic lttng event
249 *
250 * The structures should be initialized to zero before use.
251 */
fe9ecacb 252#define LTTNG_EVENT_PADDING1 12
1239a312
DG
253#define LTTNG_EVENT_PADDING2 LTTNG_SYMBOL_NAME_LEN + 32
254struct lttng_event {
fe9ecacb 255 /* Offset 0 */
1239a312 256 enum lttng_event_type type;
fe9ecacb
PP
257
258 /* Offset 4 */
1239a312
DG
259 char name[LTTNG_SYMBOL_NAME_LEN];
260
fe9ecacb 261 /* Offset 260 */
1239a312 262 enum lttng_loglevel_type loglevel_type;
fe9ecacb
PP
263
264 /* Offset 264 */
1239a312
DG
265 int loglevel;
266
fe9ecacb 267 /* Offset 268 */
1239a312 268 int32_t enabled; /* Does not apply: -1 */
fe9ecacb
PP
269
270 /* Offset 272 */
1239a312 271 pid_t pid;
fe9ecacb
PP
272
273 /* Offset 276 */
1239a312 274 unsigned char filter; /* filter enabled ? */
fe9ecacb
PP
275
276 /* Offset 277 */
1239a312
DG
277 unsigned char exclusion; /* exclusions added ? */
278
fe9ecacb
PP
279 /* Offset 278 */
280 char padding2[2];
281
282 /* Offset 280 */
834978fd
DG
283 /* Event flag, from 2.6 and above. */
284 enum lttng_event_flag flags;
285
fe9ecacb 286 /* Offset 284 */
b4e3ceb9
PP
287 char padding[4];
288
289 /* Offset 288 */
290 union {
4829ae55 291 uint64_t padding;
b4e3ceb9
PP
292 void *ptr;
293 } extended;
1239a312 294
fe9ecacb 295 /* Offset 296 */
1239a312
DG
296 /* Per event type configuration */
297 union {
298 struct lttng_event_probe_attr probe;
299 struct lttng_event_function_attr ftrace;
300
301 char padding[LTTNG_EVENT_PADDING2];
302 } attr;
303};
304
305#define LTTNG_EVENT_FIELD_PADDING LTTNG_SYMBOL_NAME_LEN + 32
306struct lttng_event_field {
307 char field_name[LTTNG_SYMBOL_NAME_LEN];
308 enum lttng_event_field_type type;
309 char padding[LTTNG_EVENT_FIELD_PADDING];
310 struct lttng_event event;
311 int nowrite;
312};
313
314/*
315 * List the event(s) of a session channel.
316 *
317 * Both handle and channel_name CAN NOT be NULL.
318 *
319 * Return the size (number of entries) of the "lttng_event" array. Caller must
320 * free events. On error a negative LTTng error code is returned.
321 */
322extern int lttng_list_events(struct lttng_handle *handle,
323 const char *channel_name, struct lttng_event **events);
324
c8282375
JG
325/*
326 * Create an lttng_event.
327 *
328 * This creation function, introduced in LTTng 2.11, works around
329 * the fact that the layout of the 'lttng_event' is publicly exposed.
330 *
331 * It allocates a larger object which exposes the same public fields
332 * as a 'struct lttng_event', but also allows the use of the following extended
333 * attribute setters:
334 * - lttng_event_set_userspace_probe_location();
335 *
336 * Events created through this function must be destroyed using
337 * lttng_event_destroy().
338 *
339 * Returns a zeroed lttng_event on success, NULL on error.
340 */
ef0e06bc
JG
341extern struct lttng_event *lttng_event_create(void);
342
c8282375
JG
343/*
344 * Destroy an lttng_event.
345 *
346 * This destruction function, introduced in LTTng 2.11, should only
347 * be used with events created by lttng_event_create().
348 */
ef0e06bc
JG
349extern void lttng_event_destroy(struct lttng_event *event);
350
d31d3e8c 351/*
134e72ed 352 * Get the filter expression of a specific LTTng event.
d31d3e8c 353 *
134e72ed
JG
354 * If the call is successful, then the filter expression's address is put
355 * in *filter_expression. If the event has no filter expression,
356 * *filter_expression is set to NULL. The caller does NOT own
357 * *filter_expression.
d31d3e8c
PP
358 *
359 * Returns 0 on success, or a negative LTTng error code on error.
360 */
134e72ed 361extern int lttng_event_get_filter_expression(struct lttng_event *event,
d31d3e8c
PP
362 const char **filter_string);
363
f086e50e
PP
364/*
365 * Get the number of exclusion names of a specific LTTng event.
366 *
367 * Returns the number of exclusion names on success, or a negative
368 * LTTng error code on error.
369 */
370extern int lttng_event_get_exclusion_name_count(struct lttng_event *event);
371
372/*
373 * Get an LTTng event's exclusion name at a given index.
374 *
375 * If the call is successful, then the exclusion name string's address
376 * is put in *exclusion_name. The caller does NOT own *exclusion_name.
377 *
378 * Returns 0 on success, or a negative LTTng error code on error.
379 */
380extern int lttng_event_get_exclusion_name(struct lttng_event *event,
381 size_t index, const char **exclusion_name);
382
ef0e06bc
JG
383/*
384 * Get the userspace probe location of a specific LTTng event.
385 * If the call is successful, then a pointer to the probe location is returned.
386 * If the event has no probe location a NULL pointer is returned. The caller
387 * does not own the returned probe location.
388 */
87597c2c
JG
389extern const struct lttng_userspace_probe_location *
390lttng_event_get_userspace_probe_location(const struct lttng_event *event);
ef0e06bc
JG
391
392/*
393 * Set an LTTng event's userspace probe location.
c8282375 394 *
ef0e06bc
JG
395 * If the call is successful, then the probe location is set to the event. The
396 * ownership of the probe_location is given to the event.
397 *
c8282375
JG
398 * Note that the event must have been created using 'lttng_event_create()' in
399 * order for this call to succeed.
400 *
ef0e06bc
JG
401 * Returns 0 on success, or a negative LTTng error code on error.
402 */
403extern int lttng_event_set_userspace_probe_location(struct lttng_event *event,
404 struct lttng_userspace_probe_location *probe_location);
405
1239a312
DG
406/*
407 * List the available tracepoints of a specific lttng domain.
408 *
409 * The handle CAN NOT be NULL.
410 *
411 * Return the size (number of entries) of the "lttng_event" array. Caller must
412 * free events. On error a negative LTTng error code is returned.
413 */
414extern int lttng_list_tracepoints(struct lttng_handle *handle,
415 struct lttng_event **events);
416
417/*
418 * List the available tracepoints fields of a specific lttng domain.
419 *
420 * The handle CAN NOT be NULL.
421 *
422 * Return the size (number of entries) of the "lttng_event_field" array.
423 * Caller must free fields. On error a negative LTTng error code is
424 * returned.
425 */
426extern int lttng_list_tracepoint_fields(struct lttng_handle *handle,
427 struct lttng_event_field **fields);
428
834978fd
DG
429/*
430 * List the available kernel syscall.
431 *
432 * Return the size (number of entries) of the allocated "lttng_event" array.
433 * All events in will be of type syscall. Caller must free events. On error a
434 * negative LTTng error code is returned.
435 */
436extern int lttng_list_syscalls(struct lttng_event **events);
437
1239a312
DG
438/*
439 * Add context to event(s) for a specific channel (or for all).
440 *
441 * If the channel_name is NULL and they are no channel for the domain, the
442 * default channel is created (channel0). The context is then added on ALL
443 * channels since no name was specified.
444 *
445 * The event_name is ignored since adding a context to an event is not possible
446 * for now.
447 *
448 * Return 0 on success else a negative LTTng error code.
449 */
450extern int lttng_add_context(struct lttng_handle *handle,
451 struct lttng_event_context *ctx, const char *event_name,
452 const char *channel_name);
453
454/*
455 * Create or enable an event (or events) for a channel.
456 *
457 * If the event you are trying to enable does not exist, it will be created,
458 * else it is enabled. If channel_name is NULL, the default channel is used
459 * (channel0).
460 *
461 * The handle and ev params can not be NULL.
462 *
463 * Return 0 on success else a negative LTTng error code.
464 */
465extern int lttng_enable_event(struct lttng_handle *handle,
466 struct lttng_event *ev, const char *channel_name);
467
468/*
469 * Create or enable an event with a specific filter.
470 *
471 * If the event you are trying to enable does not exist, it will be created,
472 * else it is enabled.
473 * If ev is NULL, all events are enabled with that filter.
474 * If channel_name is NULL, the default channel is used (channel0) and created
475 * if not found.
476 * If filter_expression is NULL, an event without associated filter is
477 * created.
478 *
479 * Return 0 on success else a negative LTTng error code.
480 */
481extern int lttng_enable_event_with_filter(struct lttng_handle *handle,
482 struct lttng_event *event, const char *channel_name,
483 const char *filter_expression);
484
485/*
486 * Create or enable an event with a filter and/or exclusions.
487 *
488 * If the event you are trying to enable does not exist, it will be created,
489 * else it is enabled.
490 * If ev is NULL, all events are enabled with the filter and exclusion options.
491 * If channel_name is NULL, the default channel is used (channel0) and created
492 * if not found.
493 * If filter_expression is NULL, an event without associated filter is
494 * created.
495 * If exclusion count is zero, the event will be created without exclusions.
496 *
497 * Return 0 on success else a negative LTTng error code.
498 */
499extern int lttng_enable_event_with_exclusions(struct lttng_handle *handle,
500 struct lttng_event *event, const char *channel_name,
501 const char *filter_expression,
502 int exclusion_count, char **exclusion_names);
503
504/*
505 * Disable event(s) of a channel and domain.
506 *
507 * If name is NULL, all events are disabled.
508 * If channel_name is NULL, the default channel is used (channel0).
509 *
510 * Return 0 on success else a negative LTTng error code.
511 */
512extern int lttng_disable_event(struct lttng_handle *handle,
513 const char *name, const char *channel_name);
514
6e911cad
MD
515/*
516 * Disable event(s) of a channel and domain.
517 *
518 * Takes a struct lttng_event as parameter.
519 * If channel_name is NULL, the default channel is used (channel0).
520 *
521 * Currently, @filter_expression must be NULL. (disabling specific
522 * filter expressions not implemented)
523 * Currently, only LTTNG_EVENT_ALL and LTTNG_EVENT_SYSCALL event types
524 * are implemented for field @ev.
525 *
526 * Return 0 on success else a negative LTTng error code.
527 */
528int lttng_disable_event_ext(struct lttng_handle *handle,
529 struct lttng_event *ev, const char *channel_name,
530 const char *filter_expression);
531
1239a312
DG
532#ifdef __cplusplus
533}
534#endif
535
536#endif /* LTTNG_EVENT_H */
This page took 0.056871 seconds and 4 git commands to generate.