1 /* SPDX-License-Identifier: (GPL-2.0-only or LGPL-2.1-only)
7 * Copyright (C) 2010-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
14 #include <linux/types.h>
17 * Major/minor version of ABI exposed to lttng tools. Major number
18 * should be increased when an incompatible ABI change is done.
20 #define LTTNG_MODULES_ABI_MAJOR_VERSION 2
21 #define LTTNG_MODULES_ABI_MINOR_VERSION 6
23 #define LTTNG_KERNEL_SYM_NAME_LEN 256
24 #define LTTNG_KERNEL_SESSION_NAME_LEN 256
25 #define LTTNG_KERNEL_SESSION_CREATION_TIME_ISO8601_LEN 26
27 enum lttng_kernel_instrumentation
{
28 LTTNG_KERNEL_TRACEPOINT
= 0,
29 LTTNG_KERNEL_KPROBE
= 1,
30 LTTNG_KERNEL_FUNCTION
= 2,
31 LTTNG_KERNEL_KRETPROBE
= 3,
32 LTTNG_KERNEL_NOOP
= 4, /* not hooked */
33 LTTNG_KERNEL_SYSCALL
= 5,
34 LTTNG_KERNEL_UPROBE
= 6,
40 enum lttng_kernel_output
{
41 LTTNG_KERNEL_SPLICE
= 0,
42 LTTNG_KERNEL_MMAP
= 1,
46 * LTTng DebugFS ABI structures.
48 #define LTTNG_KERNEL_CHANNEL_PADDING LTTNG_KERNEL_SYM_NAME_LEN + 32
49 struct lttng_kernel_channel
{
50 uint64_t subbuf_size
; /* in bytes */
52 unsigned int switch_timer_interval
; /* usecs */
53 unsigned int read_timer_interval
; /* usecs */
54 uint32_t output
; /* enum lttng_kernel_output (splice, mmap) */
55 int overwrite
; /* 1: overwrite, 0: discard */
56 char padding
[LTTNG_KERNEL_CHANNEL_PADDING
];
57 } __attribute__((packed
));
59 struct lttng_kernel_kretprobe
{
63 char symbol_name
[LTTNG_KERNEL_SYM_NAME_LEN
];
64 } __attribute__((packed
));
67 * Either addr is used, or symbol_name and offset.
69 struct lttng_kernel_kprobe
{
73 char symbol_name
[LTTNG_KERNEL_SYM_NAME_LEN
];
74 } __attribute__((packed
));
76 struct lttng_kernel_function_tracer
{
77 char symbol_name
[LTTNG_KERNEL_SYM_NAME_LEN
];
78 } __attribute__((packed
));
80 struct lttng_kernel_uprobe
{
82 } __attribute__((packed
));
84 struct lttng_kernel_event_callsite_uprobe
{
86 } __attribute__((packed
));
88 struct lttng_kernel_event_callsite
{
90 struct lttng_kernel_event_callsite_uprobe uprobe
;
92 } __attribute__((packed
));
94 enum lttng_kernel_syscall_entryexit
{
95 LTTNG_KERNEL_SYSCALL_ENTRYEXIT
= 0,
96 LTTNG_KERNEL_SYSCALL_ENTRY
= 1,
97 LTTNG_KERNEL_SYSCALL_EXIT
= 2,
100 enum lttng_kernel_syscall_abi
{
101 LTTNG_KERNEL_SYSCALL_ABI_ALL
= 0,
102 LTTNG_KERNEL_SYSCALL_ABI_NATIVE
= 1,
103 LTTNG_KERNEL_SYSCALL_ABI_COMPAT
= 2,
106 enum lttng_kernel_syscall_match
{
107 LTTNG_KERNEL_SYSCALL_MATCH_NAME
= 0,
108 LTTNG_KERNEL_SYSCALL_MATCH_NR
= 1, /* Not implemented. */
111 struct lttng_kernel_syscall
{
112 uint8_t entryexit
; /* enum lttng_kernel_syscall_entryexit */
113 uint8_t abi
; /* enum lttng_kernel_syscall_abi */
114 uint8_t match
; /* enum lttng_kernel_syscall_match */
116 uint32_t nr
; /* For LTTNG_SYSCALL_MATCH_NR */
117 } __attribute__((packed
));
120 * For syscall tracing, name = "*" means "enable all".
122 #define LTTNG_KERNEL_EVENT_PADDING1 8
123 #define LTTNG_KERNEL_EVENT_PADDING2 LTTNG_KERNEL_SYM_NAME_LEN + 32
124 struct lttng_kernel_event
{
125 char name
[LTTNG_KERNEL_SYM_NAME_LEN
]; /* event name */
126 uint32_t instrumentation
; /* enum lttng_kernel_instrumentation */
127 uint64_t token
; /* User-provided token */
128 char padding
[LTTNG_KERNEL_EVENT_PADDING1
];
130 /* Per instrumentation type configuration */
132 struct lttng_kernel_kretprobe kretprobe
;
133 struct lttng_kernel_kprobe kprobe
;
134 struct lttng_kernel_function_tracer ftrace
;
135 struct lttng_kernel_uprobe uprobe
;
136 struct lttng_kernel_syscall syscall
;
137 char padding
[LTTNG_KERNEL_EVENT_PADDING2
];
139 } __attribute__((packed
));
141 #define LTTNG_KERNEL_EVENT_NOTIFIER_PADDING 32
142 struct lttng_kernel_event_notifier
{
143 struct lttng_kernel_event event
;
144 uint64_t error_counter_index
;
146 char padding
[LTTNG_KERNEL_EVENT_NOTIFIER_PADDING
];
147 } __attribute__((packed
));
149 #define LTTNG_KERNEL_COUNTER_DIMENSION_MAX 4
151 enum lttng_kernel_counter_arithmetic
{
152 LTTNG_KERNEL_COUNTER_ARITHMETIC_MODULAR
= 0,
155 enum lttng_kernel_counter_bitness
{
156 LTTNG_KERNEL_COUNTER_BITNESS_32
= 0,
157 LTTNG_KERNEL_COUNTER_BITNESS_64
= 1,
160 struct lttng_kernel_counter_dimension
{
162 uint64_t underflow_index
;
163 uint64_t overflow_index
;
164 uint8_t has_underflow
;
165 uint8_t has_overflow
;
166 } __attribute__((packed
));
168 #define LTTNG_KERNEL_COUNTER_CONF_PADDING1 67
169 struct lttng_kernel_counter_conf
{
170 uint32_t arithmetic
; /* enum lttng_kernel_counter_arithmetic */
171 uint32_t bitness
; /* enum lttng_kernel_counter_bitness */
172 uint32_t number_dimensions
;
173 int64_t global_sum_step
;
174 struct lttng_kernel_counter_dimension dimensions
[LTTNG_KERNEL_COUNTER_DIMENSION_MAX
];
175 uint8_t coalesce_hits
;
176 char padding
[LTTNG_KERNEL_COUNTER_CONF_PADDING1
];
177 } __attribute__((packed
));
179 struct lttng_kernel_counter_index
{
180 uint32_t number_dimensions
;
181 uint64_t dimension_indexes
[LTTNG_KERNEL_COUNTER_DIMENSION_MAX
];
182 } __attribute__((packed
));
184 struct lttng_kernel_counter_value
{
188 } __attribute__((packed
));
190 #define LTTNG_KERNEL_COUNTER_READ_PADDING 32
191 struct lttng_kernel_counter_read
{
192 struct lttng_kernel_counter_index index
;
193 int32_t cpu
; /* -1 for global counter, >= 0 for specific cpu. */
194 struct lttng_kernel_counter_value value
; /* output */
195 char padding
[LTTNG_KERNEL_COUNTER_READ_PADDING
];
196 } __attribute__((packed
));
198 #define LTTNG_KERNEL_COUNTER_AGGREGATE_PADDING 32
199 struct lttng_kernel_counter_aggregate
{
200 struct lttng_kernel_counter_index index
;
201 struct lttng_kernel_counter_value value
; /* output */
202 char padding
[LTTNG_KERNEL_COUNTER_AGGREGATE_PADDING
];
203 } __attribute__((packed
));
205 #define LTTNG_KERNEL_COUNTER_CLEAR_PADDING 32
206 struct lttng_kernel_counter_clear
{
207 struct lttng_kernel_counter_index index
;
208 char padding
[LTTNG_KERNEL_COUNTER_CLEAR_PADDING
];
209 } __attribute__((packed
));
211 #define LTTNG_KERNEL_EVENT_NOTIFIER_NOTIFICATION_PADDING 32
212 struct lttng_kernel_event_notifier_notification
{
214 uint16_t capture_buf_size
;
215 char padding
[LTTNG_KERNEL_EVENT_NOTIFIER_NOTIFICATION_PADDING
];
216 } __attribute__((packed
));
218 struct lttng_kernel_tracer_version
{
222 } __attribute__((packed
));
224 struct lttng_kernel_tracer_abi_version
{
227 } __attribute__((packed
));
229 struct lttng_kernel_session_name
{
230 char name
[LTTNG_KERNEL_SESSION_NAME_LEN
];
231 } __attribute__((packed
));
233 struct lttng_kernel_session_creation_time
{
234 char iso8601
[LTTNG_KERNEL_SESSION_CREATION_TIME_ISO8601_LEN
];
235 } __attribute__((packed
));
237 enum lttng_kernel_calibrate_type
{
238 LTTNG_KERNEL_CALIBRATE_KRETPROBE
,
241 struct lttng_kernel_calibrate
{
242 uint32_t type
; /* enum lttng_kernel_calibrate_type (input) */
243 } __attribute__((packed
));
245 struct lttng_kernel_syscall_mask
{
246 uint32_t len
; /* in bits */
248 } __attribute__((packed
));
250 enum lttng_kernel_context_type
{
251 LTTNG_KERNEL_CONTEXT_PID
= 0,
252 LTTNG_KERNEL_CONTEXT_PERF_COUNTER
= 1,
253 LTTNG_KERNEL_CONTEXT_PROCNAME
= 2,
254 LTTNG_KERNEL_CONTEXT_PRIO
= 3,
255 LTTNG_KERNEL_CONTEXT_NICE
= 4,
256 LTTNG_KERNEL_CONTEXT_VPID
= 5,
257 LTTNG_KERNEL_CONTEXT_TID
= 6,
258 LTTNG_KERNEL_CONTEXT_VTID
= 7,
259 LTTNG_KERNEL_CONTEXT_PPID
= 8,
260 LTTNG_KERNEL_CONTEXT_VPPID
= 9,
261 LTTNG_KERNEL_CONTEXT_HOSTNAME
= 10,
262 LTTNG_KERNEL_CONTEXT_CPU_ID
= 11,
263 LTTNG_KERNEL_CONTEXT_INTERRUPTIBLE
= 12,
264 LTTNG_KERNEL_CONTEXT_PREEMPTIBLE
= 13,
265 LTTNG_KERNEL_CONTEXT_NEED_RESCHEDULE
= 14,
266 LTTNG_KERNEL_CONTEXT_MIGRATABLE
= 15,
267 LTTNG_KERNEL_CONTEXT_CALLSTACK_KERNEL
= 16,
268 LTTNG_KERNEL_CONTEXT_CALLSTACK_USER
= 17,
269 LTTNG_KERNEL_CONTEXT_CGROUP_NS
= 18,
270 LTTNG_KERNEL_CONTEXT_IPC_NS
= 19,
271 LTTNG_KERNEL_CONTEXT_MNT_NS
= 20,
272 LTTNG_KERNEL_CONTEXT_NET_NS
= 21,
273 LTTNG_KERNEL_CONTEXT_PID_NS
= 22,
274 LTTNG_KERNEL_CONTEXT_USER_NS
= 23,
275 LTTNG_KERNEL_CONTEXT_UTS_NS
= 24,
276 LTTNG_KERNEL_CONTEXT_UID
= 25,
277 LTTNG_KERNEL_CONTEXT_EUID
= 26,
278 LTTNG_KERNEL_CONTEXT_SUID
= 27,
279 LTTNG_KERNEL_CONTEXT_GID
= 28,
280 LTTNG_KERNEL_CONTEXT_EGID
= 29,
281 LTTNG_KERNEL_CONTEXT_SGID
= 30,
282 LTTNG_KERNEL_CONTEXT_VUID
= 31,
283 LTTNG_KERNEL_CONTEXT_VEUID
= 32,
284 LTTNG_KERNEL_CONTEXT_VSUID
= 33,
285 LTTNG_KERNEL_CONTEXT_VGID
= 34,
286 LTTNG_KERNEL_CONTEXT_VEGID
= 35,
287 LTTNG_KERNEL_CONTEXT_VSGID
= 36,
288 LTTNG_KERNEL_CONTEXT_TIME_NS
= 37,
291 struct lttng_kernel_perf_counter_ctx
{
294 char name
[LTTNG_KERNEL_SYM_NAME_LEN
];
295 } __attribute__((packed
));
297 #define LTTNG_KERNEL_CONTEXT_PADDING1 16
298 #define LTTNG_KERNEL_CONTEXT_PADDING2 LTTNG_KERNEL_SYM_NAME_LEN + 32
299 struct lttng_kernel_context
{
300 uint32_t ctx
; /*enum lttng_kernel_context_type */
301 char padding
[LTTNG_KERNEL_CONTEXT_PADDING1
];
304 struct lttng_kernel_perf_counter_ctx perf_counter
;
305 char padding
[LTTNG_KERNEL_CONTEXT_PADDING2
];
307 } __attribute__((packed
));
309 #define LTTNG_KERNEL_FILTER_BYTECODE_MAX_LEN 65536
310 struct lttng_kernel_filter_bytecode
{
312 uint32_t reloc_offset
;
315 } __attribute__((packed
));
317 #define LTTNG_KERNEL_CAPTURE_BYTECODE_MAX_LEN 65536
318 struct lttng_kernel_capture_bytecode
{
320 uint32_t reloc_offset
;
323 } __attribute__((packed
));
325 enum lttng_kernel_tracker_type
{
326 LTTNG_KERNEL_TRACKER_UNKNOWN
= -1,
328 LTTNG_KERNEL_TRACKER_PID
= 0,
329 LTTNG_KERNEL_TRACKER_VPID
= 1,
330 LTTNG_KERNEL_TRACKER_UID
= 2,
331 LTTNG_KERNEL_TRACKER_VUID
= 3,
332 LTTNG_KERNEL_TRACKER_GID
= 4,
333 LTTNG_KERNEL_TRACKER_VGID
= 5,
336 struct lttng_kernel_tracker_args
{
337 uint32_t type
; /* enum lttng_kernel_tracker_type */
341 /* LTTng file descriptor ioctl */
342 /* lttng/abi-old.h reserve 0x40, 0x41, 0x42, 0x43, and 0x44. */
343 #define LTTNG_KERNEL_SESSION _IO(0xF6, 0x45)
344 #define LTTNG_KERNEL_TRACER_VERSION \
345 _IOR(0xF6, 0x46, struct lttng_kernel_tracer_version)
346 #define LTTNG_KERNEL_TRACEPOINT_LIST _IO(0xF6, 0x47)
347 #define LTTNG_KERNEL_WAIT_QUIESCENT _IO(0xF6, 0x48)
348 #define LTTNG_KERNEL_CALIBRATE \
349 _IOWR(0xF6, 0x49, struct lttng_kernel_calibrate)
350 #define LTTNG_KERNEL_SYSCALL_LIST _IO(0xF6, 0x4A)
351 #define LTTNG_KERNEL_TRACER_ABI_VERSION \
352 _IOR(0xF6, 0x4B, struct lttng_kernel_tracer_abi_version)
353 #define LTTNG_KERNEL_EVENT_NOTIFIER_GROUP_CREATE _IO(0xF6, 0x4C)
355 /* Session FD ioctl */
356 /* lttng/abi-old.h reserve 0x50, 0x51, 0x52, and 0x53. */
357 #define LTTNG_KERNEL_METADATA \
358 _IOW(0xF6, 0x54, struct lttng_kernel_channel)
359 #define LTTNG_KERNEL_CHANNEL \
360 _IOW(0xF6, 0x55, struct lttng_kernel_channel)
361 #define LTTNG_KERNEL_SESSION_START _IO(0xF6, 0x56)
362 #define LTTNG_KERNEL_SESSION_STOP _IO(0xF6, 0x57)
363 #define LTTNG_KERNEL_SESSION_TRACK_PID \
364 _IOR(0xF6, 0x58, int32_t)
365 #define LTTNG_KERNEL_SESSION_UNTRACK_PID \
366 _IOR(0xF6, 0x59, int32_t)
369 * ioctl 0x58 and 0x59 are duplicated here. It works, since _IOR vs _IO
370 * are generating two different ioctl numbers, but this was not done on
371 * purpose. We should generally try to avoid those duplications.
373 #define LTTNG_KERNEL_SESSION_LIST_TRACKER_PIDS _IO(0xF6, 0x58)
374 #define LTTNG_KERNEL_SESSION_METADATA_REGEN _IO(0xF6, 0x59)
376 /* lttng/abi-old.h reserve 0x5A and 0x5B. */
377 #define LTTNG_KERNEL_SESSION_STATEDUMP _IO(0xF6, 0x5C)
378 #define LTTNG_KERNEL_SESSION_SET_NAME \
379 _IOR(0xF6, 0x5D, struct lttng_kernel_session_name)
380 #define LTTNG_KERNEL_SESSION_SET_CREATION_TIME \
381 _IOR(0xF6, 0x5E, struct lttng_kernel_session_creation_time)
383 /* Channel FD ioctl */
384 /* lttng/abi-old.h reserve 0x60 and 0x61. */
385 #define LTTNG_KERNEL_STREAM _IO(0xF6, 0x62)
386 #define LTTNG_KERNEL_EVENT \
387 _IOW(0xF6, 0x63, struct lttng_kernel_event)
388 #define LTTNG_KERNEL_SYSCALL_MASK \
389 _IOWR(0xF6, 0x64, struct lttng_kernel_syscall_mask)
391 /* Event and Channel FD ioctl */
392 /* lttng/abi-old.h reserve 0x70. */
393 #define LTTNG_KERNEL_CONTEXT \
394 _IOW(0xF6, 0x71, struct lttng_kernel_context)
396 /* Event, Event notifier, Channel, Counter and Session ioctl */
397 /* lttng/abi-old.h reserve 0x80 and 0x81. */
398 #define LTTNG_KERNEL_ENABLE _IO(0xF6, 0x82)
399 #define LTTNG_KERNEL_DISABLE _IO(0xF6, 0x83)
401 /* Trigger group and session ioctl */
402 #define LTTNG_KERNEL_COUNTER \
403 _IOW(0xF6, 0x84, struct lttng_kernel_counter_conf)
405 /* Event and Event notifier FD ioctl */
406 #define LTTNG_KERNEL_FILTER _IO(0xF6, 0x90)
407 #define LTTNG_KERNEL_ADD_CALLSITE _IO(0xF6, 0x91)
409 /* Session FD ioctl (continued) */
410 #define LTTNG_KERNEL_SESSION_LIST_TRACKER_IDS \
411 _IOR(0xF6, 0xA0, struct lttng_kernel_tracker_args)
412 #define LTTNG_KERNEL_SESSION_TRACK_ID \
413 _IOR(0xF6, 0xA1, struct lttng_kernel_tracker_args)
414 #define LTTNG_KERNEL_SESSION_UNTRACK_ID \
415 _IOR(0xF6, 0xA2, struct lttng_kernel_tracker_args)
417 /* Event notifier group file descriptor ioctl */
418 #define LTTNG_KERNEL_EVENT_NOTIFIER_CREATE \
419 _IOW(0xF6, 0xB0, struct lttng_kernel_event_notifier)
420 #define LTTNG_KERNEL_EVENT_NOTIFIER_GROUP_NOTIFICATION_FD \
423 /* Event notifier file descriptor ioctl */
424 #define LTTNG_KERNEL_CAPTURE _IO(0xF6, 0xB8)
426 /* Counter file descriptor ioctl */
427 #define LTTNG_KERNEL_COUNTER_READ \
428 _IOWR(0xF6, 0xC0, struct lttng_kernel_counter_read)
429 #define LTTNG_KERNEL_COUNTER_AGGREGATE \
430 _IOWR(0xF6, 0xC1, struct lttng_kernel_counter_aggregate)
431 #define LTTNG_KERNEL_COUNTER_CLEAR \
432 _IOW(0xF6, 0xC2, struct lttng_kernel_counter_clear)
436 * LTTng-specific ioctls for the lib ringbuffer.
438 * Operations applying to the current sub-buffer need to occur between
439 * a get/put or get_next/put_next ioctl pair.
442 /* returns the timestamp begin of the current sub-buffer */
443 #define LTTNG_RING_BUFFER_GET_TIMESTAMP_BEGIN _IOR(0xF6, 0x20, uint64_t)
444 /* returns the timestamp end of the current sub-buffer */
445 #define LTTNG_RING_BUFFER_GET_TIMESTAMP_END _IOR(0xF6, 0x21, uint64_t)
446 /* returns the number of events discarded of the current sub-buffer */
447 #define LTTNG_RING_BUFFER_GET_EVENTS_DISCARDED _IOR(0xF6, 0x22, uint64_t)
448 /* returns the packet payload size of the current sub-buffer */
449 #define LTTNG_RING_BUFFER_GET_CONTENT_SIZE _IOR(0xF6, 0x23, uint64_t)
450 /* returns the packet size of the current sub-buffer*/
451 #define LTTNG_RING_BUFFER_GET_PACKET_SIZE _IOR(0xF6, 0x24, uint64_t)
452 /* returns the stream id (invariant for the stream) */
453 #define LTTNG_RING_BUFFER_GET_STREAM_ID _IOR(0xF6, 0x25, uint64_t)
454 /* returns the current timestamp as perceived from the tracer */
455 #define LTTNG_RING_BUFFER_GET_CURRENT_TIMESTAMP _IOR(0xF6, 0x26, uint64_t)
456 /* returns the packet sequence number of the current sub-buffer */
457 #define LTTNG_RING_BUFFER_GET_SEQ_NUM _IOR(0xF6, 0x27, uint64_t)
458 /* returns the stream instance id (invariant for the stream) */
459 #define LTTNG_RING_BUFFER_INSTANCE_ID _IOR(0xF6, 0x28, uint64_t)
462 /* returns the timestamp begin of the current sub-buffer */
463 #define LTTNG_RING_BUFFER_COMPAT_GET_TIMESTAMP_BEGIN \
464 LTTNG_RING_BUFFER_GET_TIMESTAMP_BEGIN
465 /* returns the timestamp end of the current sub-buffer */
466 #define LTTNG_RING_BUFFER_COMPAT_GET_TIMESTAMP_END \
467 LTTNG_RING_BUFFER_GET_TIMESTAMP_END
468 /* returns the number of events discarded of the current sub-buffer */
469 #define LTTNG_RING_BUFFER_COMPAT_GET_EVENTS_DISCARDED \
470 LTTNG_RING_BUFFER_GET_EVENTS_DISCARDED
471 /* returns the packet payload size of the current sub-buffer */
472 #define LTTNG_RING_BUFFER_COMPAT_GET_CONTENT_SIZE \
473 LTTNG_RING_BUFFER_GET_CONTENT_SIZE
474 /* returns the packet size of the current sub-buffer */
475 #define LTTNG_RING_BUFFER_COMPAT_GET_PACKET_SIZE \
476 LTTNG_RING_BUFFER_GET_PACKET_SIZE
477 /* returns the stream id (invariant for the stream) */
478 #define LTTNG_RING_BUFFER_COMPAT_GET_STREAM_ID \
479 LTTNG_RING_BUFFER_GET_STREAM_ID
480 /* returns the current timestamp as perceived from the tracer */
481 #define LTTNG_RING_BUFFER_COMPAT_GET_CURRENT_TIMESTAMP \
482 LTTNG_RING_BUFFER_GET_CURRENT_TIMESTAMP
483 /* returns the packet sequence number of the current sub-buffer */
484 #define LTTNG_RING_BUFFER_COMPAT_GET_SEQ_NUM \
485 LTTNG_RING_BUFFER_GET_SEQ_NUM
486 /* returns the stream instance id (invariant for the stream) */
487 #define LTTNG_RING_BUFFER_COMPAT_INSTANCE_ID \
488 LTTNG_RING_BUFFER_INSTANCE_ID
489 #endif /* CONFIG_COMPAT */
491 #endif /* _LTTNG_ABI_H */