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 5
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_PADDING1 16
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_PADDING1
];
147 } __attribute__((packed
));
149 enum lttng_kernel_counter_arithmetic
{
150 LTTNG_KERNEL_COUNTER_ARITHMETIC_MODULAR
= 1,
153 enum lttng_kernel_counter_bitness
{
154 LTTNG_KERNEL_COUNTER_BITNESS_32
= 1,
155 LTTNG_KERNEL_COUNTER_BITNESS_64
= 2,
158 struct lttng_kernel_counter_dimension
{
160 uint64_t underflow_index
;
161 uint64_t overflow_index
;
162 uint8_t has_underflow
;
163 uint8_t has_overflow
;
164 } __attribute__((packed
));
166 #define LTTNG_KERNEL_COUNTER_DIMENSION_MAX 4
167 struct lttng_kernel_counter_conf
{
168 uint32_t arithmetic
; /* enum lttng_kernel_counter_arithmetic */
169 uint32_t bitness
; /* enum lttng_kernel_counter_bitness */
170 uint32_t number_dimensions
;
171 int64_t global_sum_step
;
172 struct lttng_kernel_counter_dimension dimensions
[LTTNG_KERNEL_COUNTER_DIMENSION_MAX
];
173 } __attribute__((packed
));
175 struct lttng_kernel_counter_index
{
176 uint32_t number_dimensions
;
177 uint64_t dimension_indexes
[LTTNG_KERNEL_COUNTER_DIMENSION_MAX
];
178 } __attribute__((packed
));
180 struct lttng_kernel_counter_value
{
184 } __attribute__((packed
));
186 #define LTTNG_KERNEL_COUNTER_READ_PADDING 32
187 struct lttng_kernel_counter_read
{
188 struct lttng_kernel_counter_index index
;
189 int32_t cpu
; /* -1 for global counter, >= 0 for specific cpu. */
190 struct lttng_kernel_counter_value value
; /* output */
191 char padding
[LTTNG_KERNEL_COUNTER_READ_PADDING
];
192 } __attribute__((packed
));
194 #define LTTNG_KERNEL_COUNTER_AGGREGATE_PADDING 32
195 struct lttng_kernel_counter_aggregate
{
196 struct lttng_kernel_counter_index index
;
197 struct lttng_kernel_counter_value value
; /* output */
198 char padding
[LTTNG_KERNEL_COUNTER_AGGREGATE_PADDING
];
199 } __attribute__((packed
));
201 #define LTTNG_KERNEL_COUNTER_CLEAR_PADDING 32
202 struct lttng_kernel_counter_clear
{
203 struct lttng_kernel_counter_index index
;
204 char padding
[LTTNG_KERNEL_COUNTER_CLEAR_PADDING
];
205 } __attribute__((packed
));
207 #define LTTNG_KERNEL_EVENT_NOTIFIER_NOTIFICATION_PADDING 32
208 struct lttng_kernel_event_notifier_notification
{
210 uint16_t capture_buf_size
;
211 char padding
[LTTNG_KERNEL_EVENT_NOTIFIER_NOTIFICATION_PADDING
];
212 } __attribute__((packed
));
214 struct lttng_kernel_tracer_version
{
218 } __attribute__((packed
));
220 struct lttng_kernel_tracer_abi_version
{
223 } __attribute__((packed
));
225 struct lttng_kernel_session_name
{
226 char name
[LTTNG_KERNEL_SESSION_NAME_LEN
];
227 } __attribute__((packed
));
229 struct lttng_kernel_session_creation_time
{
230 char iso8601
[LTTNG_KERNEL_SESSION_CREATION_TIME_ISO8601_LEN
];
231 } __attribute__((packed
));
233 enum lttng_kernel_calibrate_type
{
234 LTTNG_KERNEL_CALIBRATE_KRETPROBE
,
237 struct lttng_kernel_calibrate
{
238 uint32_t type
; /* enum lttng_kernel_calibrate_type (input) */
239 } __attribute__((packed
));
241 struct lttng_kernel_syscall_mask
{
242 uint32_t len
; /* in bits */
244 } __attribute__((packed
));
246 enum lttng_kernel_context_type
{
247 LTTNG_KERNEL_CONTEXT_PID
= 0,
248 LTTNG_KERNEL_CONTEXT_PERF_COUNTER
= 1,
249 LTTNG_KERNEL_CONTEXT_PROCNAME
= 2,
250 LTTNG_KERNEL_CONTEXT_PRIO
= 3,
251 LTTNG_KERNEL_CONTEXT_NICE
= 4,
252 LTTNG_KERNEL_CONTEXT_VPID
= 5,
253 LTTNG_KERNEL_CONTEXT_TID
= 6,
254 LTTNG_KERNEL_CONTEXT_VTID
= 7,
255 LTTNG_KERNEL_CONTEXT_PPID
= 8,
256 LTTNG_KERNEL_CONTEXT_VPPID
= 9,
257 LTTNG_KERNEL_CONTEXT_HOSTNAME
= 10,
258 LTTNG_KERNEL_CONTEXT_CPU_ID
= 11,
259 LTTNG_KERNEL_CONTEXT_INTERRUPTIBLE
= 12,
260 LTTNG_KERNEL_CONTEXT_PREEMPTIBLE
= 13,
261 LTTNG_KERNEL_CONTEXT_NEED_RESCHEDULE
= 14,
262 LTTNG_KERNEL_CONTEXT_MIGRATABLE
= 15,
263 LTTNG_KERNEL_CONTEXT_CALLSTACK_KERNEL
= 16,
264 LTTNG_KERNEL_CONTEXT_CALLSTACK_USER
= 17,
265 LTTNG_KERNEL_CONTEXT_CGROUP_NS
= 18,
266 LTTNG_KERNEL_CONTEXT_IPC_NS
= 19,
267 LTTNG_KERNEL_CONTEXT_MNT_NS
= 20,
268 LTTNG_KERNEL_CONTEXT_NET_NS
= 21,
269 LTTNG_KERNEL_CONTEXT_PID_NS
= 22,
270 LTTNG_KERNEL_CONTEXT_USER_NS
= 23,
271 LTTNG_KERNEL_CONTEXT_UTS_NS
= 24,
272 LTTNG_KERNEL_CONTEXT_UID
= 25,
273 LTTNG_KERNEL_CONTEXT_EUID
= 26,
274 LTTNG_KERNEL_CONTEXT_SUID
= 27,
275 LTTNG_KERNEL_CONTEXT_GID
= 28,
276 LTTNG_KERNEL_CONTEXT_EGID
= 29,
277 LTTNG_KERNEL_CONTEXT_SGID
= 30,
278 LTTNG_KERNEL_CONTEXT_VUID
= 31,
279 LTTNG_KERNEL_CONTEXT_VEUID
= 32,
280 LTTNG_KERNEL_CONTEXT_VSUID
= 33,
281 LTTNG_KERNEL_CONTEXT_VGID
= 34,
282 LTTNG_KERNEL_CONTEXT_VEGID
= 35,
283 LTTNG_KERNEL_CONTEXT_VSGID
= 36,
284 LTTNG_KERNEL_CONTEXT_TIME_NS
= 37,
287 struct lttng_kernel_perf_counter_ctx
{
290 char name
[LTTNG_KERNEL_SYM_NAME_LEN
];
291 } __attribute__((packed
));
293 #define LTTNG_KERNEL_CONTEXT_PADDING1 16
294 #define LTTNG_KERNEL_CONTEXT_PADDING2 LTTNG_KERNEL_SYM_NAME_LEN + 32
295 struct lttng_kernel_context
{
296 uint32_t ctx
; /*enum lttng_kernel_context_type */
297 char padding
[LTTNG_KERNEL_CONTEXT_PADDING1
];
300 struct lttng_kernel_perf_counter_ctx perf_counter
;
301 char padding
[LTTNG_KERNEL_CONTEXT_PADDING2
];
303 } __attribute__((packed
));
305 #define LTTNG_KERNEL_FILTER_BYTECODE_MAX_LEN 65536
306 struct lttng_kernel_filter_bytecode
{
308 uint32_t reloc_offset
;
311 } __attribute__((packed
));
313 #define LTTNG_KERNEL_CAPTURE_BYTECODE_MAX_LEN 65536
314 struct lttng_kernel_capture_bytecode
{
316 uint32_t reloc_offset
;
319 } __attribute__((packed
));
321 enum lttng_kernel_tracker_type
{
322 LTTNG_KERNEL_TRACKER_UNKNOWN
= -1,
324 LTTNG_KERNEL_TRACKER_PID
= 0,
325 LTTNG_KERNEL_TRACKER_VPID
= 1,
326 LTTNG_KERNEL_TRACKER_UID
= 2,
327 LTTNG_KERNEL_TRACKER_VUID
= 3,
328 LTTNG_KERNEL_TRACKER_GID
= 4,
329 LTTNG_KERNEL_TRACKER_VGID
= 5,
332 struct lttng_kernel_tracker_args
{
333 uint32_t type
; /* enum lttng_kernel_tracker_type */
337 /* LTTng file descriptor ioctl */
338 /* lttng/abi-old.h reserve 0x40, 0x41, 0x42, 0x43, and 0x44. */
339 #define LTTNG_KERNEL_SESSION _IO(0xF6, 0x45)
340 #define LTTNG_KERNEL_TRACER_VERSION \
341 _IOR(0xF6, 0x46, struct lttng_kernel_tracer_version)
342 #define LTTNG_KERNEL_TRACEPOINT_LIST _IO(0xF6, 0x47)
343 #define LTTNG_KERNEL_WAIT_QUIESCENT _IO(0xF6, 0x48)
344 #define LTTNG_KERNEL_CALIBRATE \
345 _IOWR(0xF6, 0x49, struct lttng_kernel_calibrate)
346 #define LTTNG_KERNEL_SYSCALL_LIST _IO(0xF6, 0x4A)
347 #define LTTNG_KERNEL_TRACER_ABI_VERSION \
348 _IOR(0xF6, 0x4B, struct lttng_kernel_tracer_abi_version)
349 #define LTTNG_KERNEL_EVENT_NOTIFIER_GROUP_CREATE _IO(0xF6, 0x4C)
351 /* Session FD ioctl */
352 /* lttng/abi-old.h reserve 0x50, 0x51, 0x52, and 0x53. */
353 #define LTTNG_KERNEL_METADATA \
354 _IOW(0xF6, 0x54, struct lttng_kernel_channel)
355 #define LTTNG_KERNEL_CHANNEL \
356 _IOW(0xF6, 0x55, struct lttng_kernel_channel)
357 #define LTTNG_KERNEL_SESSION_START _IO(0xF6, 0x56)
358 #define LTTNG_KERNEL_SESSION_STOP _IO(0xF6, 0x57)
359 #define LTTNG_KERNEL_SESSION_TRACK_PID \
360 _IOR(0xF6, 0x58, int32_t)
361 #define LTTNG_KERNEL_SESSION_UNTRACK_PID \
362 _IOR(0xF6, 0x59, int32_t)
365 * ioctl 0x58 and 0x59 are duplicated here. It works, since _IOR vs _IO
366 * are generating two different ioctl numbers, but this was not done on
367 * purpose. We should generally try to avoid those duplications.
369 #define LTTNG_KERNEL_SESSION_LIST_TRACKER_PIDS _IO(0xF6, 0x58)
370 #define LTTNG_KERNEL_SESSION_METADATA_REGEN _IO(0xF6, 0x59)
372 /* lttng/abi-old.h reserve 0x5A and 0x5B. */
373 #define LTTNG_KERNEL_SESSION_STATEDUMP _IO(0xF6, 0x5C)
374 #define LTTNG_KERNEL_SESSION_SET_NAME \
375 _IOR(0xF6, 0x5D, struct lttng_kernel_session_name)
376 #define LTTNG_KERNEL_SESSION_SET_CREATION_TIME \
377 _IOR(0xF6, 0x5E, struct lttng_kernel_session_creation_time)
379 /* Channel FD ioctl */
380 /* lttng/abi-old.h reserve 0x60 and 0x61. */
381 #define LTTNG_KERNEL_STREAM _IO(0xF6, 0x62)
382 #define LTTNG_KERNEL_EVENT \
383 _IOW(0xF6, 0x63, struct lttng_kernel_event)
384 #define LTTNG_KERNEL_SYSCALL_MASK \
385 _IOWR(0xF6, 0x64, struct lttng_kernel_syscall_mask)
387 /* Event and Channel FD ioctl */
388 /* lttng/abi-old.h reserve 0x70. */
389 #define LTTNG_KERNEL_CONTEXT \
390 _IOW(0xF6, 0x71, struct lttng_kernel_context)
392 /* Event, Event notifier, Channel, Counter and Session ioctl */
393 /* lttng/abi-old.h reserve 0x80 and 0x81. */
394 #define LTTNG_KERNEL_ENABLE _IO(0xF6, 0x82)
395 #define LTTNG_KERNEL_DISABLE _IO(0xF6, 0x83)
397 /* Trigger group and session ioctl */
398 #define LTTNG_KERNEL_COUNTER \
399 _IOW(0xF6, 0x84, struct lttng_kernel_counter_conf)
401 /* Event and Event notifier FD ioctl */
402 #define LTTNG_KERNEL_FILTER _IO(0xF6, 0x90)
403 #define LTTNG_KERNEL_ADD_CALLSITE _IO(0xF6, 0x91)
405 /* Session FD ioctl (continued) */
406 #define LTTNG_KERNEL_SESSION_LIST_TRACKER_IDS \
407 _IOR(0xF6, 0xA0, struct lttng_kernel_tracker_args)
408 #define LTTNG_KERNEL_SESSION_TRACK_ID \
409 _IOR(0xF6, 0xA1, struct lttng_kernel_tracker_args)
410 #define LTTNG_KERNEL_SESSION_UNTRACK_ID \
411 _IOR(0xF6, 0xA2, struct lttng_kernel_tracker_args)
413 /* Event notifier group file descriptor ioctl */
414 #define LTTNG_KERNEL_EVENT_NOTIFIER_CREATE \
415 _IOW(0xF6, 0xB0, struct lttng_kernel_event_notifier)
416 #define LTTNG_KERNEL_EVENT_NOTIFIER_GROUP_NOTIFICATION_FD \
419 /* Event notifier file descriptor ioctl */
420 #define LTTNG_KERNEL_CAPTURE _IO(0xF6, 0xB8)
422 /* Counter file descriptor ioctl */
423 #define LTTNG_KERNEL_COUNTER_READ \
424 _IOWR(0xF6, 0xC0, struct lttng_kernel_counter_read)
425 #define LTTNG_KERNEL_COUNTER_AGGREGATE \
426 _IOWR(0xF6, 0xC1, struct lttng_kernel_counter_aggregate)
427 #define LTTNG_KERNEL_COUNTER_CLEAR \
428 _IOW(0xF6, 0xC2, struct lttng_kernel_counter_clear)
432 * LTTng-specific ioctls for the lib ringbuffer.
434 * Operations applying to the current sub-buffer need to occur between
435 * a get/put or get_next/put_next ioctl pair.
438 /* returns the timestamp begin of the current sub-buffer */
439 #define LTTNG_RING_BUFFER_GET_TIMESTAMP_BEGIN _IOR(0xF6, 0x20, uint64_t)
440 /* returns the timestamp end of the current sub-buffer */
441 #define LTTNG_RING_BUFFER_GET_TIMESTAMP_END _IOR(0xF6, 0x21, uint64_t)
442 /* returns the number of events discarded of the current sub-buffer */
443 #define LTTNG_RING_BUFFER_GET_EVENTS_DISCARDED _IOR(0xF6, 0x22, uint64_t)
444 /* returns the packet payload size of the current sub-buffer */
445 #define LTTNG_RING_BUFFER_GET_CONTENT_SIZE _IOR(0xF6, 0x23, uint64_t)
446 /* returns the packet size of the current sub-buffer*/
447 #define LTTNG_RING_BUFFER_GET_PACKET_SIZE _IOR(0xF6, 0x24, uint64_t)
448 /* returns the stream id (invariant for the stream) */
449 #define LTTNG_RING_BUFFER_GET_STREAM_ID _IOR(0xF6, 0x25, uint64_t)
450 /* returns the current timestamp as perceived from the tracer */
451 #define LTTNG_RING_BUFFER_GET_CURRENT_TIMESTAMP _IOR(0xF6, 0x26, uint64_t)
452 /* returns the packet sequence number of the current sub-buffer */
453 #define LTTNG_RING_BUFFER_GET_SEQ_NUM _IOR(0xF6, 0x27, uint64_t)
454 /* returns the stream instance id (invariant for the stream) */
455 #define LTTNG_RING_BUFFER_INSTANCE_ID _IOR(0xF6, 0x28, uint64_t)
458 /* returns the timestamp begin of the current sub-buffer */
459 #define LTTNG_RING_BUFFER_COMPAT_GET_TIMESTAMP_BEGIN \
460 LTTNG_RING_BUFFER_GET_TIMESTAMP_BEGIN
461 /* returns the timestamp end of the current sub-buffer */
462 #define LTTNG_RING_BUFFER_COMPAT_GET_TIMESTAMP_END \
463 LTTNG_RING_BUFFER_GET_TIMESTAMP_END
464 /* returns the number of events discarded of the current sub-buffer */
465 #define LTTNG_RING_BUFFER_COMPAT_GET_EVENTS_DISCARDED \
466 LTTNG_RING_BUFFER_GET_EVENTS_DISCARDED
467 /* returns the packet payload size of the current sub-buffer */
468 #define LTTNG_RING_BUFFER_COMPAT_GET_CONTENT_SIZE \
469 LTTNG_RING_BUFFER_GET_CONTENT_SIZE
470 /* returns the packet size of the current sub-buffer */
471 #define LTTNG_RING_BUFFER_COMPAT_GET_PACKET_SIZE \
472 LTTNG_RING_BUFFER_GET_PACKET_SIZE
473 /* returns the stream id (invariant for the stream) */
474 #define LTTNG_RING_BUFFER_COMPAT_GET_STREAM_ID \
475 LTTNG_RING_BUFFER_GET_STREAM_ID
476 /* returns the current timestamp as perceived from the tracer */
477 #define LTTNG_RING_BUFFER_COMPAT_GET_CURRENT_TIMESTAMP \
478 LTTNG_RING_BUFFER_GET_CURRENT_TIMESTAMP
479 /* returns the packet sequence number of the current sub-buffer */
480 #define LTTNG_RING_BUFFER_COMPAT_GET_SEQ_NUM \
481 LTTNG_RING_BUFFER_GET_SEQ_NUM
482 /* returns the stream instance id (invariant for the stream) */
483 #define LTTNG_RING_BUFFER_COMPAT_INSTANCE_ID \
484 LTTNG_RING_BUFFER_INSTANCE_ID
485 #endif /* CONFIG_COMPAT */
487 #endif /* _LTTNG_ABI_H */