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,
158 LTTNG_EVENT_CONTEXT_TIME_NS
= 41,
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,
169 enum lttng_event_flag
{
170 LTTNG_EVENT_FLAG_SYSCALL_32
= (1U << 0),
171 LTTNG_EVENT_FLAG_SYSCALL_64
= (1U << 1),
175 * Perf counter attributes
177 * The structures should be initialized to zero before use.
179 #define LTTNG_PERF_EVENT_PADDING1 16
180 struct lttng_event_perf_counter_ctx
{
183 char name
[LTTNG_SYMBOL_NAME_LEN
];
185 char padding
[LTTNG_PERF_EVENT_PADDING1
];
189 * Event/channel context
191 * The structures should be initialized to zero before use.
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
];
200 struct lttng_event_perf_counter_ctx perf_counter
;
205 char padding
[LTTNG_EVENT_CONTEXT_PADDING2
];
212 * Either addr is used or symbol_name and offset.
214 * The structures should be initialized to zero before use.
216 #define LTTNG_EVENT_PROBE_PADDING1 16
217 struct lttng_event_probe_attr
{
221 char symbol_name
[LTTNG_SYMBOL_NAME_LEN
];
223 char padding
[LTTNG_EVENT_PROBE_PADDING1
];
229 * The structures should be initialized to zero before use.
231 #define LTTNG_EVENT_FUNCTION_PADDING1 16
232 struct lttng_event_function_attr
{
233 char symbol_name
[LTTNG_SYMBOL_NAME_LEN
];
235 char padding
[LTTNG_EVENT_FUNCTION_PADDING1
];
239 * Generic lttng event
241 * The structures should be initialized to zero before use.
243 #define LTTNG_EVENT_PADDING1 12
244 #define LTTNG_EVENT_PADDING2 LTTNG_SYMBOL_NAME_LEN + 32
247 enum lttng_event_type type
;
250 char name
[LTTNG_SYMBOL_NAME_LEN
];
253 enum lttng_loglevel_type loglevel_type
;
259 int32_t enabled
; /* Does not apply: -1 */
265 unsigned char filter
; /* filter enabled ? */
268 unsigned char exclusion
; /* exclusions added ? */
274 /* Event flag, from 2.6 and above. */
275 enum lttng_event_flag flags
;
287 /* Per event type configuration */
289 struct lttng_event_probe_attr probe
;
290 struct lttng_event_function_attr ftrace
;
292 char padding
[LTTNG_EVENT_PADDING2
];
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
;
306 * List the event(s) of a session channel.
308 * Both handle and channel_name CAN NOT be NULL.
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.
313 extern int lttng_list_events(struct lttng_handle
*handle
,
314 const char *channel_name
, struct lttng_event
**events
);
317 * Create an lttng_event.
319 * This creation function, introduced in LTTng 2.11, works around
320 * the fact that the layout of the 'lttng_event' is publicly exposed.
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
325 * - lttng_event_set_userspace_probe_location();
327 * Events created through this function must be destroyed using
328 * lttng_event_destroy().
330 * Returns a zeroed lttng_event on success, NULL on error.
332 extern struct lttng_event
*lttng_event_create(void);
335 * Destroy an lttng_event.
337 * This destruction function, introduced in LTTng 2.11, should only
338 * be used with events created by lttng_event_create().
340 extern void lttng_event_destroy(struct lttng_event
*event
);
343 * Get the filter expression of a specific LTTng event.
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.
350 * Returns 0 on success, or a negative LTTng error code on error.
352 extern int lttng_event_get_filter_expression(struct lttng_event
*event
,
353 const char **filter_string
);
356 * Get the number of exclusion names of a specific LTTng event.
358 * Returns the number of exclusion names on success, or a negative
359 * LTTng error code on error.
361 extern int lttng_event_get_exclusion_name_count(struct lttng_event
*event
);
364 * Get an LTTng event's exclusion name at a given index.
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.
369 * Returns 0 on success, or a negative LTTng error code on error.
371 extern int lttng_event_get_exclusion_name(struct lttng_event
*event
,
372 size_t index
, const char **exclusion_name
);
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.
380 extern const struct lttng_userspace_probe_location
*
381 lttng_event_get_userspace_probe_location(const struct lttng_event
*event
);
384 * Set an LTTng event's userspace probe location.
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.
389 * Note that the event must have been created using 'lttng_event_create()' in
390 * order for this call to succeed.
392 * Returns 0 on success, or a negative LTTng error code on error.
394 extern int lttng_event_set_userspace_probe_location(struct lttng_event
*event
,
395 struct lttng_userspace_probe_location
*probe_location
);
398 * List the available tracepoints of a specific lttng domain.
400 * The handle CAN NOT be NULL.
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.
405 extern int lttng_list_tracepoints(struct lttng_handle
*handle
,
406 struct lttng_event
**events
);
409 * List the available tracepoints fields of a specific lttng domain.
411 * The handle CAN NOT be NULL.
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
417 extern int lttng_list_tracepoint_fields(struct lttng_handle
*handle
,
418 struct lttng_event_field
**fields
);
421 * List the available kernel syscall.
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.
427 extern int lttng_list_syscalls(struct lttng_event
**events
);
430 * Add context to event(s) for a specific channel (or for all).
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.
436 * The event_name is ignored since adding a context to an event is not possible
439 * Return 0 on success else a negative LTTng error code.
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
);
446 * Create or enable an event (or events) for a channel.
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
452 * The handle and ev params can not be NULL.
454 * Return 0 on success else a negative LTTng error code.
456 extern int lttng_enable_event(struct lttng_handle
*handle
,
457 struct lttng_event
*ev
, const char *channel_name
);
460 * Create or enable an event with a specific filter.
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
467 * If filter_expression is NULL, an event without associated filter is
470 * Return 0 on success else a negative LTTng error code.
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
);
477 * Create or enable an event with a filter and/or exclusions.
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
484 * If filter_expression is NULL, an event without associated filter is
486 * If exclusion count is zero, the event will be created without exclusions.
488 * Return 0 on success else a negative LTTng error code.
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
);
496 * Disable event(s) of a channel and domain.
498 * If name is NULL, all events are disabled.
499 * If channel_name is NULL, the default channel is used (channel0).
501 * Return 0 on success else a negative LTTng error code.
503 extern int lttng_disable_event(struct lttng_handle
*handle
,
504 const char *name
, const char *channel_name
);
507 * Disable event(s) of a channel and domain.
509 * Takes a struct lttng_event as parameter.
510 * If channel_name is NULL, the default channel is used (channel0).
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.
517 * Return 0 on success else a negative LTTng error code.
519 extern int lttng_disable_event_ext(struct lttng_handle
*handle
,
520 struct lttng_event
*ev
, const char *channel_name
,
521 const char *filter_expression
);
527 #endif /* LTTNG_EVENT_H */