2 * Copyright (C) 2014 David Goulet <dgoulet@efficios.com>
3 * Copyright (C) 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com>
5 * SPDX-License-Identifier: LGPL-2.1-only
12 #include <lttng/handle.h>
13 #include <lttng/lttng-export.h>
14 #include <lttng/userspace-probe.h>
21 * Instrumentation type of tracing event.
23 enum lttng_event_type
{
25 LTTNG_EVENT_TRACEPOINT
= 0,
26 LTTNG_EVENT_PROBE
= 1,
27 LTTNG_EVENT_FUNCTION
= 2,
28 LTTNG_EVENT_FUNCTION_ENTRY
= 3,
30 LTTNG_EVENT_SYSCALL
= 5,
31 LTTNG_EVENT_USERSPACE_PROBE
= 6,
35 * Loglevel information.
37 enum lttng_loglevel_type
{
38 LTTNG_EVENT_LOGLEVEL_ALL
= 0,
39 LTTNG_EVENT_LOGLEVEL_RANGE
= 1,
40 LTTNG_EVENT_LOGLEVEL_SINGLE
= 2,
44 * Available loglevels.
47 LTTNG_LOGLEVEL_EMERG
= 0,
48 LTTNG_LOGLEVEL_ALERT
= 1,
49 LTTNG_LOGLEVEL_CRIT
= 2,
50 LTTNG_LOGLEVEL_ERR
= 3,
51 LTTNG_LOGLEVEL_WARNING
= 4,
52 LTTNG_LOGLEVEL_NOTICE
= 5,
53 LTTNG_LOGLEVEL_INFO
= 6,
54 LTTNG_LOGLEVEL_DEBUG_SYSTEM
= 7,
55 LTTNG_LOGLEVEL_DEBUG_PROGRAM
= 8,
56 LTTNG_LOGLEVEL_DEBUG_PROCESS
= 9,
57 LTTNG_LOGLEVEL_DEBUG_MODULE
= 10,
58 LTTNG_LOGLEVEL_DEBUG_UNIT
= 11,
59 LTTNG_LOGLEVEL_DEBUG_FUNCTION
= 12,
60 LTTNG_LOGLEVEL_DEBUG_LINE
= 13,
61 LTTNG_LOGLEVEL_DEBUG
= 14,
65 * Available loglevels for the JUL domain. Those are an exact map from the
66 * class java.util.logging.Level.
68 enum lttng_loglevel_jul
{
69 LTTNG_LOGLEVEL_JUL_OFF
= INT32_MAX
,
70 LTTNG_LOGLEVEL_JUL_SEVERE
= 1000,
71 LTTNG_LOGLEVEL_JUL_WARNING
= 900,
72 LTTNG_LOGLEVEL_JUL_INFO
= 800,
73 LTTNG_LOGLEVEL_JUL_CONFIG
= 700,
74 LTTNG_LOGLEVEL_JUL_FINE
= 500,
75 LTTNG_LOGLEVEL_JUL_FINER
= 400,
76 LTTNG_LOGLEVEL_JUL_FINEST
= 300,
77 LTTNG_LOGLEVEL_JUL_ALL
= INT32_MIN
,
81 * Available loglevels for the LOG4j domain. Those are an exact map from the
82 * class org.apache.log4j.Level.
84 enum lttng_loglevel_log4j
{
85 LTTNG_LOGLEVEL_LOG4J_OFF
= INT32_MAX
,
86 LTTNG_LOGLEVEL_LOG4J_FATAL
= 50000,
87 LTTNG_LOGLEVEL_LOG4J_ERROR
= 40000,
88 LTTNG_LOGLEVEL_LOG4J_WARN
= 30000,
89 LTTNG_LOGLEVEL_LOG4J_INFO
= 20000,
90 LTTNG_LOGLEVEL_LOG4J_DEBUG
= 10000,
91 LTTNG_LOGLEVEL_LOG4J_TRACE
= 5000,
92 LTTNG_LOGLEVEL_LOG4J_ALL
= INT32_MIN
,
96 * Available loglevels for the Python domain. Those are an exact map from the
99 enum lttng_loglevel_python
{
100 LTTNG_LOGLEVEL_PYTHON_CRITICAL
= 50,
101 LTTNG_LOGLEVEL_PYTHON_ERROR
= 40,
102 LTTNG_LOGLEVEL_PYTHON_WARNING
= 30,
103 LTTNG_LOGLEVEL_PYTHON_INFO
= 20,
104 LTTNG_LOGLEVEL_PYTHON_DEBUG
= 10,
105 LTTNG_LOGLEVEL_PYTHON_NOTSET
= 0,
109 * LTTng consumer mode
111 enum lttng_event_output
{
112 LTTNG_EVENT_SPLICE
= 0,
113 LTTNG_EVENT_MMAP
= 1,
116 /* Event context possible type */
117 enum lttng_event_context_type
{
118 LTTNG_EVENT_CONTEXT_PID
= 0,
119 LTTNG_EVENT_CONTEXT_PERF_COUNTER
= 1, /* Backward compat. */
120 LTTNG_EVENT_CONTEXT_PROCNAME
= 2,
121 LTTNG_EVENT_CONTEXT_PRIO
= 3,
122 LTTNG_EVENT_CONTEXT_NICE
= 4,
123 LTTNG_EVENT_CONTEXT_VPID
= 5,
124 LTTNG_EVENT_CONTEXT_TID
= 6,
125 LTTNG_EVENT_CONTEXT_VTID
= 7,
126 LTTNG_EVENT_CONTEXT_PPID
= 8,
127 LTTNG_EVENT_CONTEXT_VPPID
= 9,
128 LTTNG_EVENT_CONTEXT_PTHREAD_ID
= 10,
129 LTTNG_EVENT_CONTEXT_HOSTNAME
= 11,
130 LTTNG_EVENT_CONTEXT_IP
= 12,
131 LTTNG_EVENT_CONTEXT_PERF_CPU_COUNTER
= 13,
132 LTTNG_EVENT_CONTEXT_PERF_THREAD_COUNTER
= 14,
133 LTTNG_EVENT_CONTEXT_APP_CONTEXT
= 15,
134 LTTNG_EVENT_CONTEXT_INTERRUPTIBLE
= 16,
135 LTTNG_EVENT_CONTEXT_PREEMPTIBLE
= 17,
136 LTTNG_EVENT_CONTEXT_NEED_RESCHEDULE
= 18,
137 LTTNG_EVENT_CONTEXT_MIGRATABLE
= 19,
138 LTTNG_EVENT_CONTEXT_CALLSTACK_KERNEL
= 20,
139 LTTNG_EVENT_CONTEXT_CALLSTACK_USER
= 21, /* Supported on x86_32 and x86_64 only. */
140 LTTNG_EVENT_CONTEXT_CGROUP_NS
= 22,
141 LTTNG_EVENT_CONTEXT_IPC_NS
= 23,
142 LTTNG_EVENT_CONTEXT_MNT_NS
= 24,
143 LTTNG_EVENT_CONTEXT_NET_NS
= 25,
144 LTTNG_EVENT_CONTEXT_PID_NS
= 26,
145 LTTNG_EVENT_CONTEXT_USER_NS
= 27,
146 LTTNG_EVENT_CONTEXT_UTS_NS
= 28,
147 LTTNG_EVENT_CONTEXT_UID
= 29,
148 LTTNG_EVENT_CONTEXT_EUID
= 30,
149 LTTNG_EVENT_CONTEXT_SUID
= 31,
150 LTTNG_EVENT_CONTEXT_GID
= 32,
151 LTTNG_EVENT_CONTEXT_EGID
= 33,
152 LTTNG_EVENT_CONTEXT_SGID
= 34,
153 LTTNG_EVENT_CONTEXT_VUID
= 35,
154 LTTNG_EVENT_CONTEXT_VEUID
= 36,
155 LTTNG_EVENT_CONTEXT_VSUID
= 37,
156 LTTNG_EVENT_CONTEXT_VGID
= 38,
157 LTTNG_EVENT_CONTEXT_VEGID
= 39,
158 LTTNG_EVENT_CONTEXT_VSGID
= 40,
159 LTTNG_EVENT_CONTEXT_TIME_NS
= 41,
162 enum lttng_event_field_type
{
163 LTTNG_EVENT_FIELD_OTHER
= 0,
164 LTTNG_EVENT_FIELD_INTEGER
= 1,
165 LTTNG_EVENT_FIELD_ENUM
= 2,
166 LTTNG_EVENT_FIELD_FLOAT
= 3,
167 LTTNG_EVENT_FIELD_STRING
= 4,
170 enum lttng_event_flag
{
171 LTTNG_EVENT_FLAG_SYSCALL_32
= (1U << 0),
172 LTTNG_EVENT_FLAG_SYSCALL_64
= (1U << 1),
176 * Perf counter attributes
178 * The structures should be initialized to zero before use.
180 #define LTTNG_PERF_EVENT_PADDING1 16
181 struct lttng_event_perf_counter_ctx
{
184 char name
[LTTNG_SYMBOL_NAME_LEN
];
186 char padding
[LTTNG_PERF_EVENT_PADDING1
];
190 * Event/channel context
192 * The structures should be initialized to zero before use.
194 #define LTTNG_EVENT_CONTEXT_PADDING1 16
195 #define LTTNG_EVENT_CONTEXT_PADDING2 LTTNG_SYMBOL_NAME_LEN + 32
196 struct lttng_event_context
{
197 enum lttng_event_context_type ctx
;
198 char padding
[LTTNG_EVENT_CONTEXT_PADDING1
];
201 struct lttng_event_perf_counter_ctx perf_counter
;
206 char padding
[LTTNG_EVENT_CONTEXT_PADDING2
];
213 * Either addr is used or symbol_name and offset.
215 * The structures should be initialized to zero before use.
217 #define LTTNG_EVENT_PROBE_PADDING1 16
218 struct lttng_event_probe_attr
{
222 char symbol_name
[LTTNG_SYMBOL_NAME_LEN
];
224 char padding
[LTTNG_EVENT_PROBE_PADDING1
];
230 * The structures should be initialized to zero before use.
232 #define LTTNG_EVENT_FUNCTION_PADDING1 16
233 struct lttng_event_function_attr
{
234 char symbol_name
[LTTNG_SYMBOL_NAME_LEN
];
236 char padding
[LTTNG_EVENT_FUNCTION_PADDING1
];
240 * Generic lttng event
242 * The structures should be initialized to zero before use.
244 #define LTTNG_EVENT_PADDING1 12
245 #define LTTNG_EVENT_PADDING2 LTTNG_SYMBOL_NAME_LEN + 32
248 enum lttng_event_type type
;
251 char name
[LTTNG_SYMBOL_NAME_LEN
];
254 enum lttng_loglevel_type loglevel_type
;
260 int32_t enabled
; /* Does not apply: -1 */
266 unsigned char filter
; /* filter enabled ? */
269 unsigned char exclusion
; /* exclusions added ? */
275 /* Event flag, from 2.6 and above. */
276 enum lttng_event_flag flags
;
288 /* Per event type configuration */
290 struct lttng_event_probe_attr probe
;
291 struct lttng_event_function_attr ftrace
;
293 char padding
[LTTNG_EVENT_PADDING2
];
297 #define LTTNG_EVENT_FIELD_PADDING LTTNG_SYMBOL_NAME_LEN + 32
298 struct lttng_event_field
{
299 char field_name
[LTTNG_SYMBOL_NAME_LEN
];
300 enum lttng_event_field_type type
;
301 char padding
[LTTNG_EVENT_FIELD_PADDING
];
302 struct lttng_event event
;
307 * List the event(s) of a session channel.
309 * Both handle and channel_name CAN NOT be NULL.
311 * Return the size (number of entries) of the "lttng_event" array. Caller must
312 * free events. On error a negative LTTng error code is returned.
314 LTTNG_EXPORT
extern int lttng_list_events(struct lttng_handle
*handle
,
315 const char *channel_name
,
316 struct lttng_event
**events
);
319 * Create an lttng_event.
321 * This creation function, introduced in LTTng 2.11, works around
322 * the fact that the layout of the 'lttng_event' is publicly exposed.
324 * It allocates a larger object which exposes the same public fields
325 * as a 'struct lttng_event', but also allows the use of the following extended
327 * - lttng_event_set_userspace_probe_location();
329 * Events created through this function must be destroyed using
330 * lttng_event_destroy().
332 * Returns a zeroed lttng_event on success, NULL on error.
334 LTTNG_EXPORT
extern struct lttng_event
*lttng_event_create(void);
337 * Destroy an lttng_event.
339 * This destruction function, introduced in LTTng 2.11, should only
340 * be used with events created by lttng_event_create().
342 LTTNG_EXPORT
extern void lttng_event_destroy(struct lttng_event
*event
);
345 * Get the filter expression of a specific LTTng event.
347 * If the call is successful, then the filter expression's address is put
348 * in *filter_expression. If the event has no filter expression,
349 * *filter_expression is set to NULL. The caller does NOT own
350 * *filter_expression.
352 * Returns 0 on success, or a negative LTTng error code on error.
354 LTTNG_EXPORT
extern int lttng_event_get_filter_expression(struct lttng_event
*event
,
355 const char **filter_string
);
358 * Get the number of exclusion names of a specific LTTng event.
360 * Returns the number of exclusion names on success, or a negative
361 * LTTng error code on error.
363 LTTNG_EXPORT
extern int lttng_event_get_exclusion_name_count(struct lttng_event
*event
);
366 * Get an LTTng event's exclusion name at a given index.
368 * If the call is successful, then the exclusion name string's address
369 * is put in *exclusion_name. The caller does NOT own *exclusion_name.
371 * Returns 0 on success, or a negative LTTng error code on error.
373 LTTNG_EXPORT
extern int lttng_event_get_exclusion_name(struct lttng_event
*event
,
375 const char **exclusion_name
);
378 * Get the userspace probe location of a specific LTTng event.
379 * If the call is successful, then a pointer to the probe location is returned.
380 * If the event has no probe location a NULL pointer is returned. The caller
381 * does not own the returned probe location.
383 LTTNG_EXPORT
extern const struct lttng_userspace_probe_location
*
384 lttng_event_get_userspace_probe_location(const struct lttng_event
*event
);
387 * Set an LTTng event's userspace probe location.
389 * If the call is successful, then the probe location is set to the event. The
390 * ownership of the probe_location is given to the event.
392 * Note that the event must have been created using 'lttng_event_create()' in
393 * order for this call to succeed.
395 * Returns 0 on success, or a negative LTTng error code on error.
397 LTTNG_EXPORT
extern int
398 lttng_event_set_userspace_probe_location(struct lttng_event
*event
,
399 struct lttng_userspace_probe_location
*probe_location
);
402 * List the available tracepoints of a specific lttng domain.
404 * The handle CAN NOT be NULL.
406 * Return the size (number of entries) of the "lttng_event" array. Caller must
407 * free events. On error a negative LTTng error code is returned.
409 LTTNG_EXPORT
extern int lttng_list_tracepoints(struct lttng_handle
*handle
,
410 struct lttng_event
**events
);
413 * List the available tracepoints fields of a specific lttng domain.
415 * The handle CAN NOT be NULL.
417 * Return the size (number of entries) of the "lttng_event_field" array.
418 * Caller must free fields. On error a negative LTTng error code is
421 LTTNG_EXPORT
extern int lttng_list_tracepoint_fields(struct lttng_handle
*handle
,
422 struct lttng_event_field
**fields
);
425 * List the available kernel syscall.
427 * Return the size (number of entries) of the allocated "lttng_event" array.
428 * All events in will be of type syscall. Caller must free events. On error a
429 * negative LTTng error code is returned.
431 LTTNG_EXPORT
extern int lttng_list_syscalls(struct lttng_event
**events
);
434 * Add context to event(s) for a specific channel (or for all).
436 * If the channel_name is NULL and they are no channel for the domain, the
437 * default channel is created (channel0). The context is then added on ALL
438 * channels since no name was specified.
440 * The event_name is ignored since adding a context to an event is not possible
443 * Return 0 on success else a negative LTTng error code.
445 LTTNG_EXPORT
extern int lttng_add_context(struct lttng_handle
*handle
,
446 struct lttng_event_context
*ctx
,
447 const char *event_name
,
448 const char *channel_name
);
451 * Create or enable an event (or events) for a channel.
453 * If the event you are trying to enable does not exist, it will be created,
454 * else it is enabled. If channel_name is NULL, the default channel is used
457 * The handle and ev params can not be NULL.
459 * Return 0 on success else a negative LTTng error code.
461 LTTNG_EXPORT
extern int
462 lttng_enable_event(struct lttng_handle
*handle
, struct lttng_event
*ev
, const char *channel_name
);
465 * Create or enable an event with a specific filter.
467 * If the event you are trying to enable does not exist, it will be created,
468 * else it is enabled.
469 * If ev is NULL, all events are enabled with that filter.
470 * If channel_name is NULL, the default channel is used (channel0) and created
472 * If filter_expression is NULL, an event without associated filter is
475 * Return 0 on success else a negative LTTng error code.
477 LTTNG_EXPORT
extern int lttng_enable_event_with_filter(struct lttng_handle
*handle
,
478 struct lttng_event
*event
,
479 const char *channel_name
,
480 const char *filter_expression
);
483 * Create or enable an event with a filter and/or exclusions.
485 * If the event you are trying to enable does not exist, it will be created,
486 * else it is enabled.
487 * If ev is NULL, all events are enabled with the filter and exclusion options.
488 * If channel_name is NULL, the default channel is used (channel0) and created
490 * If filter_expression is NULL, an event without associated filter is
492 * If exclusion count is zero, the event will be created without exclusions.
494 * Return 0 on success else a negative LTTng error code.
496 LTTNG_EXPORT
extern int lttng_enable_event_with_exclusions(struct lttng_handle
*handle
,
497 struct lttng_event
*event
,
498 const char *channel_name
,
499 const char *filter_expression
,
501 char **exclusion_names
);
504 * Disable event(s) of a channel and domain.
506 * If name is NULL, all events are disabled.
507 * If channel_name is NULL, the default channel is used (channel0).
509 * Return 0 on success else a negative LTTng error code.
511 LTTNG_EXPORT
extern int
512 lttng_disable_event(struct lttng_handle
*handle
, const char *name
, const char *channel_name
);
515 * Disable event(s) of a channel and domain.
517 * Takes a struct lttng_event as parameter.
518 * If channel_name is NULL, the default channel is used (channel0).
520 * Currently, @filter_expression must be NULL. (disabling specific
521 * filter expressions not implemented)
522 * Currently, only LTTNG_EVENT_ALL and LTTNG_EVENT_SYSCALL event types
523 * are implemented for field @ev.
525 * Return 0 on success else a negative LTTng error code.
527 LTTNG_EXPORT
extern int lttng_disable_event_ext(struct lttng_handle
*handle
,
528 struct lttng_event
*ev
,
529 const char *channel_name
,
530 const char *filter_expression
);
536 #endif /* LTTNG_EVENT_H */