1 // SPDX-FileCopyrightText: 2010-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
3 // SPDX-License-Identifier: MIT
9 #ifndef _LTTNG_UST_ABI_H
10 #define _LTTNG_UST_ABI_H
13 #include <lttng/ust-compiler.h>
15 #define LTTNG_UST_ABI_SYM_NAME_LEN 256
16 #define LTTNG_UST_ABI_PROCNAME_LEN 16
18 /* UST comm magic number, used to validate protocol and endianness. */
19 #define LTTNG_UST_ABI_COMM_MAGIC 0xC57C57C5
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
26 #define LTTNG_UST_ABI_CMD_MAX_LEN 4096U
28 enum lttng_ust_abi_instrumentation
{
29 LTTNG_UST_ABI_TRACEPOINT
= 0,
30 LTTNG_UST_ABI_PROBE
= 1,
31 LTTNG_UST_ABI_FUNCTION
= 2,
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,
40 enum lttng_ust_abi_output
{
41 LTTNG_UST_ABI_MMAP
= 0,
44 enum lttng_ust_abi_chan_type
{
45 LTTNG_UST_ABI_CHAN_PER_CPU
= 0,
46 LTTNG_UST_ABI_CHAN_METADATA
= 1,
49 struct lttng_ust_abi_tracer_version
{
53 } __attribute__((packed
));
55 #define LTTNG_UST_ABI_CHANNEL_PADDING (LTTNG_UST_ABI_SYM_NAME_LEN + 32)
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.
62 #define LTTNG_UST_ABI_CHANNEL_DATA_MAX_LEN 1048576U
63 struct lttng_ust_abi_channel
{
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
));
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
];
76 * shm_fd and wakeup_fd are send over unix socket as file
77 * descriptors after this structure.
79 } __attribute__((packed
));
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 */
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
];
92 /* Per instrumentation type configuration */
94 char padding
[LTTNG_UST_ABI_EVENT_PADDING2
];
96 } __attribute__((packed
));
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
));
105 #define LTTNG_UST_ABI_EVENT_NOTIFIER_NOTIFICATION_PADDING 32
106 struct lttng_ust_abi_event_notifier_notification
{
108 uint16_t capture_buf_size
;
109 char padding
[LTTNG_UST_ABI_EVENT_NOTIFIER_NOTIFICATION_PADDING
];
110 } __attribute__((packed
));
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. */
118 enum lttng_ust_abi_counter_arithmetic
{
119 LTTNG_UST_ABI_COUNTER_ARITHMETIC_MODULAR
= 0,
120 LTTNG_UST_ABI_COUNTER_ARITHMETIC_SATURATION
= 1,
123 enum lttng_ust_abi_counter_bitness
{
124 LTTNG_UST_ABI_COUNTER_BITNESS_32
= 0,
125 LTTNG_UST_ABI_COUNTER_BITNESS_64
= 1,
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 */
132 * The size of this structure is fixed because it is embedded into
133 * children structures.
135 } __attribute__((packed
));
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) */
142 char str
[]; /* Null-terminated string following this structure. */
143 } __attribute__((packed
));
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.
151 * Dimension indexing: All events should use the same key type to index
152 * a given map dimension.
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. */
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 */
163 * The size of this structure is fixed because it is embedded into
164 * children structures.
166 } __attribute__((packed
));
168 struct lttng_ust_abi_counter_key_dimension_tokens
{
169 struct lttng_ust_abi_counter_key_dimension parent
;
170 uint32_t nr_key_tokens
;
172 /* Followed by an array of nr_key_tokens struct lttng_ust_abi_key_token elements. */
173 } __attribute__((packed
));
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
182 enum lttng_ust_abi_counter_action
{
183 LTTNG_UST_ABI_COUNTER_ACTION_INCREMENT
= 0,
186 * Can be extended with additional actions, such as decrement,
187 * set value, run bytecode, and so on.
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 */
195 struct lttng_ust_abi_event event
;
196 uint32_t number_key_dimensions
; /* array of dimensions is an array of var. len. elements. */
199 * Followed by additional data specific to the action, and by a
200 * variable-length array of key dimensions.
202 } __attribute__((packed
));
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),
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
));
217 enum lttng_ust_abi_counter_conf_flags
{
218 LTTNG_UST_ABI_COUNTER_CONF_FLAG_COALESCE_HITS
= (1 << 0),
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
));
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
));
236 struct lttng_ust_abi_counter_cpu
{
237 uint32_t len
; /* Length of this structure */
238 uint64_t shm_len
; /* shm len */
240 } __attribute__((packed
));
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,
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 */
257 char padding
[LTTNG_UST_ABI_FIELD_ITER_PADDING
];
258 } __attribute__((packed
));
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,
285 struct lttng_ust_abi_perf_counter_ctx
{
288 char name
[LTTNG_UST_ABI_SYM_NAME_LEN
];
289 } __attribute__((packed
));
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
];
298 struct lttng_ust_abi_perf_counter_ctx perf_counter
;
300 /* Includes trailing '\0'. */
301 uint32_t provider_name_len
;
302 uint32_t ctx_name_len
;
304 char padding
[LTTNG_UST_ABI_CONTEXT_PADDING2
];
306 } __attribute__((packed
));
309 * Tracer channel attributes.
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 */
321 int64_t blocking_timeout
; /* Blocking timeout (usec) */
323 char padding
[LTTNG_UST_ABI_CHANNEL_ATTR_PADDING
];
325 } __attribute__((packed
));
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 */
331 char padding
[LTTNG_UST_ABI_TRACEPOINT_ITER_PADDING
];
332 } __attribute__((packed
));
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,
348 #define LTTNG_UST_ABI_OBJECT_DATA_PADDING1 32
349 #define LTTNG_UST_ABI_OBJECT_DATA_PADDING2 (LTTNG_UST_ABI_SYM_NAME_LEN + 32)
351 struct lttng_ust_abi_object_data
{
352 int32_t type
; /* enum lttng_ust_abi_object_type */
355 char padding1
[LTTNG_UST_ABI_OBJECT_DATA_PADDING1
];
359 int32_t type
; /* enum lttng_ust_abi_chan_type */
377 char padding2
[LTTNG_UST_ABI_OBJECT_DATA_PADDING2
];
379 } __attribute__((packed
));
381 enum lttng_ust_abi_calibrate_type
{
382 LTTNG_UST_ABI_CALIBRATE_TRACEPOINT
,
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
];
392 char padding
[LTTNG_UST_ABI_CALIBRATE_PADDING2
];
394 } __attribute__((packed
));
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
{
400 uint32_t reloc_offset
;
402 char padding
[LTTNG_UST_ABI_FILTER_PADDING
];
404 } __attribute__((packed
));
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
{
410 uint32_t reloc_offset
;
412 char padding
[LTTNG_UST_ABI_CAPTURE_PADDING
];
414 } __attribute__((packed
));
416 #define LTTNG_UST_ABI_EXCLUSION_PADDING 32
417 struct lttng_ust_abi_event_exclusion
{
419 char padding
[LTTNG_UST_ABI_EXCLUSION_PADDING
];
420 char names
[LTTNG_UST_ABI_SYM_NAME_LEN
][0];
421 } __attribute__((packed
));
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)
428 /* Handled by object descriptor */
429 #define LTTNG_UST_ABI_RELEASE LTTNG_UST_ABI_CMD(0x1)
431 /* Handled by object cmd */
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)
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)
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)
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)
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)
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)
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)
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)
478 /* Event notifier commands */
479 #define LTTNG_UST_ABI_CAPTURE LTTNG_UST_ABI_CMD(0xB6)
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)
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)
495 #define LTTNG_UST_ABI_ROOT_HANDLE 0
497 #endif /* _LTTNG_UST_ABI_H */