2 * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
3 * Copyright (C) 2011 EfficiOS Inc.
5 * SPDX-License-Identifier: GPL-2.0-only
9 #ifndef _LTTNG_KERNEL_H
10 #define _LTTNG_KERNEL_H
13 #include <common/macros.hpp>
14 #include <lttng/constant.h>
15 #include <lttng/event.h>
17 #define LTTNG_KERNEL_ABI_SYM_NAME_LEN 256
18 #define LTTNG_KERNEL_ABI_MAX_UPROBE_NUM 32
19 #define LTTNG_KERNEL_ABI_SESSION_NAME_LEN 256
20 #define LTTNG_KERNEL_ABI_SESSION_CREATION_TIME_ISO8601_LEN 26
23 * LTTng DebugFS ABI structures.
25 * This is the kernel ABI copied from lttng-modules tree.
28 enum lttng_kernel_abi_instrumentation {
29 LTTNG_KERNEL_ABI_ALL = -1, /* Used within lttng-tools */
30 LTTNG_KERNEL_ABI_TRACEPOINT = 0,
31 LTTNG_KERNEL_ABI_KPROBE = 1,
32 LTTNG_KERNEL_ABI_FUNCTION = 2,
33 LTTNG_KERNEL_ABI_KRETPROBE = 3,
34 LTTNG_KERNEL_ABI_NOOP = 4, /* not hooked */
35 LTTNG_KERNEL_ABI_SYSCALL = 5,
36 LTTNG_KERNEL_ABI_UPROBE = 6,
39 enum lttng_kernel_abi_context_type {
40 LTTNG_KERNEL_ABI_CONTEXT_PID = 0,
41 LTTNG_KERNEL_ABI_CONTEXT_PERF_CPU_COUNTER = 1,
42 LTTNG_KERNEL_ABI_CONTEXT_PROCNAME = 2,
43 LTTNG_KERNEL_ABI_CONTEXT_PRIO = 3,
44 LTTNG_KERNEL_ABI_CONTEXT_NICE = 4,
45 LTTNG_KERNEL_ABI_CONTEXT_VPID = 5,
46 LTTNG_KERNEL_ABI_CONTEXT_TID = 6,
47 LTTNG_KERNEL_ABI_CONTEXT_VTID = 7,
48 LTTNG_KERNEL_ABI_CONTEXT_PPID = 8,
49 LTTNG_KERNEL_ABI_CONTEXT_VPPID = 9,
50 LTTNG_KERNEL_ABI_CONTEXT_HOSTNAME = 10,
51 LTTNG_KERNEL_ABI_CONTEXT_CPU_ID = 11,
52 LTTNG_KERNEL_ABI_CONTEXT_INTERRUPTIBLE = 12,
53 LTTNG_KERNEL_ABI_CONTEXT_PREEMPTIBLE = 13,
54 LTTNG_KERNEL_ABI_CONTEXT_NEED_RESCHEDULE = 14,
55 LTTNG_KERNEL_ABI_CONTEXT_MIGRATABLE = 15,
56 LTTNG_KERNEL_ABI_CONTEXT_CALLSTACK_KERNEL = 16,
57 LTTNG_KERNEL_ABI_CONTEXT_CALLSTACK_USER = 17,
58 LTTNG_KERNEL_ABI_CONTEXT_CGROUP_NS = 18,
59 LTTNG_KERNEL_ABI_CONTEXT_IPC_NS = 19,
60 LTTNG_KERNEL_ABI_CONTEXT_MNT_NS = 20,
61 LTTNG_KERNEL_ABI_CONTEXT_NET_NS = 21,
62 LTTNG_KERNEL_ABI_CONTEXT_PID_NS = 22,
63 LTTNG_KERNEL_ABI_CONTEXT_USER_NS = 23,
64 LTTNG_KERNEL_ABI_CONTEXT_UTS_NS = 24,
65 LTTNG_KERNEL_ABI_CONTEXT_UID = 25,
66 LTTNG_KERNEL_ABI_CONTEXT_EUID = 26,
67 LTTNG_KERNEL_ABI_CONTEXT_SUID = 27,
68 LTTNG_KERNEL_ABI_CONTEXT_GID = 28,
69 LTTNG_KERNEL_ABI_CONTEXT_EGID = 29,
70 LTTNG_KERNEL_ABI_CONTEXT_SGID = 30,
71 LTTNG_KERNEL_ABI_CONTEXT_VUID = 31,
72 LTTNG_KERNEL_ABI_CONTEXT_VEUID = 32,
73 LTTNG_KERNEL_ABI_CONTEXT_VSUID = 33,
74 LTTNG_KERNEL_ABI_CONTEXT_VGID = 34,
75 LTTNG_KERNEL_ABI_CONTEXT_VEGID = 35,
76 LTTNG_KERNEL_ABI_CONTEXT_VSGID = 36,
77 LTTNG_KERNEL_ABI_CONTEXT_TIME_NS = 37,
80 /* Perf counter attributes */
81 struct lttng_kernel_abi_perf_counter_ctx {
84 char name[LTTNG_KERNEL_ABI_SYM_NAME_LEN];
87 /* Event/Channel context */
88 #define LTTNG_KERNEL_ABI_CONTEXT_PADDING1 16
89 #define LTTNG_KERNEL_ABI_CONTEXT_PADDING2 LTTNG_KERNEL_ABI_SYM_NAME_LEN + 32
90 struct lttng_kernel_abi_context {
91 enum lttng_kernel_abi_context_type ctx;
92 char padding[LTTNG_KERNEL_ABI_CONTEXT_PADDING1];
95 struct lttng_kernel_abi_perf_counter_ctx perf_counter;
96 char padding[LTTNG_KERNEL_ABI_CONTEXT_PADDING2];
100 struct lttng_kernel_abi_kretprobe {
104 char symbol_name[LTTNG_KERNEL_ABI_SYM_NAME_LEN];
108 * Either addr is used, or symbol_name and offset.
110 struct lttng_kernel_abi_kprobe {
114 char symbol_name[LTTNG_KERNEL_ABI_SYM_NAME_LEN];
117 struct lttng_kernel_abi_uprobe {
121 struct lttng_kernel_abi_event_callsite_uprobe {
125 struct lttng_kernel_abi_event_callsite {
127 struct lttng_kernel_abi_event_callsite_uprobe uprobe;
131 enum lttng_kernel_abi_syscall_entryexit {
132 LTTNG_KERNEL_ABI_SYSCALL_ENTRYEXIT = 0,
133 LTTNG_KERNEL_ABI_SYSCALL_ENTRY = 1,
134 LTTNG_KERNEL_ABI_SYSCALL_EXIT = 2,
137 enum lttng_kernel_abi_syscall_abi {
138 LTTNG_KERNEL_ABI_SYSCALL_ABI_ALL = 0,
139 LTTNG_KERNEL_ABI_SYSCALL_ABI_NATIVE = 1,
140 LTTNG_KERNEL_ABI_SYSCALL_ABI_COMPAT = 2,
143 enum lttng_kernel_abi_syscall_match {
144 LTTNG_KERNEL_ABI_SYSCALL_MATCH_NAME = 0,
145 LTTNG_KERNEL_ABI_SYSCALL_MATCH_NR = 1,
148 struct lttng_kernel_abi_syscall {
149 uint8_t entryexit; /* enum lttng_kernel_abi_syscall_entryexit */
150 uint8_t abi; /* enum lttng_kernel_abi_syscall_abi */
151 uint8_t match; /* enum lttng_kernel_abi_syscall_match */
153 uint32_t nr; /* For LTTNG_SYSCALL_MATCH_NR */
156 /* Function tracer */
157 struct lttng_kernel_abi_function {
158 char symbol_name[LTTNG_KERNEL_ABI_SYM_NAME_LEN];
161 #define LTTNG_KERNEL_ABI_EVENT_PADDING1 8
162 #define LTTNG_KERNEL_ABI_EVENT_PADDING2 LTTNG_KERNEL_ABI_SYM_NAME_LEN + 32
163 struct lttng_kernel_abi_event {
164 char name[LTTNG_KERNEL_ABI_SYM_NAME_LEN];
165 enum lttng_kernel_abi_instrumentation instrumentation;
167 char padding[LTTNG_KERNEL_ABI_EVENT_PADDING1];
169 /* Per instrumentation type configuration */
171 struct lttng_kernel_abi_kretprobe kretprobe;
172 struct lttng_kernel_abi_kprobe kprobe;
173 struct lttng_kernel_abi_function ftrace;
174 struct lttng_kernel_abi_uprobe uprobe;
175 struct lttng_kernel_abi_syscall syscall;
176 char padding[LTTNG_KERNEL_ABI_EVENT_PADDING2];
180 #define LTTNG_KERNEL_ABI_EVENT_NOTIFIER_PADDING 32
181 struct lttng_kernel_abi_event_notifier {
182 struct lttng_kernel_abi_event event;
183 uint64_t error_counter_idx;
185 char padding[LTTNG_KERNEL_ABI_EVENT_NOTIFIER_PADDING];
188 #define LTTNG_KERNEL_ABI_COUNTER_DIMENSION_MAX 4
190 enum lttng_kernel_abi_counter_arithmetic {
191 LTTNG_KERNEL_ABI_COUNTER_ARITHMETIC_MODULAR = 0,
194 enum lttng_kernel_abi_counter_bitness {
195 LTTNG_KERNEL_ABI_COUNTER_BITNESS_32 = 0,
196 LTTNG_KERNEL_ABI_COUNTER_BITNESS_64 = 1,
199 struct lttng_kernel_abi_counter_dimension {
201 uint64_t underflow_index;
202 uint64_t overflow_index;
203 uint8_t has_underflow;
204 uint8_t has_overflow;
207 #define LTTNG_KERNEL_ABI_COUNTER_CONF_PADDING1 67
208 struct lttng_kernel_abi_counter_conf {
209 uint32_t arithmetic; /* enum lttng_kernel_abi_counter_arithmetic */
210 uint32_t bitness; /* enum lttng_kernel_abi_counter_bitness */
211 uint32_t number_dimensions;
212 int64_t global_sum_step;
213 struct lttng_kernel_abi_counter_dimension dimensions[LTTNG_KERNEL_ABI_COUNTER_DIMENSION_MAX];
214 uint8_t coalesce_hits;
215 char padding[LTTNG_KERNEL_ABI_COUNTER_CONF_PADDING1];
218 struct lttng_kernel_abi_counter_index {
219 uint32_t number_dimensions;
220 uint64_t dimension_indexes[LTTNG_KERNEL_ABI_COUNTER_DIMENSION_MAX];
223 struct lttng_kernel_abi_counter_value {
229 #define LTTNG_KERNEL_ABI_COUNTER_READ_PADDING 32
230 struct lttng_kernel_abi_counter_read {
231 struct lttng_kernel_abi_counter_index index;
232 int32_t cpu; /* -1 for global counter, >= 0 for specific cpu. */
233 struct lttng_kernel_abi_counter_value value; /* output */
234 char padding[LTTNG_KERNEL_ABI_COUNTER_READ_PADDING];
237 #define LTTNG_KERNEL_ABI_COUNTER_AGGREGATE_PADDING 32
238 struct lttng_kernel_abi_counter_aggregate {
239 struct lttng_kernel_abi_counter_index index;
240 struct lttng_kernel_abi_counter_value value; /* output */
241 char padding[LTTNG_KERNEL_ABI_COUNTER_AGGREGATE_PADDING];
244 #define LTTNG_KERNEL_ABI_COUNTER_CLEAR_PADDING 32
245 struct lttng_kernel_abi_counter_clear {
246 struct lttng_kernel_abi_counter_index index;
247 char padding[LTTNG_KERNEL_ABI_COUNTER_CLEAR_PADDING];
250 #define LTTNG_KERNEL_ABI_EVENT_NOTIFIER_NOTIFICATION_PADDING 32
251 struct lttng_kernel_abi_event_notifier_notification {
253 uint16_t capture_buf_size;
254 char padding[LTTNG_KERNEL_ABI_EVENT_NOTIFIER_NOTIFICATION_PADDING];
257 #define LTTNG_KERNEL_ABI_CAPTURE_BYTECODE_MAX_LEN 65536
258 struct lttng_kernel_abi_capture_bytecode {
260 uint32_t reloc_offset;
265 struct lttng_kernel_abi_tracer_version {
271 struct lttng_kernel_abi_tracer_abi_version {
276 struct lttng_kernel_abi_syscall_mask {
277 uint32_t len; /* in bits */
284 #define LTTNG_KERNEL_ABI_CHANNEL_PADDING1 LTTNG_SYMBOL_NAME_LEN + 32
285 struct lttng_kernel_abi_channel {
286 uint64_t subbuf_size; /* bytes */
287 uint64_t num_subbuf; /* power of 2 */
288 unsigned int switch_timer_interval; /* usec */
289 unsigned int read_timer_interval; /* usec */
290 enum lttng_event_output output; /* splice, mmap */
292 int overwrite; /* 1: overwrite, 0: discard */
293 char padding[LTTNG_KERNEL_ABI_CHANNEL_PADDING1];
296 #define KERNEL_FILTER_BYTECODE_MAX_LEN 65536
297 struct lttng_kernel_abi_filter_bytecode {
299 uint32_t reloc_offset;
305 * kernel session name
307 struct lttng_kernel_abi_session_name {
308 char name[LTTNG_KERNEL_ABI_SESSION_NAME_LEN];
312 * kernel session creation datetime
314 struct lttng_kernel_abi_session_creation_time {
315 char iso8601[LTTNG_KERNEL_ABI_SESSION_CREATION_TIME_ISO8601_LEN];
318 enum lttng_kernel_abi_tracker_type {
319 LTTNG_KERNEL_ABI_TRACKER_UNKNOWN = -1,
321 LTTNG_KERNEL_ABI_TRACKER_PID = 0,
322 LTTNG_KERNEL_ABI_TRACKER_VPID = 1,
323 LTTNG_KERNEL_ABI_TRACKER_UID = 2,
324 LTTNG_KERNEL_ABI_TRACKER_VUID = 3,
325 LTTNG_KERNEL_ABI_TRACKER_GID = 4,
326 LTTNG_KERNEL_ABI_TRACKER_VGID = 5,
329 struct lttng_kernel_abi_tracker_args {
330 enum lttng_kernel_abi_tracker_type type;
334 #endif /* _LTTNG_KERNEL_H */