fd5f829c0a61e8a708ced081b69368f26425c949
[lttng-ust.git] / include / lttng / ust-abi.h
1 // SPDX-FileCopyrightText: 2010-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
2 //
3 // SPDX-License-Identifier: MIT
4
5 /*
6 * LTTng-UST ABI header
7 */
8
9 #ifndef _LTTNG_UST_ABI_H
10 #define _LTTNG_UST_ABI_H
11
12 #include <stdint.h>
13 #include <lttng/ust-compiler.h>
14
15 #define LTTNG_UST_ABI_SYM_NAME_LEN 256
16 #define LTTNG_UST_ABI_PROCNAME_LEN 16
17
18 /* UST comm magic number, used to validate protocol and endianness. */
19 #define LTTNG_UST_ABI_COMM_MAGIC 0xC57C57C5
20
21 /* Version for ABI between liblttng-ust, sessiond, consumerd */
22 #define LTTNG_UST_ABI_MAJOR_VERSION 10
23 #define LTTNG_UST_ABI_MAJOR_VERSION_OLDEST_COMPATIBLE 8
24 #define LTTNG_UST_ABI_MINOR_VERSION 0
25
26 #define LTTNG_UST_ABI_CMD_MAX_LEN 4096U
27
28 enum lttng_ust_abi_instrumentation {
29 LTTNG_UST_ABI_TRACEPOINT = 0,
30 LTTNG_UST_ABI_PROBE = 1,
31 LTTNG_UST_ABI_FUNCTION = 2,
32 };
33
34 enum lttng_ust_abi_loglevel_type {
35 LTTNG_UST_ABI_LOGLEVEL_ALL = 0,
36 LTTNG_UST_ABI_LOGLEVEL_RANGE = 1,
37 LTTNG_UST_ABI_LOGLEVEL_SINGLE = 2,
38 };
39
40 enum lttng_ust_abi_output {
41 LTTNG_UST_ABI_MMAP = 0,
42 };
43
44 enum lttng_ust_abi_chan_type {
45 LTTNG_UST_ABI_CHAN_PER_CPU = 0,
46 LTTNG_UST_ABI_CHAN_METADATA = 1,
47 };
48
49 struct lttng_ust_abi_tracer_version {
50 uint32_t major;
51 uint32_t minor;
52 uint32_t patchlevel;
53 } __attribute__((packed));
54
55 #define LTTNG_UST_ABI_CHANNEL_PADDING (LTTNG_UST_ABI_SYM_NAME_LEN + 32)
56 /*
57 * Given that the consumerd is limited to 64k file descriptors, we
58 * cannot expect much more than 1MB channel structure size. This size is
59 * depends on the number of streams within a channel, which depends on
60 * the number of possible CPUs on the system.
61 */
62 #define LTTNG_UST_ABI_CHANNEL_DATA_MAX_LEN 1048576U
63 struct lttng_ust_abi_channel {
64 uint64_t len;
65 int32_t type; /* enum lttng_ust_abi_chan_type */
66 char padding[LTTNG_UST_ABI_CHANNEL_PADDING];
67 char data[]; /* variable sized data */
68 } __attribute__((packed));
69
70 #define LTTNG_UST_ABI_STREAM_PADDING1 (LTTNG_UST_ABI_SYM_NAME_LEN + 32)
71 struct lttng_ust_abi_stream {
72 uint64_t len; /* shm len */
73 uint32_t stream_nr; /* stream number */
74 char padding[LTTNG_UST_ABI_STREAM_PADDING1];
75 /*
76 * shm_fd and wakeup_fd are send over unix socket as file
77 * descriptors after this structure.
78 */
79 } __attribute__((packed));
80
81 #define LTTNG_UST_ABI_EVENT_PADDING1 8
82 #define LTTNG_UST_ABI_EVENT_PADDING2 (LTTNG_UST_ABI_SYM_NAME_LEN + 32)
83 struct lttng_ust_abi_event {
84 int32_t instrumentation; /* enum lttng_ust_abi_instrumentation */
85 char name[LTTNG_UST_ABI_SYM_NAME_LEN]; /* event name */
86
87 int32_t loglevel_type; /* enum lttng_ust_abi_loglevel_type */
88 int32_t loglevel; /* value, -1: all */
89 uint64_t token; /* User-provided token */
90 char padding[LTTNG_UST_ABI_EVENT_PADDING1];
91
92 /* Per instrumentation type configuration */
93 union {
94 char padding[LTTNG_UST_ABI_EVENT_PADDING2];
95 } u;
96 } __attribute__((packed));
97
98 #define LTTNG_UST_ABI_EVENT_NOTIFIER_PADDING 32
99 struct lttng_ust_abi_event_notifier {
100 struct lttng_ust_abi_event event;
101 uint64_t error_counter_index;
102 char padding[LTTNG_UST_ABI_EVENT_NOTIFIER_PADDING];
103 } __attribute__((packed));
104
105 #define LTTNG_UST_ABI_EVENT_NOTIFIER_NOTIFICATION_PADDING 32
106 struct lttng_ust_abi_event_notifier_notification {
107 uint64_t token;
108 uint16_t capture_buf_size;
109 char padding[LTTNG_UST_ABI_EVENT_NOTIFIER_NOTIFICATION_PADDING];
110 } __attribute__((packed));
111
112 enum lttng_ust_abi_key_token_type {
113 LTTNG_UST_ABI_KEY_TOKEN_STRING = 0, /* arg: strtab_offset. */
114 LTTNG_UST_ABI_KEY_TOKEN_EVENT_NAME = 1, /* no arg. */
115 LTTNG_UST_ABI_KEY_TOKEN_PROVIDER_NAME = 2, /* no arg. */
116 };
117
118 enum lttng_ust_abi_counter_arithmetic {
119 LTTNG_UST_ABI_COUNTER_ARITHMETIC_MODULAR = 0,
120 LTTNG_UST_ABI_COUNTER_ARITHMETIC_SATURATION = 1,
121 };
122
123 enum lttng_ust_abi_counter_bitness {
124 LTTNG_UST_ABI_COUNTER_BITNESS_32 = 0,
125 LTTNG_UST_ABI_COUNTER_BITNESS_64 = 1,
126 };
127
128 struct lttng_ust_abi_key_token {
129 uint32_t len; /* length of child structure. */
130 uint32_t type; /* enum lttng_ust_abi_key_token_type */
131 /*
132 * The size of this structure is fixed because it is embedded into
133 * children structures.
134 */
135 } __attribute__((packed));
136
137 /* Length of this structure excludes the following string. */
138 struct lttng_ust_abi_key_token_string {
139 struct lttng_ust_abi_key_token parent;
140 uint32_t string_len; /* string length (includes \0) */
141
142 char str[]; /* Null-terminated string following this structure. */
143 } __attribute__((packed));
144
145 /*
146 * token types event_name and provider_name don't have specific fields,
147 * so they do not need to derive their own specific child structure.
148 */
149
150 /*
151 * Dimension indexing: All events should use the same key type to index
152 * a given map dimension.
153 */
154 enum lttng_ust_abi_key_type {
155 LTTNG_UST_ABI_KEY_TYPE_TOKENS = 0, /* Dimension key is a set of tokens. */
156 LTTNG_UST_ABI_KEY_TYPE_INTEGER = 1, /* Dimension key is an integer value. */
157 };
158
159 struct lttng_ust_abi_counter_key_dimension {
160 uint32_t len; /* length of child structure */
161 uint32_t key_type; /* enum lttng_ust_abi_key_type */
162 /*
163 * The size of this structure is fixed because it is embedded into
164 * children structures.
165 */
166 } __attribute__((packed));
167
168 struct lttng_ust_abi_counter_key_dimension_tokens {
169 struct lttng_ust_abi_counter_key_dimension parent;
170 uint32_t nr_key_tokens;
171
172 /* Followed by an array of nr_key_tokens struct lttng_ust_abi_key_token elements. */
173 } __attribute__((packed));
174
175 /*
176 * The "integer" key type is not implemented yet, but when it will be
177 * introduced in the future, its specific key dimension will allow
178 * defining the function to apply over input argument, bytecode to run
179 * and so on.
180 */
181
182 enum lttng_ust_abi_counter_action {
183 LTTNG_UST_ABI_COUNTER_ACTION_INCREMENT = 0,
184
185 /*
186 * Can be extended with additional actions, such as decrement,
187 * set value, run bytecode, and so on.
188 */
189 };
190
191 struct lttng_ust_abi_counter_event {
192 uint32_t len; /* length of this structure */
193 uint32_t action; /* enum lttng_ust_abi_counter_action */
194
195 struct lttng_ust_abi_event event;
196 uint32_t number_key_dimensions; /* array of dimensions is an array of var. len. elements. */
197
198 /*
199 * Followed by additional data specific to the action, and by a
200 * variable-length array of key dimensions.
201 */
202 } __attribute__((packed));
203
204 enum lttng_ust_abi_counter_dimension_flags {
205 LTTNG_UST_ABI_COUNTER_DIMENSION_FLAG_UNDERFLOW = (1 << 0),
206 LTTNG_UST_ABI_COUNTER_DIMENSION_FLAG_OVERFLOW = (1 << 1),
207 };
208
209 struct lttng_ust_abi_counter_dimension {
210 uint32_t key_type; /* enum lttng_ust_abi_key_type */
211 uint32_t flags; /* enum lttng_ust_abi_counter_dimension_flags */
212 uint64_t size; /* dimension size (count of entries) */
213 uint64_t underflow_index;
214 uint64_t overflow_index;
215 } __attribute__((packed));
216
217 enum lttng_ust_abi_counter_conf_flags {
218 LTTNG_UST_ABI_COUNTER_CONF_FLAG_COALESCE_HITS = (1 << 0),
219 };
220
221 struct lttng_ust_abi_counter_conf {
222 uint32_t len; /* Length of fields before var. len. data. */
223 uint32_t flags; /* enum lttng_ust_abi_counter_conf_flags */
224 uint32_t arithmetic; /* enum lttng_ust_abi_counter_arithmetic */
225 uint32_t bitness; /* enum lttng_ust_abi_counter_bitness */
226 int64_t global_sum_step;
227 uint32_t number_dimensions;
228 uint32_t elem_len; /* array stride (size of lttng_ust_abi_counter_dimension) */
229 } __attribute__((packed));
230
231 struct lttng_ust_abi_counter_global {
232 uint32_t len; /* Length of this structure */
233 uint64_t shm_len; /* shm len */
234 } __attribute__((packed));
235
236 struct lttng_ust_abi_counter_cpu {
237 uint32_t len; /* Length of this structure */
238 uint64_t shm_len; /* shm len */
239 uint32_t cpu_nr;
240 } __attribute__((packed));
241
242 enum lttng_ust_abi_field_type {
243 LTTNG_UST_ABI_FIELD_OTHER = 0,
244 LTTNG_UST_ABI_FIELD_INTEGER = 1,
245 LTTNG_UST_ABI_FIELD_ENUM = 2,
246 LTTNG_UST_ABI_FIELD_FLOAT = 3,
247 LTTNG_UST_ABI_FIELD_STRING = 4,
248 };
249
250 #define LTTNG_UST_ABI_FIELD_ITER_PADDING (LTTNG_UST_ABI_SYM_NAME_LEN + 28)
251 struct lttng_ust_abi_field_iter {
252 char event_name[LTTNG_UST_ABI_SYM_NAME_LEN];
253 char field_name[LTTNG_UST_ABI_SYM_NAME_LEN];
254 int32_t type; /* enum lttng_ust_abi_field_type */
255 int loglevel; /* event loglevel */
256 int nowrite;
257 char padding[LTTNG_UST_ABI_FIELD_ITER_PADDING];
258 } __attribute__((packed));
259
260 enum lttng_ust_abi_context_type {
261 LTTNG_UST_ABI_CONTEXT_VTID = 0,
262 LTTNG_UST_ABI_CONTEXT_VPID = 1,
263 LTTNG_UST_ABI_CONTEXT_PTHREAD_ID = 2,
264 LTTNG_UST_ABI_CONTEXT_PROCNAME = 3,
265 LTTNG_UST_ABI_CONTEXT_IP = 4,
266 LTTNG_UST_ABI_CONTEXT_PERF_THREAD_COUNTER = 5,
267 LTTNG_UST_ABI_CONTEXT_CPU_ID = 6,
268 LTTNG_UST_ABI_CONTEXT_APP_CONTEXT = 7,
269 LTTNG_UST_ABI_CONTEXT_CGROUP_NS = 8,
270 LTTNG_UST_ABI_CONTEXT_IPC_NS = 9,
271 LTTNG_UST_ABI_CONTEXT_MNT_NS = 10,
272 LTTNG_UST_ABI_CONTEXT_NET_NS = 11,
273 LTTNG_UST_ABI_CONTEXT_PID_NS = 12,
274 LTTNG_UST_ABI_CONTEXT_USER_NS = 13,
275 LTTNG_UST_ABI_CONTEXT_UTS_NS = 14,
276 LTTNG_UST_ABI_CONTEXT_VUID = 15,
277 LTTNG_UST_ABI_CONTEXT_VEUID = 16,
278 LTTNG_UST_ABI_CONTEXT_VSUID = 17,
279 LTTNG_UST_ABI_CONTEXT_VGID = 18,
280 LTTNG_UST_ABI_CONTEXT_VEGID = 19,
281 LTTNG_UST_ABI_CONTEXT_VSGID = 20,
282 LTTNG_UST_ABI_CONTEXT_TIME_NS = 21,
283 };
284
285 struct lttng_ust_abi_perf_counter_ctx {
286 uint32_t type;
287 uint64_t config;
288 char name[LTTNG_UST_ABI_SYM_NAME_LEN];
289 } __attribute__((packed));
290
291 #define LTTNG_UST_ABI_CONTEXT_PADDING1 16
292 #define LTTNG_UST_ABI_CONTEXT_PADDING2 (LTTNG_UST_ABI_SYM_NAME_LEN + 32)
293 struct lttng_ust_abi_context {
294 int32_t ctx; /* enum lttng_ust_abi_context_type */
295 char padding[LTTNG_UST_ABI_CONTEXT_PADDING1];
296
297 union {
298 struct lttng_ust_abi_perf_counter_ctx perf_counter;
299 struct {
300 /* Includes trailing '\0'. */
301 uint32_t provider_name_len;
302 uint32_t ctx_name_len;
303 } app_ctx;
304 char padding[LTTNG_UST_ABI_CONTEXT_PADDING2];
305 } u;
306 } __attribute__((packed));
307
308 /*
309 * Tracer channel attributes.
310 */
311 #define LTTNG_UST_ABI_CHANNEL_ATTR_PADDING (LTTNG_UST_ABI_SYM_NAME_LEN + 32)
312 struct lttng_ust_abi_channel_attr {
313 uint64_t subbuf_size; /* bytes */
314 uint64_t num_subbuf; /* power of 2 */
315 int overwrite; /* 1: overwrite, 0: discard */
316 unsigned int switch_timer_interval; /* usec */
317 unsigned int read_timer_interval; /* usec */
318 int32_t output; /* enum lttng_ust_abi_output */
319 union {
320 struct {
321 int64_t blocking_timeout; /* Blocking timeout (usec) */
322 } s;
323 char padding[LTTNG_UST_ABI_CHANNEL_ATTR_PADDING];
324 } u;
325 } __attribute__((packed));
326
327 #define LTTNG_UST_ABI_TRACEPOINT_ITER_PADDING 16
328 struct lttng_ust_abi_tracepoint_iter {
329 char name[LTTNG_UST_ABI_SYM_NAME_LEN]; /* provider:name */
330 int loglevel;
331 char padding[LTTNG_UST_ABI_TRACEPOINT_ITER_PADDING];
332 } __attribute__((packed));
333
334 enum lttng_ust_abi_object_type {
335 LTTNG_UST_ABI_OBJECT_TYPE_UNKNOWN = -1,
336 LTTNG_UST_ABI_OBJECT_TYPE_CHANNEL = 0,
337 LTTNG_UST_ABI_OBJECT_TYPE_STREAM = 1,
338 LTTNG_UST_ABI_OBJECT_TYPE_EVENT = 2,
339 LTTNG_UST_ABI_OBJECT_TYPE_CONTEXT = 3,
340 LTTNG_UST_ABI_OBJECT_TYPE_EVENT_NOTIFIER_GROUP = 4,
341 LTTNG_UST_ABI_OBJECT_TYPE_EVENT_NOTIFIER = 5,
342 LTTNG_UST_ABI_OBJECT_TYPE_COUNTER = 6,
343 LTTNG_UST_ABI_OBJECT_TYPE_COUNTER_GLOBAL = 7,
344 LTTNG_UST_ABI_OBJECT_TYPE_COUNTER_CPU = 8,
345 LTTNG_UST_ABI_OBJECT_TYPE_COUNTER_EVENT = 9,
346 };
347
348 #define LTTNG_UST_ABI_OBJECT_DATA_PADDING1 32
349 #define LTTNG_UST_ABI_OBJECT_DATA_PADDING2 (LTTNG_UST_ABI_SYM_NAME_LEN + 32)
350
351 struct lttng_ust_abi_object_data {
352 int32_t type; /* enum lttng_ust_abi_object_type */
353 int handle;
354 uint64_t size;
355 char padding1[LTTNG_UST_ABI_OBJECT_DATA_PADDING1];
356 union {
357 struct {
358 void *data;
359 int32_t type; /* enum lttng_ust_abi_chan_type */
360 int wakeup_fd;
361 } channel;
362 struct {
363 int shm_fd;
364 int wakeup_fd;
365 uint32_t stream_nr;
366 } stream;
367 struct {
368 void *data;
369 } counter;
370 struct {
371 int shm_fd;
372 } counter_global;
373 struct {
374 int shm_fd;
375 uint32_t cpu_nr;
376 } counter_cpu;
377 char padding2[LTTNG_UST_ABI_OBJECT_DATA_PADDING2];
378 } u;
379 } __attribute__((packed));
380
381 enum lttng_ust_abi_calibrate_type {
382 LTTNG_UST_ABI_CALIBRATE_TRACEPOINT,
383 };
384
385 #define LTTNG_UST_ABI_CALIBRATE_PADDING1 16
386 #define LTTNG_UST_ABI_CALIBRATE_PADDING2 (LTTNG_UST_ABI_SYM_NAME_LEN + 32)
387 struct lttng_ust_abi_calibrate {
388 enum lttng_ust_abi_calibrate_type type; /* type (input) */
389 char padding[LTTNG_UST_ABI_CALIBRATE_PADDING1];
390
391 union {
392 char padding[LTTNG_UST_ABI_CALIBRATE_PADDING2];
393 } u;
394 } __attribute__((packed));
395
396 #define LTTNG_UST_ABI_FILTER_BYTECODE_MAX_LEN 65536
397 #define LTTNG_UST_ABI_FILTER_PADDING 32
398 struct lttng_ust_abi_filter_bytecode {
399 uint32_t len;
400 uint32_t reloc_offset;
401 uint64_t seqnum;
402 char padding[LTTNG_UST_ABI_FILTER_PADDING];
403 char data[0];
404 } __attribute__((packed));
405
406 #define LTTNG_UST_ABI_CAPTURE_BYTECODE_MAX_LEN 65536
407 #define LTTNG_UST_ABI_CAPTURE_PADDING 32
408 struct lttng_ust_abi_capture_bytecode {
409 uint32_t len;
410 uint32_t reloc_offset;
411 uint64_t seqnum;
412 char padding[LTTNG_UST_ABI_CAPTURE_PADDING];
413 char data[0];
414 } __attribute__((packed));
415
416 #define LTTNG_UST_ABI_EXCLUSION_PADDING 32
417 struct lttng_ust_abi_event_exclusion {
418 uint32_t count;
419 char padding[LTTNG_UST_ABI_EXCLUSION_PADDING];
420 char names[LTTNG_UST_ABI_SYM_NAME_LEN][0];
421 } __attribute__((packed));
422
423 #define LTTNG_UST_ABI_CMD(minor) (minor)
424 #define LTTNG_UST_ABI_CMDR(minor, type) (minor)
425 #define LTTNG_UST_ABI_CMDW(minor, type) (minor)
426 #define LTTNG_UST_ABI_CMDV(minor, var_len_cmd_type) (minor)
427
428 /* Handled by object descriptor */
429 #define LTTNG_UST_ABI_RELEASE LTTNG_UST_ABI_CMD(0x1)
430
431 /* Handled by object cmd */
432
433 /* LTTng-UST commands */
434 #define LTTNG_UST_ABI_SESSION LTTNG_UST_ABI_CMD(0x40)
435 #define LTTNG_UST_ABI_TRACER_VERSION \
436 LTTNG_UST_ABI_CMDR(0x41, struct lttng_ust_abi_tracer_version)
437 #define LTTNG_UST_ABI_TRACEPOINT_LIST LTTNG_UST_ABI_CMD(0x42)
438 #define LTTNG_UST_ABI_WAIT_QUIESCENT LTTNG_UST_ABI_CMD(0x43)
439 #define LTTNG_UST_ABI_REGISTER_DONE LTTNG_UST_ABI_CMD(0x44)
440 #define LTTNG_UST_ABI_TRACEPOINT_FIELD_LIST LTTNG_UST_ABI_CMD(0x45)
441 #define LTTNG_UST_ABI_EVENT_NOTIFIER_GROUP_CREATE \
442 LTTNG_UST_ABI_CMD(0x46)
443
444 /* Session commands */
445 #define LTTNG_UST_ABI_CHANNEL \
446 LTTNG_UST_ABI_CMDW(0x51, struct lttng_ust_abi_channel)
447 #define LTTNG_UST_ABI_SESSION_START LTTNG_UST_ABI_CMD(0x52)
448 #define LTTNG_UST_ABI_SESSION_STOP LTTNG_UST_ABI_CMD(0x53)
449 #define LTTNG_UST_ABI_SESSION_STATEDUMP LTTNG_UST_ABI_CMD(0x54)
450
451 /* Channel commands */
452 #define LTTNG_UST_ABI_STREAM LTTNG_UST_ABI_CMD(0x60)
453 #define LTTNG_UST_ABI_EVENT \
454 LTTNG_UST_ABI_CMDW(0x61, struct lttng_ust_abi_event)
455
456 /* Event and channel commands */
457 #define LTTNG_UST_ABI_CONTEXT \
458 LTTNG_UST_ABI_CMDW(0x70, struct lttng_ust_abi_context)
459 #define LTTNG_UST_ABI_FLUSH_BUFFER \
460 LTTNG_UST_ABI_CMD(0x71)
461
462 /* Event, event notifier, channel and session commands */
463 #define LTTNG_UST_ABI_ENABLE LTTNG_UST_ABI_CMD(0x80)
464 #define LTTNG_UST_ABI_DISABLE LTTNG_UST_ABI_CMD(0x81)
465
466 /* Tracepoint list commands */
467 #define LTTNG_UST_ABI_TRACEPOINT_LIST_GET LTTNG_UST_ABI_CMD(0x90)
468 #define LTTNG_UST_ABI_TRACEPOINT_FIELD_LIST_GET LTTNG_UST_ABI_CMD(0x91)
469
470 /* Event and event notifier commands */
471 #define LTTNG_UST_ABI_FILTER LTTNG_UST_ABI_CMD(0xA0)
472 #define LTTNG_UST_ABI_EXCLUSION LTTNG_UST_ABI_CMD(0xA1)
473
474 /* Event notifier group commands */
475 #define LTTNG_UST_ABI_EVENT_NOTIFIER_CREATE \
476 LTTNG_UST_ABI_CMDV(0xB0, struct lttng_ust_abi_event_notifier)
477
478 /* Event notifier commands */
479 #define LTTNG_UST_ABI_CAPTURE LTTNG_UST_ABI_CMD(0xB6)
480
481 /* Session and event notifier group commands */
482 /* (0xC0) reserved for old ABI. */
483 #define LTTNG_UST_ABI_COUNTER \
484 LTTNG_UST_ABI_CMDV(0xC1, struct lttng_ust_abi_counter_conf)
485
486 /* Counter commands */
487 /* (0xD0, 0xD1) reserved for old ABI. */
488 #define LTTNG_UST_ABI_COUNTER_GLOBAL \
489 LTTNG_UST_ABI_CMDV(0xD2, struct lttng_ust_abi_counter_global)
490 #define LTTNG_UST_ABI_COUNTER_CPU \
491 LTTNG_UST_ABI_CMDV(0xD3, struct lttng_ust_abi_counter_cpu)
492 #define LTTNG_UST_ABI_COUNTER_EVENT \
493 LTTNG_UST_ABI_CMDV(0xD4, struct lttng_ust_abi_counter_event)
494
495 #define LTTNG_UST_ABI_ROOT_HANDLE 0
496
497 #endif /* _LTTNG_UST_ABI_H */
This page took 0.040501 seconds and 5 git commands to generate.