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
16 #include <lttng/handle.h>
17 #include <lttng/userspace-probe.h>
20 * Instrumentation type of tracing event.
22 enum lttng_event_type
{
24 LTTNG_EVENT_TRACEPOINT
= 0,
25 LTTNG_EVENT_PROBE
= 1,
26 LTTNG_EVENT_FUNCTION
= 2,
27 LTTNG_EVENT_FUNCTION_ENTRY
= 3,
29 LTTNG_EVENT_SYSCALL
= 5,
30 LTTNG_EVENT_USERSPACE_PROBE
= 6,
34 * Loglevel information.
36 enum lttng_loglevel_type
{
37 LTTNG_EVENT_LOGLEVEL_ALL
= 0,
38 LTTNG_EVENT_LOGLEVEL_RANGE
= 1,
39 LTTNG_EVENT_LOGLEVEL_SINGLE
= 2,
43 * Available loglevels.
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,
64 * Available loglevels for the JUL domain. Those are an exact map from the
65 * class java.util.logging.Level.
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
,
80 * Available loglevels for the LOG4j domain. Those are an exact map from the
81 * class org.apache.log4j.Level.
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
,
95 * Available loglevels for the Python domain. Those are an exact map from the
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,
108 * LTTng consumer mode
110 enum lttng_event_output
{
111 LTTNG_EVENT_SPLICE
= 0,
112 LTTNG_EVENT_MMAP
= 1,
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,
160 enum 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,
168 enum lttng_event_flag
{
169 LTTNG_EVENT_FLAG_SYSCALL_32
= (1U << 0),
170 LTTNG_EVENT_FLAG_SYSCALL_64
= (1U << 1),
174 * Perf counter attributes
176 * The structures should be initialized to zero before use.
178 #define LTTNG_PERF_EVENT_PADDING1 16
179 struct lttng_event_perf_counter_ctx
{
182 char name
[LTTNG_SYMBOL_NAME_LEN
];
184 char padding
[LTTNG_PERF_EVENT_PADDING1
];
188 * Event/channel context
190 * The structures should be initialized to zero before use.
192 #define LTTNG_EVENT_CONTEXT_PADDING1 16
193 #define LTTNG_EVENT_CONTEXT_PADDING2 LTTNG_SYMBOL_NAME_LEN + 32
194 struct lttng_event_context
{
195 enum lttng_event_context_type ctx
;
196 char padding
[LTTNG_EVENT_CONTEXT_PADDING1
];
199 struct lttng_event_perf_counter_ctx perf_counter
;
204 char padding
[LTTNG_EVENT_CONTEXT_PADDING2
];
211 * Either addr is used or symbol_name and offset.
213 * The structures should be initialized to zero before use.
215 #define LTTNG_EVENT_PROBE_PADDING1 16
216 struct lttng_event_probe_attr
{
220 char symbol_name
[LTTNG_SYMBOL_NAME_LEN
];
222 char padding
[LTTNG_EVENT_PROBE_PADDING1
];
228 * The structures should be initialized to zero before use.
230 #define LTTNG_EVENT_FUNCTION_PADDING1 16
231 struct lttng_event_function_attr
{
232 char symbol_name
[LTTNG_SYMBOL_NAME_LEN
];
234 char padding
[LTTNG_EVENT_FUNCTION_PADDING1
];
238 * Generic lttng event
240 * The structures should be initialized to zero before use.
242 #define LTTNG_EVENT_PADDING1 12
243 #define LTTNG_EVENT_PADDING2 LTTNG_SYMBOL_NAME_LEN + 32
246 enum lttng_event_type type
;
249 char name
[LTTNG_SYMBOL_NAME_LEN
];
252 enum lttng_loglevel_type loglevel_type
;
258 int32_t enabled
; /* Does not apply: -1 */
264 unsigned char filter
; /* filter enabled ? */
267 unsigned char exclusion
; /* exclusions added ? */
273 /* Event flag, from 2.6 and above. */
274 enum lttng_event_flag flags
;
286 /* Per event type configuration */
288 struct lttng_event_probe_attr probe
;
289 struct lttng_event_function_attr ftrace
;
291 char padding
[LTTNG_EVENT_PADDING2
];
295 #define LTTNG_EVENT_FIELD_PADDING LTTNG_SYMBOL_NAME_LEN + 32
296 struct 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
;
305 * List the event(s) of a session channel.
307 * Both handle and channel_name CAN NOT be NULL.
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.
312 extern int lttng_list_events(struct lttng_handle
*handle
,
313 const char *channel_name
, struct lttng_event
**events
);
316 * Create an lttng_event.
318 * This creation function, introduced in LTTng 2.11, works around
319 * the fact that the layout of the 'lttng_event' is publicly exposed.
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
324 * - lttng_event_set_userspace_probe_location();
326 * Events created through this function must be destroyed using
327 * lttng_event_destroy().
329 * Returns a zeroed lttng_event on success, NULL on error.
331 extern struct lttng_event
*lttng_event_create(void);
334 * Destroy an lttng_event.
336 * This destruction function, introduced in LTTng 2.11, should only
337 * be used with events created by lttng_event_create().
339 extern void lttng_event_destroy(struct lttng_event
*event
);
342 * Get the filter expression of a specific LTTng event.
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.
349 * Returns 0 on success, or a negative LTTng error code on error.
351 extern int lttng_event_get_filter_expression(struct lttng_event
*event
,
352 const char **filter_string
);
355 * Get the number of exclusion names of a specific LTTng event.
357 * Returns the number of exclusion names on success, or a negative
358 * LTTng error code on error.
360 extern int lttng_event_get_exclusion_name_count(struct lttng_event
*event
);
363 * Get an LTTng event's exclusion name at a given index.
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.
368 * Returns 0 on success, or a negative LTTng error code on error.
370 extern int lttng_event_get_exclusion_name(struct lttng_event
*event
,
371 size_t index
, const char **exclusion_name
);
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.
379 extern const struct lttng_userspace_probe_location
*
380 lttng_event_get_userspace_probe_location(const struct lttng_event
*event
);
383 * Set an LTTng event's userspace probe location.
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.
388 * Note that the event must have been created using 'lttng_event_create()' in
389 * order for this call to succeed.
391 * Returns 0 on success, or a negative LTTng error code on error.
393 extern int lttng_event_set_userspace_probe_location(struct lttng_event
*event
,
394 struct lttng_userspace_probe_location
*probe_location
);
397 * List the available tracepoints of a specific lttng domain.
399 * The handle CAN NOT be NULL.
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.
404 extern int lttng_list_tracepoints(struct lttng_handle
*handle
,
405 struct lttng_event
**events
);
408 * List the available tracepoints fields of a specific lttng domain.
410 * The handle CAN NOT be NULL.
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
416 extern int lttng_list_tracepoint_fields(struct lttng_handle
*handle
,
417 struct lttng_event_field
**fields
);
420 * List the available kernel syscall.
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.
426 extern int lttng_list_syscalls(struct lttng_event
**events
);
429 * Add context to event(s) for a specific channel (or for all).
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.
435 * The event_name is ignored since adding a context to an event is not possible
438 * Return 0 on success else a negative LTTng error code.
440 extern int lttng_add_context(struct lttng_handle
*handle
,
441 struct lttng_event_context
*ctx
, const char *event_name
,
442 const char *channel_name
);
445 * Create or enable an event (or events) for a channel.
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
451 * The handle and ev params can not be NULL.
453 * Return 0 on success else a negative LTTng error code.
455 extern int lttng_enable_event(struct lttng_handle
*handle
,
456 struct lttng_event
*ev
, const char *channel_name
);
459 * Create or enable an event with a specific filter.
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
466 * If filter_expression is NULL, an event without associated filter is
469 * Return 0 on success else a negative LTTng error code.
471 extern int lttng_enable_event_with_filter(struct lttng_handle
*handle
,
472 struct lttng_event
*event
, const char *channel_name
,
473 const char *filter_expression
);
476 * Create or enable an event with a filter and/or exclusions.
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
483 * If filter_expression is NULL, an event without associated filter is
485 * If exclusion count is zero, the event will be created without exclusions.
487 * Return 0 on success else a negative LTTng error code.
489 extern 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
);
495 * Disable event(s) of a channel and domain.
497 * If name is NULL, all events are disabled.
498 * If channel_name is NULL, the default channel is used (channel0).
500 * Return 0 on success else a negative LTTng error code.
502 extern int lttng_disable_event(struct lttng_handle
*handle
,
503 const char *name
, const char *channel_name
);
506 * Disable event(s) of a channel and domain.
508 * Takes a struct lttng_event as parameter.
509 * If channel_name is NULL, the default channel is used (channel0).
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.
516 * Return 0 on success else a negative LTTng error code.
518 int lttng_disable_event_ext(struct lttng_handle
*handle
,
519 struct lttng_event
*ev
, const char *channel_name
,
520 const char *filter_expression
);
526 #endif /* LTTNG_EVENT_H */