Commit | Line | Data |
---|---|---|
93128a92 | 1 | /* |
ab5be9fa MJ |
2 | * Copyright (C) 2011 Julien Desfossez <julien.desfossez@polymtl.ca> |
3 | * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com> | |
4 | * Copyright (C) 2011 David Goulet <david.goulet@polymtl.ca> | |
93128a92 | 5 | * |
ab5be9fa | 6 | * SPDX-License-Identifier: GPL-2.0-only |
93128a92 | 7 | * |
93128a92 DG |
8 | */ |
9 | ||
10 | #ifndef _LTTNG_KERNEL_H | |
11 | #define _LTTNG_KERNEL_H | |
12 | ||
e848fc76 | 13 | #include <stdint.h> |
113373e4 | 14 | #include <common/macros.h> |
0ef03255 FD |
15 | #include <lttng/constant.h> |
16 | #include <lttng/event.h> | |
e848fc76 | 17 | |
dbbb3ec5 | 18 | #define LTTNG_KERNEL_SYM_NAME_LEN 256 |
0ef03255 | 19 | #define LTTNG_KERNEL_MAX_UPROBE_NUM 32 |
8ff4109e | 20 | #define LTTNG_KERNEL_SESSION_NAME_LEN 256 |
e04b2181 | 21 | #define LTTNG_KERNEL_SESSION_CREATION_TIME_ISO8601_LEN 26 |
9cb98350 | 22 | |
7d29a247 DG |
23 | /* |
24 | * LTTng DebugFS ABI structures. | |
25 | * | |
26 | * This is the kernel ABI copied from lttng-modules tree. | |
27 | */ | |
28 | ||
9cb98350 | 29 | enum lttng_kernel_instrumentation { |
5f822d0a | 30 | LTTNG_KERNEL_ALL = -1, /* Used within lttng-tools */ |
e6ddca71 DG |
31 | LTTNG_KERNEL_TRACEPOINT = 0, |
32 | LTTNG_KERNEL_KPROBE = 1, | |
33 | LTTNG_KERNEL_FUNCTION = 2, | |
8f0d098b | 34 | LTTNG_KERNEL_KRETPROBE = 3, |
0133c199 | 35 | LTTNG_KERNEL_NOOP = 4, /* not hooked */ |
a54bd42d | 36 | LTTNG_KERNEL_SYSCALL = 5, |
1ab8c2ad | 37 | LTTNG_KERNEL_UPROBE = 6, |
e6ddca71 DG |
38 | }; |
39 | ||
7d29a247 DG |
40 | enum lttng_kernel_context_type { |
41 | LTTNG_KERNEL_CONTEXT_PID = 0, | |
aa3514e9 | 42 | LTTNG_KERNEL_CONTEXT_PERF_CPU_COUNTER = 1, |
9197c5c4 | 43 | LTTNG_KERNEL_CONTEXT_PROCNAME = 2, |
7d29a247 DG |
44 | LTTNG_KERNEL_CONTEXT_PRIO = 3, |
45 | LTTNG_KERNEL_CONTEXT_NICE = 4, | |
46 | LTTNG_KERNEL_CONTEXT_VPID = 5, | |
47 | LTTNG_KERNEL_CONTEXT_TID = 6, | |
48 | LTTNG_KERNEL_CONTEXT_VTID = 7, | |
49 | LTTNG_KERNEL_CONTEXT_PPID = 8, | |
50 | LTTNG_KERNEL_CONTEXT_VPPID = 9, | |
54773d68 | 51 | LTTNG_KERNEL_CONTEXT_HOSTNAME = 10, |
33e801a9 | 52 | LTTNG_KERNEL_CONTEXT_CPU_ID = 11, |
1ae5e83e JD |
53 | LTTNG_KERNEL_CONTEXT_INTERRUPTIBLE = 12, |
54 | LTTNG_KERNEL_CONTEXT_PREEMPTIBLE = 13, | |
55 | LTTNG_KERNEL_CONTEXT_NEED_RESCHEDULE = 14, | |
56 | LTTNG_KERNEL_CONTEXT_MIGRATABLE = 15, | |
373148e9 FG |
57 | LTTNG_KERNEL_CONTEXT_CALLSTACK_KERNEL = 16, |
58 | LTTNG_KERNEL_CONTEXT_CALLSTACK_USER = 17, | |
40e14884 MJ |
59 | LTTNG_KERNEL_CONTEXT_CGROUP_NS = 18, |
60 | LTTNG_KERNEL_CONTEXT_IPC_NS = 19, | |
61 | LTTNG_KERNEL_CONTEXT_MNT_NS = 20, | |
62 | LTTNG_KERNEL_CONTEXT_NET_NS = 21, | |
63 | LTTNG_KERNEL_CONTEXT_PID_NS = 22, | |
64 | LTTNG_KERNEL_CONTEXT_USER_NS = 23, | |
65 | LTTNG_KERNEL_CONTEXT_UTS_NS = 24, | |
499cbfa1 MJ |
66 | LTTNG_KERNEL_CONTEXT_UID = 25, |
67 | LTTNG_KERNEL_CONTEXT_EUID = 26, | |
68 | LTTNG_KERNEL_CONTEXT_SUID = 27, | |
69 | LTTNG_KERNEL_CONTEXT_GID = 28, | |
70 | LTTNG_KERNEL_CONTEXT_EGID = 29, | |
71 | LTTNG_KERNEL_CONTEXT_SGID = 30, | |
72 | LTTNG_KERNEL_CONTEXT_VUID = 31, | |
73 | LTTNG_KERNEL_CONTEXT_VEUID = 32, | |
74 | LTTNG_KERNEL_CONTEXT_VSUID = 33, | |
75 | LTTNG_KERNEL_CONTEXT_VGID = 34, | |
76 | LTTNG_KERNEL_CONTEXT_VEGID = 35, | |
77 | LTTNG_KERNEL_CONTEXT_VSGID = 36, | |
d37ac3cd | 78 | LTTNG_KERNEL_CONTEXT_TIME_NS = 37, |
7d29a247 DG |
79 | }; |
80 | ||
81 | /* Perf counter attributes */ | |
82 | struct lttng_kernel_perf_counter_ctx { | |
83 | uint32_t type; | |
84 | uint64_t config; | |
dbbb3ec5 | 85 | char name[LTTNG_KERNEL_SYM_NAME_LEN]; |
113373e4 | 86 | } LTTNG_PACKED; |
7d29a247 DG |
87 | |
88 | /* Event/Channel context */ | |
dbbb3ec5 DG |
89 | #define LTTNG_KERNEL_CONTEXT_PADDING1 16 |
90 | #define LTTNG_KERNEL_CONTEXT_PADDING2 LTTNG_KERNEL_SYM_NAME_LEN + 32 | |
7d29a247 DG |
91 | struct lttng_kernel_context { |
92 | enum lttng_kernel_context_type ctx; | |
dbbb3ec5 DG |
93 | char padding[LTTNG_KERNEL_CONTEXT_PADDING1]; |
94 | ||
7d29a247 DG |
95 | union { |
96 | struct lttng_kernel_perf_counter_ctx perf_counter; | |
dbbb3ec5 | 97 | char padding[LTTNG_KERNEL_CONTEXT_PADDING2]; |
7d29a247 | 98 | } u; |
113373e4 | 99 | } LTTNG_PACKED; |
9cb98350 | 100 | |
8f0d098b MD |
101 | struct lttng_kernel_kretprobe { |
102 | uint64_t addr; | |
103 | ||
104 | uint64_t offset; | |
dbbb3ec5 | 105 | char symbol_name[LTTNG_KERNEL_SYM_NAME_LEN]; |
113373e4 | 106 | } LTTNG_PACKED; |
8f0d098b | 107 | |
93128a92 | 108 | /* |
7d29a247 | 109 | * Either addr is used, or symbol_name and offset. |
93128a92 | 110 | */ |
7d29a247 DG |
111 | struct lttng_kernel_kprobe { |
112 | uint64_t addr; | |
113 | ||
114 | uint64_t offset; | |
dbbb3ec5 | 115 | char symbol_name[LTTNG_KERNEL_SYM_NAME_LEN]; |
113373e4 | 116 | } LTTNG_PACKED; |
9cb98350 | 117 | |
1ab8c2ad FD |
118 | struct lttng_kernel_uprobe { |
119 | int fd; | |
120 | } LTTNG_PACKED; | |
121 | ||
122 | struct lttng_kernel_event_callsite_uprobe { | |
123 | uint64_t offset; | |
124 | } LTTNG_PACKED; | |
125 | ||
126 | struct lttng_kernel_event_callsite { | |
127 | union { | |
128 | struct lttng_kernel_event_callsite_uprobe uprobe; | |
129 | } u; | |
130 | } LTTNG_PACKED; | |
131 | ||
c863e5a6 FD |
132 | enum lttng_kernel_syscall_entryexit { |
133 | LTTNG_KERNEL_SYSCALL_ENTRYEXIT = 0, | |
134 | LTTNG_KERNEL_SYSCALL_ENTRY = 1, | |
135 | LTTNG_KERNEL_SYSCALL_EXIT = 2, | |
136 | }; | |
137 | ||
138 | enum lttng_kernel_syscall_abi { | |
139 | LTTNG_KERNEL_SYSCALL_ABI_ALL = 0, | |
140 | LTTNG_KERNEL_SYSCALL_ABI_NATIVE = 1, | |
141 | LTTNG_KERNEL_SYSCALL_ABI_COMPAT = 2, | |
142 | }; | |
143 | ||
144 | enum lttng_kernel_syscall_match { | |
145 | LTTNG_KERNEL_SYSCALL_MATCH_NAME = 0, | |
146 | LTTNG_KERNEL_SYSCALL_MATCH_NR = 1, | |
147 | }; | |
148 | ||
149 | struct lttng_kernel_syscall { | |
150 | uint8_t entryexit; /* enum lttng_kernel_syscall_entryexit */ | |
151 | uint8_t abi; /* enum lttng_kernel_syscall_abi */ | |
152 | uint8_t match; /* enum lttng_kernel_syscall_match */ | |
153 | uint8_t padding; | |
154 | uint32_t nr; /* For LTTNG_SYSCALL_MATCH_NR */ | |
155 | } LTTNG_PACKED; | |
156 | ||
f05b5f07 | 157 | /* Function tracer */ |
7d29a247 | 158 | struct lttng_kernel_function { |
dbbb3ec5 | 159 | char symbol_name[LTTNG_KERNEL_SYM_NAME_LEN]; |
113373e4 | 160 | } LTTNG_PACKED; |
93128a92 | 161 | |
8e49ca12 | 162 | #define LTTNG_KERNEL_EVENT_PADDING1 8 |
dbbb3ec5 | 163 | #define LTTNG_KERNEL_EVENT_PADDING2 LTTNG_KERNEL_SYM_NAME_LEN + 32 |
9cb98350 | 164 | struct lttng_kernel_event { |
dbbb3ec5 | 165 | char name[LTTNG_KERNEL_SYM_NAME_LEN]; |
9cb98350 | 166 | enum lttng_kernel_instrumentation instrumentation; |
8e49ca12 | 167 | uint64_t token; |
dbbb3ec5 DG |
168 | char padding[LTTNG_KERNEL_EVENT_PADDING1]; |
169 | ||
9cb98350 JD |
170 | /* Per instrumentation type configuration */ |
171 | union { | |
8f0d098b | 172 | struct lttng_kernel_kretprobe kretprobe; |
7d29a247 DG |
173 | struct lttng_kernel_kprobe kprobe; |
174 | struct lttng_kernel_function ftrace; | |
c863e5a6 FD |
175 | struct lttng_kernel_uprobe uprobe; |
176 | struct lttng_kernel_syscall syscall; | |
dbbb3ec5 | 177 | char padding[LTTNG_KERNEL_EVENT_PADDING2]; |
9cb98350 | 178 | } u; |
113373e4 | 179 | } LTTNG_PACKED; |
93128a92 | 180 | |
90aa04a1 | 181 | #define LTTNG_KERNEL_EVENT_NOTIFIER_PADDING 32 |
cfb1c9bc JR |
182 | struct lttng_kernel_event_notifier { |
183 | struct lttng_kernel_event event; | |
90aa04a1 FD |
184 | uint64_t error_counter_idx; |
185 | ||
cfb1c9bc JR |
186 | char padding[LTTNG_KERNEL_EVENT_NOTIFIER_PADDING]; |
187 | } LTTNG_PACKED; | |
188 | ||
90aa04a1 FD |
189 | #define LTTNG_KERNEL_COUNTER_DIMENSION_MAX 4 |
190 | ||
191 | enum lttng_kernel_counter_arithmetic { | |
192 | LTTNG_KERNEL_COUNTER_ARITHMETIC_MODULAR = 0, | |
193 | }; | |
194 | ||
195 | enum lttng_kernel_counter_bitness { | |
196 | LTTNG_KERNEL_COUNTER_BITNESS_32 = 0, | |
197 | LTTNG_KERNEL_COUNTER_BITNESS_64 = 1, | |
198 | }; | |
199 | ||
200 | struct lttng_kernel_counter_dimension { | |
201 | uint64_t size; | |
202 | uint64_t underflow_index; | |
203 | uint64_t overflow_index; | |
204 | uint8_t has_underflow; | |
205 | uint8_t has_overflow; | |
206 | } LTTNG_PACKED; | |
207 | ||
208 | #define LTTNG_KERNEL_COUNTER_CONF_PADDING1 67 | |
209 | struct lttng_kernel_counter_conf { | |
210 | uint32_t arithmetic; /* enum lttng_kernel_counter_arithmetic */ | |
211 | uint32_t bitness; /* enum lttng_kernel_counter_bitness */ | |
212 | uint32_t number_dimensions; | |
213 | int64_t global_sum_step; | |
214 | struct lttng_kernel_counter_dimension dimensions[LTTNG_KERNEL_COUNTER_DIMENSION_MAX]; | |
215 | uint8_t coalesce_hits; | |
216 | char padding[LTTNG_KERNEL_COUNTER_CONF_PADDING1]; | |
217 | } LTTNG_PACKED; | |
218 | ||
219 | struct lttng_kernel_counter_index { | |
220 | uint32_t number_dimensions; | |
221 | uint64_t dimension_indexes[LTTNG_KERNEL_COUNTER_DIMENSION_MAX]; | |
222 | } LTTNG_PACKED; | |
223 | ||
224 | struct lttng_kernel_counter_value { | |
225 | int64_t value; | |
226 | uint8_t underflow; | |
227 | uint8_t overflow; | |
228 | } LTTNG_PACKED; | |
229 | ||
230 | #define LTTNG_KERNEL_COUNTER_READ_PADDING 32 | |
231 | struct lttng_kernel_counter_read { | |
232 | struct lttng_kernel_counter_index index; | |
233 | int32_t cpu; /* -1 for global counter, >= 0 for specific cpu. */ | |
234 | struct lttng_kernel_counter_value value; /* output */ | |
235 | char padding[LTTNG_KERNEL_COUNTER_READ_PADDING]; | |
236 | } LTTNG_PACKED; | |
237 | ||
238 | #define LTTNG_KERNEL_COUNTER_AGGREGATE_PADDING 32 | |
239 | struct lttng_kernel_counter_aggregate { | |
240 | struct lttng_kernel_counter_index index; | |
241 | struct lttng_kernel_counter_value value; /* output */ | |
242 | char padding[LTTNG_KERNEL_COUNTER_AGGREGATE_PADDING]; | |
243 | } LTTNG_PACKED; | |
244 | ||
245 | #define LTTNG_KERNEL_COUNTER_CLEAR_PADDING 32 | |
246 | struct lttng_kernel_counter_clear { | |
247 | struct lttng_kernel_counter_index index; | |
248 | char padding[LTTNG_KERNEL_COUNTER_CLEAR_PADDING]; | |
249 | } LTTNG_PACKED; | |
250 | ||
bbd6675c | 251 | #define LTTNG_KERNEL_EVENT_NOTIFIER_NOTIFICATION_PADDING 32 |
cfb1c9bc JR |
252 | struct lttng_kernel_event_notifier_notification { |
253 | uint64_t token; | |
bbd6675c | 254 | uint16_t capture_buf_size; |
cfb1c9bc JR |
255 | char padding[LTTNG_KERNEL_EVENT_NOTIFIER_NOTIFICATION_PADDING]; |
256 | } LTTNG_PACKED; | |
257 | ||
bbd6675c JR |
258 | #define LTTNG_KERNEL_CAPTURE_BYTECODE_MAX_LEN 65536 |
259 | struct lttng_kernel_capture_bytecode { | |
260 | uint32_t len; | |
261 | uint32_t reloc_offset; | |
262 | uint64_t seqnum; | |
263 | char data[0]; | |
264 | } LTTNG_PACKED; | |
265 | ||
9cb98350 | 266 | struct lttng_kernel_tracer_version { |
a62a6556 MD |
267 | uint32_t major; |
268 | uint32_t minor; | |
9cb98350 | 269 | uint32_t patchlevel; |
113373e4 | 270 | } LTTNG_PACKED; |
93128a92 | 271 | |
c052142c MD |
272 | struct lttng_kernel_tracer_abi_version { |
273 | uint32_t major; | |
274 | uint32_t minor; | |
275 | } LTTNG_PACKED; | |
276 | ||
e80c3634 | 277 | struct lttng_kernel_syscall_mask { |
46820c8b | 278 | uint32_t len; /* in bits */ |
e80c3634 MD |
279 | char mask[]; |
280 | } LTTNG_PACKED; | |
281 | ||
4dbc372b JD |
282 | /* |
283 | * kernel channel | |
284 | */ | |
285 | #define LTTNG_KERNEL_CHANNEL_PADDING1 LTTNG_SYMBOL_NAME_LEN + 32 | |
286 | struct lttng_kernel_channel { | |
287 | uint64_t subbuf_size; /* bytes */ | |
288 | uint64_t num_subbuf; /* power of 2 */ | |
289 | unsigned int switch_timer_interval; /* usec */ | |
290 | unsigned int read_timer_interval; /* usec */ | |
291 | enum lttng_event_output output; /* splice, mmap */ | |
292 | ||
293 | int overwrite; /* 1: overwrite, 0: discard */ | |
294 | char padding[LTTNG_KERNEL_CHANNEL_PADDING1]; | |
113373e4 | 295 | } LTTNG_PACKED; |
d0254c7c | 296 | |
00a62084 MD |
297 | #define KERNEL_FILTER_BYTECODE_MAX_LEN 65536 |
298 | struct lttng_kernel_filter_bytecode { | |
299 | uint32_t len; | |
300 | uint32_t reloc_offset; | |
301 | uint64_t seqnum; | |
302 | char data[0]; | |
303 | } LTTNG_PACKED; | |
304 | ||
8ff4109e JR |
305 | /* |
306 | * kernel session name | |
307 | */ | |
308 | struct lttng_kernel_session_name { | |
309 | char name[LTTNG_KERNEL_SESSION_NAME_LEN]; | |
310 | } LTTNG_PACKED; | |
311 | ||
e04b2181 JR |
312 | /* |
313 | * kernel session creation datetime | |
314 | */ | |
315 | struct lttng_kernel_session_creation_time { | |
316 | char iso8601[LTTNG_KERNEL_SESSION_CREATION_TIME_ISO8601_LEN]; | |
317 | } LTTNG_PACKED; | |
318 | ||
d01c0e56 MD |
319 | enum lttng_kernel_tracker_type { |
320 | LTTNG_KERNEL_TRACKER_UNKNOWN = -1, | |
321 | ||
322 | LTTNG_KERNEL_TRACKER_PID = 0, | |
323 | LTTNG_KERNEL_TRACKER_VPID = 1, | |
324 | LTTNG_KERNEL_TRACKER_UID = 2, | |
325 | LTTNG_KERNEL_TRACKER_VUID = 3, | |
326 | LTTNG_KERNEL_TRACKER_GID = 4, | |
327 | LTTNG_KERNEL_TRACKER_VGID = 5, | |
328 | }; | |
329 | ||
330 | struct lttng_kernel_tracker_args { | |
331 | enum lttng_kernel_tracker_type type; | |
332 | int32_t id; | |
333 | }; | |
334 | ||
93128a92 | 335 | #endif /* _LTTNG_KERNEL_H */ |