Build fix: missing initializer for member 'payload'
[lttng-tools.git] / src / common / lttng-kernel.hpp
1 /*
2 * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
3 * Copyright (C) 2011 EfficiOS Inc.
4 *
5 * SPDX-License-Identifier: GPL-2.0-only
6 *
7 */
8
9 #ifndef _LTTNG_KERNEL_H
10 #define _LTTNG_KERNEL_H
11
12 #include <stdint.h>
13 #include <common/macros.hpp>
14 #include <lttng/constant.h>
15 #include <lttng/event.h>
16
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
21
22 /*
23 * LTTng DebugFS ABI structures.
24 *
25 * This is the kernel ABI copied from lttng-modules tree.
26 */
27
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,
37 };
38
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,
78 };
79
80 /* Perf counter attributes */
81 struct lttng_kernel_abi_perf_counter_ctx {
82 uint32_t type;
83 uint64_t config;
84 char name[LTTNG_KERNEL_ABI_SYM_NAME_LEN];
85 } LTTNG_PACKED;
86
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];
93
94 union {
95 struct lttng_kernel_abi_perf_counter_ctx perf_counter;
96 char padding[LTTNG_KERNEL_ABI_CONTEXT_PADDING2];
97 } u;
98 } LTTNG_PACKED;
99
100 struct lttng_kernel_abi_kretprobe {
101 uint64_t addr;
102
103 uint64_t offset;
104 char symbol_name[LTTNG_KERNEL_ABI_SYM_NAME_LEN];
105 } LTTNG_PACKED;
106
107 /*
108 * Either addr is used, or symbol_name and offset.
109 */
110 struct lttng_kernel_abi_kprobe {
111 uint64_t addr;
112
113 uint64_t offset;
114 char symbol_name[LTTNG_KERNEL_ABI_SYM_NAME_LEN];
115 } LTTNG_PACKED;
116
117 struct lttng_kernel_abi_uprobe {
118 int fd;
119 } LTTNG_PACKED;
120
121 struct lttng_kernel_abi_event_callsite_uprobe {
122 uint64_t offset;
123 } LTTNG_PACKED;
124
125 struct lttng_kernel_abi_event_callsite {
126 union {
127 struct lttng_kernel_abi_event_callsite_uprobe uprobe;
128 } u;
129 } LTTNG_PACKED;
130
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,
135 };
136
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,
141 };
142
143 enum lttng_kernel_abi_syscall_match {
144 LTTNG_KERNEL_ABI_SYSCALL_MATCH_NAME = 0,
145 LTTNG_KERNEL_ABI_SYSCALL_MATCH_NR = 1,
146 };
147
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 */
152 uint8_t padding;
153 uint32_t nr; /* For LTTNG_SYSCALL_MATCH_NR */
154 } LTTNG_PACKED;
155
156 /* Function tracer */
157 struct lttng_kernel_abi_function {
158 char symbol_name[LTTNG_KERNEL_ABI_SYM_NAME_LEN];
159 } LTTNG_PACKED;
160
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;
166 uint64_t token;
167 char padding[LTTNG_KERNEL_ABI_EVENT_PADDING1];
168
169 /* Per instrumentation type configuration */
170 union {
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];
177 } u;
178 } LTTNG_PACKED;
179
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;
184
185 char padding[LTTNG_KERNEL_ABI_EVENT_NOTIFIER_PADDING];
186 } LTTNG_PACKED;
187
188 #define LTTNG_KERNEL_ABI_COUNTER_DIMENSION_MAX 4
189
190 enum lttng_kernel_abi_counter_arithmetic {
191 LTTNG_KERNEL_ABI_COUNTER_ARITHMETIC_MODULAR = 0,
192 };
193
194 enum lttng_kernel_abi_counter_bitness {
195 LTTNG_KERNEL_ABI_COUNTER_BITNESS_32 = 0,
196 LTTNG_KERNEL_ABI_COUNTER_BITNESS_64 = 1,
197 };
198
199 struct lttng_kernel_abi_counter_dimension {
200 uint64_t size;
201 uint64_t underflow_index;
202 uint64_t overflow_index;
203 uint8_t has_underflow;
204 uint8_t has_overflow;
205 } LTTNG_PACKED;
206
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];
216 } LTTNG_PACKED;
217
218 struct lttng_kernel_abi_counter_index {
219 uint32_t number_dimensions;
220 uint64_t dimension_indexes[LTTNG_KERNEL_ABI_COUNTER_DIMENSION_MAX];
221 } LTTNG_PACKED;
222
223 struct lttng_kernel_abi_counter_value {
224 int64_t value;
225 uint8_t underflow;
226 uint8_t overflow;
227 } LTTNG_PACKED;
228
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];
235 } LTTNG_PACKED;
236
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];
242 } LTTNG_PACKED;
243
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];
248 } LTTNG_PACKED;
249
250 #define LTTNG_KERNEL_ABI_EVENT_NOTIFIER_NOTIFICATION_PADDING 32
251 struct lttng_kernel_abi_event_notifier_notification {
252 uint64_t token;
253 uint16_t capture_buf_size;
254 char padding[LTTNG_KERNEL_ABI_EVENT_NOTIFIER_NOTIFICATION_PADDING];
255 } LTTNG_PACKED;
256
257 #define LTTNG_KERNEL_ABI_CAPTURE_BYTECODE_MAX_LEN 65536
258 struct lttng_kernel_abi_capture_bytecode {
259 uint32_t len;
260 uint32_t reloc_offset;
261 uint64_t seqnum;
262 char data[0];
263 } LTTNG_PACKED;
264
265 struct lttng_kernel_abi_tracer_version {
266 uint32_t major;
267 uint32_t minor;
268 uint32_t patchlevel;
269 } LTTNG_PACKED;
270
271 struct lttng_kernel_abi_tracer_abi_version {
272 uint32_t major;
273 uint32_t minor;
274 } LTTNG_PACKED;
275
276 struct lttng_kernel_abi_syscall_mask {
277 uint32_t len; /* in bits */
278 char mask[];
279 } LTTNG_PACKED;
280
281 /*
282 * kernel channel
283 */
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 */
291
292 int overwrite; /* 1: overwrite, 0: discard */
293 char padding[LTTNG_KERNEL_ABI_CHANNEL_PADDING1];
294 } LTTNG_PACKED;
295
296 #define KERNEL_FILTER_BYTECODE_MAX_LEN 65536
297 struct lttng_kernel_abi_filter_bytecode {
298 uint32_t len;
299 uint32_t reloc_offset;
300 uint64_t seqnum;
301 char data[0];
302 } LTTNG_PACKED;
303
304 /*
305 * kernel session name
306 */
307 struct lttng_kernel_abi_session_name {
308 char name[LTTNG_KERNEL_ABI_SESSION_NAME_LEN];
309 } LTTNG_PACKED;
310
311 /*
312 * kernel session creation datetime
313 */
314 struct lttng_kernel_abi_session_creation_time {
315 char iso8601[LTTNG_KERNEL_ABI_SESSION_CREATION_TIME_ISO8601_LEN];
316 } LTTNG_PACKED;
317
318 enum lttng_kernel_abi_tracker_type {
319 LTTNG_KERNEL_ABI_TRACKER_UNKNOWN = -1,
320
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,
327 };
328
329 struct lttng_kernel_abi_tracker_args {
330 enum lttng_kernel_abi_tracker_type type;
331 int32_t id;
332 };
333
334 #endif /* _LTTNG_KERNEL_H */
This page took 0.038722 seconds and 4 git commands to generate.