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