Fix: payload view: payload view always refers to parent's position
[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 * SPDX-License-Identifier: LGPL-2.1-only
6 *
7 */
8
9 #ifndef LTTNG_EVENT_H
10 #define LTTNG_EVENT_H
11
12 #ifdef __cplusplus
13 extern "C" {
14 #endif
15
16 #include <lttng/handle.h>
17 #include <lttng/userspace-probe.h>
18
19 /*
20 * Instrumentation type of tracing event.
21 */
22 enum 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,
30 LTTNG_EVENT_USERSPACE_PROBE = 6,
31 };
32
33 /*
34 * Loglevel information.
35 */
36 enum 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 */
45 enum 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 */
67 enum 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
79 /*
80 * Available loglevels for the LOG4j domain. Those are an exact map from the
81 * class org.apache.log4j.Level.
82 */
83 enum 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
94 /*
95 * Available loglevels for the Python domain. Those are an exact map from the
96 * Level class.
97 */
98 enum 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
107 /*
108 * LTTng consumer mode
109 */
110 enum lttng_event_output {
111 LTTNG_EVENT_SPLICE = 0,
112 LTTNG_EVENT_MMAP = 1,
113 };
114
115 /* Event context possible type */
116 enum lttng_event_context_type {
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,
131 LTTNG_EVENT_CONTEXT_PERF_THREAD_COUNTER = 14,
132 LTTNG_EVENT_CONTEXT_APP_CONTEXT = 15,
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,
137 LTTNG_EVENT_CONTEXT_CALLSTACK_KERNEL = 20,
138 LTTNG_EVENT_CONTEXT_CALLSTACK_USER = 21, /* Supported on x86_32 and x86_64 only. */
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,
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,
158 LTTNG_EVENT_CONTEXT_TIME_NS = 41,
159 };
160
161 enum lttng_event_field_type {
162 LTTNG_EVENT_FIELD_OTHER = 0,
163 LTTNG_EVENT_FIELD_INTEGER = 1,
164 LTTNG_EVENT_FIELD_ENUM = 2,
165 LTTNG_EVENT_FIELD_FLOAT = 3,
166 LTTNG_EVENT_FIELD_STRING = 4,
167 };
168
169 enum lttng_event_flag {
170 LTTNG_EVENT_FLAG_SYSCALL_32 = (1U << 0),
171 LTTNG_EVENT_FLAG_SYSCALL_64 = (1U << 1),
172 };
173
174 /*
175 * Perf counter attributes
176 *
177 * The structures should be initialized to zero before use.
178 */
179 #define LTTNG_PERF_EVENT_PADDING1 16
180 struct lttng_event_perf_counter_ctx {
181 uint32_t type;
182 uint64_t config;
183 char name[LTTNG_SYMBOL_NAME_LEN];
184
185 char padding[LTTNG_PERF_EVENT_PADDING1];
186 };
187
188 /*
189 * Event/channel context
190 *
191 * The structures should be initialized to zero before use.
192 */
193 #define LTTNG_EVENT_CONTEXT_PADDING1 16
194 #define LTTNG_EVENT_CONTEXT_PADDING2 LTTNG_SYMBOL_NAME_LEN + 32
195 struct lttng_event_context {
196 enum lttng_event_context_type ctx;
197 char padding[LTTNG_EVENT_CONTEXT_PADDING1];
198
199 union {
200 struct lttng_event_perf_counter_ctx perf_counter;
201 struct {
202 char *provider_name;
203 char *ctx_name;
204 } app_ctx;
205 char padding[LTTNG_EVENT_CONTEXT_PADDING2];
206 } u;
207 };
208
209 /*
210 * Event probe.
211 *
212 * Either addr is used or symbol_name and offset.
213 *
214 * The structures should be initialized to zero before use.
215 */
216 #define LTTNG_EVENT_PROBE_PADDING1 16
217 struct lttng_event_probe_attr {
218 uint64_t addr;
219
220 uint64_t offset;
221 char symbol_name[LTTNG_SYMBOL_NAME_LEN];
222
223 char padding[LTTNG_EVENT_PROBE_PADDING1];
224 };
225
226 /*
227 * Function tracer
228 *
229 * The structures should be initialized to zero before use.
230 */
231 #define LTTNG_EVENT_FUNCTION_PADDING1 16
232 struct lttng_event_function_attr {
233 char symbol_name[LTTNG_SYMBOL_NAME_LEN];
234
235 char padding[LTTNG_EVENT_FUNCTION_PADDING1];
236 };
237
238 /*
239 * Generic lttng event
240 *
241 * The structures should be initialized to zero before use.
242 */
243 #define LTTNG_EVENT_PADDING1 12
244 #define LTTNG_EVENT_PADDING2 LTTNG_SYMBOL_NAME_LEN + 32
245 struct lttng_event {
246 /* Offset 0 */
247 enum lttng_event_type type;
248
249 /* Offset 4 */
250 char name[LTTNG_SYMBOL_NAME_LEN];
251
252 /* Offset 260 */
253 enum lttng_loglevel_type loglevel_type;
254
255 /* Offset 264 */
256 int loglevel;
257
258 /* Offset 268 */
259 int32_t enabled; /* Does not apply: -1 */
260
261 /* Offset 272 */
262 pid_t pid;
263
264 /* Offset 276 */
265 unsigned char filter; /* filter enabled ? */
266
267 /* Offset 277 */
268 unsigned char exclusion; /* exclusions added ? */
269
270 /* Offset 278 */
271 char padding2[2];
272
273 /* Offset 280 */
274 /* Event flag, from 2.6 and above. */
275 enum lttng_event_flag flags;
276
277 /* Offset 284 */
278 char padding[4];
279
280 /* Offset 288 */
281 union {
282 uint64_t padding;
283 void *ptr;
284 } extended;
285
286 /* Offset 296 */
287 /* Per event type configuration */
288 union {
289 struct lttng_event_probe_attr probe;
290 struct lttng_event_function_attr ftrace;
291
292 char padding[LTTNG_EVENT_PADDING2];
293 } attr;
294 };
295
296 #define LTTNG_EVENT_FIELD_PADDING LTTNG_SYMBOL_NAME_LEN + 32
297 struct lttng_event_field {
298 char field_name[LTTNG_SYMBOL_NAME_LEN];
299 enum lttng_event_field_type type;
300 char padding[LTTNG_EVENT_FIELD_PADDING];
301 struct lttng_event event;
302 int nowrite;
303 };
304
305 /*
306 * List the event(s) of a session channel.
307 *
308 * Both handle and channel_name CAN NOT be NULL.
309 *
310 * Return the size (number of entries) of the "lttng_event" array. Caller must
311 * free events. On error a negative LTTng error code is returned.
312 */
313 extern int lttng_list_events(struct lttng_handle *handle,
314 const char *channel_name, struct lttng_event **events);
315
316 /*
317 * Create an lttng_event.
318 *
319 * This creation function, introduced in LTTng 2.11, works around
320 * the fact that the layout of the 'lttng_event' is publicly exposed.
321 *
322 * It allocates a larger object which exposes the same public fields
323 * as a 'struct lttng_event', but also allows the use of the following extended
324 * attribute setters:
325 * - lttng_event_set_userspace_probe_location();
326 *
327 * Events created through this function must be destroyed using
328 * lttng_event_destroy().
329 *
330 * Returns a zeroed lttng_event on success, NULL on error.
331 */
332 extern struct lttng_event *lttng_event_create(void);
333
334 /*
335 * Destroy an lttng_event.
336 *
337 * This destruction function, introduced in LTTng 2.11, should only
338 * be used with events created by lttng_event_create().
339 */
340 extern void lttng_event_destroy(struct lttng_event *event);
341
342 /*
343 * Get the filter expression of a specific LTTng event.
344 *
345 * If the call is successful, then the filter expression's address is put
346 * in *filter_expression. If the event has no filter expression,
347 * *filter_expression is set to NULL. The caller does NOT own
348 * *filter_expression.
349 *
350 * Returns 0 on success, or a negative LTTng error code on error.
351 */
352 extern int lttng_event_get_filter_expression(struct lttng_event *event,
353 const char **filter_string);
354
355 /*
356 * Get the number of exclusion names of a specific LTTng event.
357 *
358 * Returns the number of exclusion names on success, or a negative
359 * LTTng error code on error.
360 */
361 extern int lttng_event_get_exclusion_name_count(struct lttng_event *event);
362
363 /*
364 * Get an LTTng event's exclusion name at a given index.
365 *
366 * If the call is successful, then the exclusion name string's address
367 * is put in *exclusion_name. The caller does NOT own *exclusion_name.
368 *
369 * Returns 0 on success, or a negative LTTng error code on error.
370 */
371 extern int lttng_event_get_exclusion_name(struct lttng_event *event,
372 size_t index, const char **exclusion_name);
373
374 /*
375 * Get the userspace probe location of a specific LTTng event.
376 * If the call is successful, then a pointer to the probe location is returned.
377 * If the event has no probe location a NULL pointer is returned. The caller
378 * does not own the returned probe location.
379 */
380 extern const struct lttng_userspace_probe_location *
381 lttng_event_get_userspace_probe_location(const struct lttng_event *event);
382
383 /*
384 * Set an LTTng event's userspace probe location.
385 *
386 * If the call is successful, then the probe location is set to the event. The
387 * ownership of the probe_location is given to the event.
388 *
389 * Note that the event must have been created using 'lttng_event_create()' in
390 * order for this call to succeed.
391 *
392 * Returns 0 on success, or a negative LTTng error code on error.
393 */
394 extern int lttng_event_set_userspace_probe_location(struct lttng_event *event,
395 struct lttng_userspace_probe_location *probe_location);
396
397 /*
398 * List the available tracepoints of a specific lttng domain.
399 *
400 * The handle CAN NOT be NULL.
401 *
402 * Return the size (number of entries) of the "lttng_event" array. Caller must
403 * free events. On error a negative LTTng error code is returned.
404 */
405 extern int lttng_list_tracepoints(struct lttng_handle *handle,
406 struct lttng_event **events);
407
408 /*
409 * List the available tracepoints fields of a specific lttng domain.
410 *
411 * The handle CAN NOT be NULL.
412 *
413 * Return the size (number of entries) of the "lttng_event_field" array.
414 * Caller must free fields. On error a negative LTTng error code is
415 * returned.
416 */
417 extern int lttng_list_tracepoint_fields(struct lttng_handle *handle,
418 struct lttng_event_field **fields);
419
420 /*
421 * List the available kernel syscall.
422 *
423 * Return the size (number of entries) of the allocated "lttng_event" array.
424 * All events in will be of type syscall. Caller must free events. On error a
425 * negative LTTng error code is returned.
426 */
427 extern int lttng_list_syscalls(struct lttng_event **events);
428
429 /*
430 * Add context to event(s) for a specific channel (or for all).
431 *
432 * If the channel_name is NULL and they are no channel for the domain, the
433 * default channel is created (channel0). The context is then added on ALL
434 * channels since no name was specified.
435 *
436 * The event_name is ignored since adding a context to an event is not possible
437 * for now.
438 *
439 * Return 0 on success else a negative LTTng error code.
440 */
441 extern int lttng_add_context(struct lttng_handle *handle,
442 struct lttng_event_context *ctx, const char *event_name,
443 const char *channel_name);
444
445 /*
446 * Create or enable an event (or events) for a channel.
447 *
448 * If the event you are trying to enable does not exist, it will be created,
449 * else it is enabled. If channel_name is NULL, the default channel is used
450 * (channel0).
451 *
452 * The handle and ev params can not be NULL.
453 *
454 * Return 0 on success else a negative LTTng error code.
455 */
456 extern int lttng_enable_event(struct lttng_handle *handle,
457 struct lttng_event *ev, const char *channel_name);
458
459 /*
460 * Create or enable an event with a specific filter.
461 *
462 * If the event you are trying to enable does not exist, it will be created,
463 * else it is enabled.
464 * If ev is NULL, all events are enabled with that filter.
465 * If channel_name is NULL, the default channel is used (channel0) and created
466 * if not found.
467 * If filter_expression is NULL, an event without associated filter is
468 * created.
469 *
470 * Return 0 on success else a negative LTTng error code.
471 */
472 extern int lttng_enable_event_with_filter(struct lttng_handle *handle,
473 struct lttng_event *event, const char *channel_name,
474 const char *filter_expression);
475
476 /*
477 * Create or enable an event with a filter and/or exclusions.
478 *
479 * If the event you are trying to enable does not exist, it will be created,
480 * else it is enabled.
481 * If ev is NULL, all events are enabled with the filter and exclusion options.
482 * If channel_name is NULL, the default channel is used (channel0) and created
483 * if not found.
484 * If filter_expression is NULL, an event without associated filter is
485 * created.
486 * If exclusion count is zero, the event will be created without exclusions.
487 *
488 * Return 0 on success else a negative LTTng error code.
489 */
490 extern int lttng_enable_event_with_exclusions(struct lttng_handle *handle,
491 struct lttng_event *event, const char *channel_name,
492 const char *filter_expression,
493 int exclusion_count, char **exclusion_names);
494
495 /*
496 * Disable event(s) of a channel and domain.
497 *
498 * If name is NULL, all events are disabled.
499 * If channel_name is NULL, the default channel is used (channel0).
500 *
501 * Return 0 on success else a negative LTTng error code.
502 */
503 extern int lttng_disable_event(struct lttng_handle *handle,
504 const char *name, const char *channel_name);
505
506 /*
507 * Disable event(s) of a channel and domain.
508 *
509 * Takes a struct lttng_event as parameter.
510 * If channel_name is NULL, the default channel is used (channel0).
511 *
512 * Currently, @filter_expression must be NULL. (disabling specific
513 * filter expressions not implemented)
514 * Currently, only LTTNG_EVENT_ALL and LTTNG_EVENT_SYSCALL event types
515 * are implemented for field @ev.
516 *
517 * Return 0 on success else a negative LTTng error code.
518 */
519 int lttng_disable_event_ext(struct lttng_handle *handle,
520 struct lttng_event *ev, const char *channel_name,
521 const char *filter_expression);
522
523 #ifdef __cplusplus
524 }
525 #endif
526
527 #endif /* LTTNG_EVENT_H */
This page took 0.039495 seconds and 5 git commands to generate.