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
, struct lttng_event
**events
);
318 * Create an lttng_event.
320 * This creation function, introduced in LTTng 2.11, works around
321 * the fact that the layout of the 'lttng_event' is publicly exposed.
323 * It allocates a larger object which exposes the same public fields
324 * as a 'struct lttng_event', but also allows the use of the following extended
326 * - lttng_event_set_userspace_probe_location();
328 * Events created through this function must be destroyed using
329 * lttng_event_destroy().
331 * Returns a zeroed lttng_event on success, NULL on error.
333 LTTNG_EXPORT
extern struct lttng_event
*lttng_event_create(void);
336 * Destroy an lttng_event.
338 * This destruction function, introduced in LTTng 2.11, should only
339 * be used with events created by lttng_event_create().
341 LTTNG_EXPORT
extern void lttng_event_destroy(struct lttng_event
*event
);
344 * Get the filter expression of a specific LTTng event.
346 * If the call is successful, then the filter expression's address is put
347 * in *filter_expression. If the event has no filter expression,
348 * *filter_expression is set to NULL. The caller does NOT own
349 * *filter_expression.
351 * Returns 0 on success, or a negative LTTng error code on error.
353 LTTNG_EXPORT
extern int lttng_event_get_filter_expression(struct lttng_event
*event
,
354 const char **filter_string
);
357 * Get the number of exclusion names of a specific LTTng event.
359 * Returns the number of exclusion names on success, or a negative
360 * LTTng error code on error.
362 LTTNG_EXPORT
extern int lttng_event_get_exclusion_name_count(struct lttng_event
*event
);
365 * Get an LTTng event's exclusion name at a given index.
367 * If the call is successful, then the exclusion name string's address
368 * is put in *exclusion_name. The caller does NOT own *exclusion_name.
370 * Returns 0 on success, or a negative LTTng error code on error.
372 LTTNG_EXPORT
extern int lttng_event_get_exclusion_name(struct lttng_event
*event
,
373 size_t index
, const char **exclusion_name
);
376 * Get the userspace probe location of a specific LTTng event.
377 * If the call is successful, then a pointer to the probe location is returned.
378 * If the event has no probe location a NULL pointer is returned. The caller
379 * does not own the returned probe location.
381 LTTNG_EXPORT
extern const struct lttng_userspace_probe_location
*
382 lttng_event_get_userspace_probe_location(const struct lttng_event
*event
);
385 * Set an LTTng event's userspace probe location.
387 * If the call is successful, then the probe location is set to the event. The
388 * ownership of the probe_location is given to the event.
390 * Note that the event must have been created using 'lttng_event_create()' in
391 * order for this call to succeed.
393 * Returns 0 on success, or a negative LTTng error code on error.
395 LTTNG_EXPORT
extern int lttng_event_set_userspace_probe_location(struct lttng_event
*event
,
396 struct lttng_userspace_probe_location
*probe_location
);
399 * List the available tracepoints of a specific lttng domain.
401 * The handle CAN NOT be NULL.
403 * Return the size (number of entries) of the "lttng_event" array. Caller must
404 * free events. On error a negative LTTng error code is returned.
406 LTTNG_EXPORT
extern int lttng_list_tracepoints(struct lttng_handle
*handle
,
407 struct lttng_event
**events
);
410 * List the available tracepoints fields of a specific lttng domain.
412 * The handle CAN NOT be NULL.
414 * Return the size (number of entries) of the "lttng_event_field" array.
415 * Caller must free fields. On error a negative LTTng error code is
418 LTTNG_EXPORT
extern int lttng_list_tracepoint_fields(struct lttng_handle
*handle
,
419 struct lttng_event_field
**fields
);
422 * List the available kernel syscall.
424 * Return the size (number of entries) of the allocated "lttng_event" array.
425 * All events in will be of type syscall. Caller must free events. On error a
426 * negative LTTng error code is returned.
428 LTTNG_EXPORT
extern int lttng_list_syscalls(struct lttng_event
**events
);
431 * Add context to event(s) for a specific channel (or for all).
433 * If the channel_name is NULL and they are no channel for the domain, the
434 * default channel is created (channel0). The context is then added on ALL
435 * channels since no name was specified.
437 * The event_name is ignored since adding a context to an event is not possible
440 * Return 0 on success else a negative LTTng error code.
442 LTTNG_EXPORT
extern int lttng_add_context(struct lttng_handle
*handle
,
443 struct lttng_event_context
*ctx
, const char *event_name
,
444 const char *channel_name
);
447 * Create or enable an event (or events) for a channel.
449 * If the event you are trying to enable does not exist, it will be created,
450 * else it is enabled. If channel_name is NULL, the default channel is used
453 * The handle and ev params can not be NULL.
455 * Return 0 on success else a negative LTTng error code.
457 LTTNG_EXPORT
extern int lttng_enable_event(struct lttng_handle
*handle
,
458 struct lttng_event
*ev
, const char *channel_name
);
461 * Create or enable an event with a specific filter.
463 * If the event you are trying to enable does not exist, it will be created,
464 * else it is enabled.
465 * If ev is NULL, all events are enabled with that filter.
466 * If channel_name is NULL, the default channel is used (channel0) and created
468 * If filter_expression is NULL, an event without associated filter is
471 * Return 0 on success else a negative LTTng error code.
473 LTTNG_EXPORT
extern int lttng_enable_event_with_filter(struct lttng_handle
*handle
,
474 struct lttng_event
*event
, const char *channel_name
,
475 const char *filter_expression
);
478 * Create or enable an event with a filter and/or exclusions.
480 * If the event you are trying to enable does not exist, it will be created,
481 * else it is enabled.
482 * If ev is NULL, all events are enabled with the filter and exclusion options.
483 * If channel_name is NULL, the default channel is used (channel0) and created
485 * If filter_expression is NULL, an event without associated filter is
487 * If exclusion count is zero, the event will be created without exclusions.
489 * Return 0 on success else a negative LTTng error code.
491 LTTNG_EXPORT
extern int lttng_enable_event_with_exclusions(struct lttng_handle
*handle
,
492 struct lttng_event
*event
, const char *channel_name
,
493 const char *filter_expression
,
494 int exclusion_count
, char **exclusion_names
);
497 * Disable event(s) of a channel and domain.
499 * If name is NULL, all events are disabled.
500 * If channel_name is NULL, the default channel is used (channel0).
502 * Return 0 on success else a negative LTTng error code.
504 LTTNG_EXPORT
extern int lttng_disable_event(struct lttng_handle
*handle
,
505 const char *name
, const char *channel_name
);
508 * Disable event(s) of a channel and domain.
510 * Takes a struct lttng_event as parameter.
511 * If channel_name is NULL, the default channel is used (channel0).
513 * Currently, @filter_expression must be NULL. (disabling specific
514 * filter expressions not implemented)
515 * Currently, only LTTNG_EVENT_ALL and LTTNG_EVENT_SYSCALL event types
516 * are implemented for field @ev.
518 * Return 0 on success else a negative LTTng error code.
520 LTTNG_EXPORT
extern int lttng_disable_event_ext(struct lttng_handle
*handle
,
521 struct lttng_event
*ev
, const char *channel_name
,
522 const char *filter_expression
);
528 #endif /* LTTNG_EVENT_H */