| 1 | /* SPDX-License-Identifier: (GPL-2.0 or LGPL-2.1) |
| 2 | * |
| 3 | * lttng-abi.h |
| 4 | * |
| 5 | * LTTng ABI header |
| 6 | * |
| 7 | * Copyright (C) 2010-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com> |
| 8 | */ |
| 9 | |
| 10 | #ifndef _LTTNG_ABI_H |
| 11 | #define _LTTNG_ABI_H |
| 12 | |
| 13 | #include <linux/fs.h> |
| 14 | |
| 15 | /* |
| 16 | * Major/minor version of ABI exposed to lttng tools. Major number |
| 17 | * should be increased when an incompatible ABI change is done. |
| 18 | */ |
| 19 | #define LTTNG_MODULES_ABI_MAJOR_VERSION 2 |
| 20 | #define LTTNG_MODULES_ABI_MINOR_VERSION 4 |
| 21 | |
| 22 | #define LTTNG_KERNEL_SYM_NAME_LEN 256 |
| 23 | #define LTTNG_KERNEL_SESSION_NAME_LEN 256 |
| 24 | |
| 25 | enum lttng_kernel_instrumentation { |
| 26 | LTTNG_KERNEL_TRACEPOINT = 0, |
| 27 | LTTNG_KERNEL_KPROBE = 1, |
| 28 | LTTNG_KERNEL_FUNCTION = 2, |
| 29 | LTTNG_KERNEL_KRETPROBE = 3, |
| 30 | LTTNG_KERNEL_NOOP = 4, /* not hooked */ |
| 31 | LTTNG_KERNEL_SYSCALL = 5, |
| 32 | LTTNG_KERNEL_UPROBE = 6, |
| 33 | }; |
| 34 | |
| 35 | /* |
| 36 | * LTTng consumer mode |
| 37 | */ |
| 38 | enum lttng_kernel_output { |
| 39 | LTTNG_KERNEL_SPLICE = 0, |
| 40 | LTTNG_KERNEL_MMAP = 1, |
| 41 | }; |
| 42 | |
| 43 | /* |
| 44 | * LTTng DebugFS ABI structures. |
| 45 | */ |
| 46 | #define LTTNG_KERNEL_CHANNEL_PADDING LTTNG_KERNEL_SYM_NAME_LEN + 32 |
| 47 | struct lttng_kernel_channel { |
| 48 | uint64_t subbuf_size; /* in bytes */ |
| 49 | uint64_t num_subbuf; |
| 50 | unsigned int switch_timer_interval; /* usecs */ |
| 51 | unsigned int read_timer_interval; /* usecs */ |
| 52 | enum lttng_kernel_output output; /* splice, mmap */ |
| 53 | int overwrite; /* 1: overwrite, 0: discard */ |
| 54 | char padding[LTTNG_KERNEL_CHANNEL_PADDING]; |
| 55 | } __attribute__((packed)); |
| 56 | |
| 57 | struct lttng_kernel_kretprobe { |
| 58 | uint64_t addr; |
| 59 | |
| 60 | uint64_t offset; |
| 61 | char symbol_name[LTTNG_KERNEL_SYM_NAME_LEN]; |
| 62 | } __attribute__((packed)); |
| 63 | |
| 64 | /* |
| 65 | * Either addr is used, or symbol_name and offset. |
| 66 | */ |
| 67 | struct lttng_kernel_kprobe { |
| 68 | uint64_t addr; |
| 69 | |
| 70 | uint64_t offset; |
| 71 | char symbol_name[LTTNG_KERNEL_SYM_NAME_LEN]; |
| 72 | } __attribute__((packed)); |
| 73 | |
| 74 | struct lttng_kernel_function_tracer { |
| 75 | char symbol_name[LTTNG_KERNEL_SYM_NAME_LEN]; |
| 76 | } __attribute__((packed)); |
| 77 | |
| 78 | struct lttng_kernel_uprobe { |
| 79 | int fd; |
| 80 | } __attribute__((packed)); |
| 81 | |
| 82 | struct lttng_kernel_event_callsite_uprobe { |
| 83 | uint64_t offset; |
| 84 | } __attribute__((packed)); |
| 85 | |
| 86 | struct lttng_kernel_event_callsite { |
| 87 | union { |
| 88 | struct lttng_kernel_event_callsite_uprobe uprobe; |
| 89 | } u; |
| 90 | } __attribute__((packed)); |
| 91 | |
| 92 | /* |
| 93 | * For syscall tracing, name = "*" means "enable all". |
| 94 | */ |
| 95 | #define LTTNG_KERNEL_EVENT_PADDING1 16 |
| 96 | #define LTTNG_KERNEL_EVENT_PADDING2 LTTNG_KERNEL_SYM_NAME_LEN + 32 |
| 97 | struct lttng_kernel_event { |
| 98 | char name[LTTNG_KERNEL_SYM_NAME_LEN]; /* event name */ |
| 99 | enum lttng_kernel_instrumentation instrumentation; |
| 100 | char padding[LTTNG_KERNEL_EVENT_PADDING1]; |
| 101 | |
| 102 | /* Per instrumentation type configuration */ |
| 103 | union { |
| 104 | struct lttng_kernel_kretprobe kretprobe; |
| 105 | struct lttng_kernel_kprobe kprobe; |
| 106 | struct lttng_kernel_function_tracer ftrace; |
| 107 | struct lttng_kernel_uprobe uprobe; |
| 108 | char padding[LTTNG_KERNEL_EVENT_PADDING2]; |
| 109 | } u; |
| 110 | } __attribute__((packed)); |
| 111 | |
| 112 | struct lttng_kernel_tracer_version { |
| 113 | uint32_t major; |
| 114 | uint32_t minor; |
| 115 | uint32_t patchlevel; |
| 116 | } __attribute__((packed)); |
| 117 | |
| 118 | struct lttng_kernel_tracer_abi_version { |
| 119 | uint32_t major; |
| 120 | uint32_t minor; |
| 121 | } __attribute__((packed)); |
| 122 | |
| 123 | struct lttng_kernel_session_name { |
| 124 | char name[LTTNG_KERNEL_SESSION_NAME_LEN]; |
| 125 | } __attribute__((packed)); |
| 126 | |
| 127 | enum lttng_kernel_calibrate_type { |
| 128 | LTTNG_KERNEL_CALIBRATE_KRETPROBE, |
| 129 | }; |
| 130 | |
| 131 | struct lttng_kernel_calibrate { |
| 132 | enum lttng_kernel_calibrate_type type; /* type (input) */ |
| 133 | } __attribute__((packed)); |
| 134 | |
| 135 | struct lttng_kernel_syscall_mask { |
| 136 | uint32_t len; /* in bits */ |
| 137 | char mask[]; |
| 138 | } __attribute__((packed)); |
| 139 | |
| 140 | enum lttng_kernel_context_type { |
| 141 | LTTNG_KERNEL_CONTEXT_PID = 0, |
| 142 | LTTNG_KERNEL_CONTEXT_PERF_COUNTER = 1, |
| 143 | LTTNG_KERNEL_CONTEXT_PROCNAME = 2, |
| 144 | LTTNG_KERNEL_CONTEXT_PRIO = 3, |
| 145 | LTTNG_KERNEL_CONTEXT_NICE = 4, |
| 146 | LTTNG_KERNEL_CONTEXT_VPID = 5, |
| 147 | LTTNG_KERNEL_CONTEXT_TID = 6, |
| 148 | LTTNG_KERNEL_CONTEXT_VTID = 7, |
| 149 | LTTNG_KERNEL_CONTEXT_PPID = 8, |
| 150 | LTTNG_KERNEL_CONTEXT_VPPID = 9, |
| 151 | LTTNG_KERNEL_CONTEXT_HOSTNAME = 10, |
| 152 | LTTNG_KERNEL_CONTEXT_CPU_ID = 11, |
| 153 | LTTNG_KERNEL_CONTEXT_INTERRUPTIBLE = 12, |
| 154 | LTTNG_KERNEL_CONTEXT_PREEMPTIBLE = 13, |
| 155 | LTTNG_KERNEL_CONTEXT_NEED_RESCHEDULE = 14, |
| 156 | LTTNG_KERNEL_CONTEXT_MIGRATABLE = 15, |
| 157 | LTTNG_KERNEL_CONTEXT_CALLSTACK_KERNEL = 16, |
| 158 | LTTNG_KERNEL_CONTEXT_CALLSTACK_USER = 17, |
| 159 | }; |
| 160 | |
| 161 | struct lttng_kernel_perf_counter_ctx { |
| 162 | uint32_t type; |
| 163 | uint64_t config; |
| 164 | char name[LTTNG_KERNEL_SYM_NAME_LEN]; |
| 165 | } __attribute__((packed)); |
| 166 | |
| 167 | #define LTTNG_KERNEL_CONTEXT_PADDING1 16 |
| 168 | #define LTTNG_KERNEL_CONTEXT_PADDING2 LTTNG_KERNEL_SYM_NAME_LEN + 32 |
| 169 | struct lttng_kernel_context { |
| 170 | enum lttng_kernel_context_type ctx; |
| 171 | char padding[LTTNG_KERNEL_CONTEXT_PADDING1]; |
| 172 | |
| 173 | union { |
| 174 | struct lttng_kernel_perf_counter_ctx perf_counter; |
| 175 | char padding[LTTNG_KERNEL_CONTEXT_PADDING2]; |
| 176 | } u; |
| 177 | } __attribute__((packed)); |
| 178 | |
| 179 | #define LTTNG_KERNEL_FILTER_BYTECODE_MAX_LEN 65536 |
| 180 | struct lttng_kernel_filter_bytecode { |
| 181 | uint32_t len; |
| 182 | uint32_t reloc_offset; |
| 183 | uint64_t seqnum; |
| 184 | char data[0]; |
| 185 | } __attribute__((packed)); |
| 186 | |
| 187 | /* LTTng file descriptor ioctl */ |
| 188 | #define LTTNG_KERNEL_SESSION _IO(0xF6, 0x45) |
| 189 | #define LTTNG_KERNEL_TRACER_VERSION \ |
| 190 | _IOR(0xF6, 0x46, struct lttng_kernel_tracer_version) |
| 191 | #define LTTNG_KERNEL_TRACEPOINT_LIST _IO(0xF6, 0x47) |
| 192 | #define LTTNG_KERNEL_WAIT_QUIESCENT _IO(0xF6, 0x48) |
| 193 | #define LTTNG_KERNEL_CALIBRATE \ |
| 194 | _IOWR(0xF6, 0x49, struct lttng_kernel_calibrate) |
| 195 | #define LTTNG_KERNEL_SYSCALL_LIST _IO(0xF6, 0x4A) |
| 196 | #define LTTNG_KERNEL_TRACER_ABI_VERSION \ |
| 197 | _IOR(0xF6, 0x4B, struct lttng_kernel_tracer_abi_version) |
| 198 | |
| 199 | /* Session FD ioctl */ |
| 200 | #define LTTNG_KERNEL_METADATA \ |
| 201 | _IOW(0xF6, 0x54, struct lttng_kernel_channel) |
| 202 | #define LTTNG_KERNEL_CHANNEL \ |
| 203 | _IOW(0xF6, 0x55, struct lttng_kernel_channel) |
| 204 | #define LTTNG_KERNEL_SESSION_START _IO(0xF6, 0x56) |
| 205 | #define LTTNG_KERNEL_SESSION_STOP _IO(0xF6, 0x57) |
| 206 | #define LTTNG_KERNEL_SESSION_TRACK_PID \ |
| 207 | _IOR(0xF6, 0x58, int32_t) |
| 208 | #define LTTNG_KERNEL_SESSION_UNTRACK_PID \ |
| 209 | _IOR(0xF6, 0x59, int32_t) |
| 210 | /* |
| 211 | * ioctl 0x58 and 0x59 are duplicated here. It works, since _IOR vs _IO |
| 212 | * are generating two different ioctl numbers, but this was not done on |
| 213 | * purpose. We should generally try to avoid those duplications. |
| 214 | */ |
| 215 | #define LTTNG_KERNEL_SESSION_LIST_TRACKER_PIDS _IO(0xF6, 0x58) |
| 216 | #define LTTNG_KERNEL_SESSION_METADATA_REGEN _IO(0xF6, 0x59) |
| 217 | |
| 218 | /* 0x5A and 0x5B are reserved for a future ABI-breaking cleanup. */ |
| 219 | #define LTTNG_KERNEL_SESSION_STATEDUMP _IO(0xF6, 0x5C) |
| 220 | #define LTTNG_KERNEL_SESSION_SET_NAME \ |
| 221 | _IOR(0xF6, 0x5D, struct lttng_kernel_session_name) |
| 222 | |
| 223 | /* Channel FD ioctl */ |
| 224 | #define LTTNG_KERNEL_STREAM _IO(0xF6, 0x62) |
| 225 | #define LTTNG_KERNEL_EVENT \ |
| 226 | _IOW(0xF6, 0x63, struct lttng_kernel_event) |
| 227 | #define LTTNG_KERNEL_SYSCALL_MASK \ |
| 228 | _IOWR(0xF6, 0x64, struct lttng_kernel_syscall_mask) |
| 229 | |
| 230 | /* Event and Channel FD ioctl */ |
| 231 | #define LTTNG_KERNEL_CONTEXT \ |
| 232 | _IOW(0xF6, 0x71, struct lttng_kernel_context) |
| 233 | |
| 234 | /* Event, Channel and Session ioctl */ |
| 235 | #define LTTNG_KERNEL_ENABLE _IO(0xF6, 0x82) |
| 236 | #define LTTNG_KERNEL_DISABLE _IO(0xF6, 0x83) |
| 237 | |
| 238 | /* Event FD ioctl */ |
| 239 | #define LTTNG_KERNEL_FILTER _IO(0xF6, 0x90) |
| 240 | #define LTTNG_KERNEL_ADD_CALLSITE _IO(0xF6, 0x91) |
| 241 | |
| 242 | /* |
| 243 | * LTTng-specific ioctls for the lib ringbuffer. |
| 244 | * |
| 245 | * Operations applying to the current sub-buffer need to occur between |
| 246 | * a get/put or get_next/put_next ioctl pair. |
| 247 | */ |
| 248 | |
| 249 | /* returns the timestamp begin of the current sub-buffer */ |
| 250 | #define LTTNG_RING_BUFFER_GET_TIMESTAMP_BEGIN _IOR(0xF6, 0x20, uint64_t) |
| 251 | /* returns the timestamp end of the current sub-buffer */ |
| 252 | #define LTTNG_RING_BUFFER_GET_TIMESTAMP_END _IOR(0xF6, 0x21, uint64_t) |
| 253 | /* returns the number of events discarded of the current sub-buffer */ |
| 254 | #define LTTNG_RING_BUFFER_GET_EVENTS_DISCARDED _IOR(0xF6, 0x22, uint64_t) |
| 255 | /* returns the packet payload size of the current sub-buffer */ |
| 256 | #define LTTNG_RING_BUFFER_GET_CONTENT_SIZE _IOR(0xF6, 0x23, uint64_t) |
| 257 | /* returns the packet size of the current sub-buffer*/ |
| 258 | #define LTTNG_RING_BUFFER_GET_PACKET_SIZE _IOR(0xF6, 0x24, uint64_t) |
| 259 | /* returns the stream id (invariant for the stream) */ |
| 260 | #define LTTNG_RING_BUFFER_GET_STREAM_ID _IOR(0xF6, 0x25, uint64_t) |
| 261 | /* returns the current timestamp as perceived from the tracer */ |
| 262 | #define LTTNG_RING_BUFFER_GET_CURRENT_TIMESTAMP _IOR(0xF6, 0x26, uint64_t) |
| 263 | /* returns the packet sequence number of the current sub-buffer */ |
| 264 | #define LTTNG_RING_BUFFER_GET_SEQ_NUM _IOR(0xF6, 0x27, uint64_t) |
| 265 | /* returns the stream instance id (invariant for the stream) */ |
| 266 | #define LTTNG_RING_BUFFER_INSTANCE_ID _IOR(0xF6, 0x28, uint64_t) |
| 267 | |
| 268 | #ifdef CONFIG_COMPAT |
| 269 | /* returns the timestamp begin of the current sub-buffer */ |
| 270 | #define LTTNG_RING_BUFFER_COMPAT_GET_TIMESTAMP_BEGIN \ |
| 271 | LTTNG_RING_BUFFER_GET_TIMESTAMP_BEGIN |
| 272 | /* returns the timestamp end of the current sub-buffer */ |
| 273 | #define LTTNG_RING_BUFFER_COMPAT_GET_TIMESTAMP_END \ |
| 274 | LTTNG_RING_BUFFER_GET_TIMESTAMP_END |
| 275 | /* returns the number of events discarded of the current sub-buffer */ |
| 276 | #define LTTNG_RING_BUFFER_COMPAT_GET_EVENTS_DISCARDED \ |
| 277 | LTTNG_RING_BUFFER_GET_EVENTS_DISCARDED |
| 278 | /* returns the packet payload size of the current sub-buffer */ |
| 279 | #define LTTNG_RING_BUFFER_COMPAT_GET_CONTENT_SIZE \ |
| 280 | LTTNG_RING_BUFFER_GET_CONTENT_SIZE |
| 281 | /* returns the packet size of the current sub-buffer */ |
| 282 | #define LTTNG_RING_BUFFER_COMPAT_GET_PACKET_SIZE \ |
| 283 | LTTNG_RING_BUFFER_GET_PACKET_SIZE |
| 284 | /* returns the stream id (invariant for the stream) */ |
| 285 | #define LTTNG_RING_BUFFER_COMPAT_GET_STREAM_ID \ |
| 286 | LTTNG_RING_BUFFER_GET_STREAM_ID |
| 287 | /* returns the current timestamp as perceived from the tracer */ |
| 288 | #define LTTNG_RING_BUFFER_COMPAT_GET_CURRENT_TIMESTAMP \ |
| 289 | LTTNG_RING_BUFFER_GET_CURRENT_TIMESTAMP |
| 290 | /* returns the packet sequence number of the current sub-buffer */ |
| 291 | #define LTTNG_RING_BUFFER_COMPAT_GET_SEQ_NUM \ |
| 292 | LTTNG_RING_BUFFER_GET_SEQ_NUM |
| 293 | /* returns the stream instance id (invariant for the stream) */ |
| 294 | #define LTTNG_RING_BUFFER_COMPAT_INSTANCE_ID \ |
| 295 | LTTNG_RING_BUFFER_INSTANCE_ID |
| 296 | #endif /* CONFIG_COMPAT */ |
| 297 | |
| 298 | #endif /* _LTTNG_ABI_H */ |