2 * SPDX-License-Identifier: MIT
4 * Copyright (C) 2010-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
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 9
23 #define LTTNG_UST_ABI_MAJOR_VERSION_OLDEST_COMPATIBLE 8
24 #define LTTNG_UST_ABI_MINOR_VERSION 0
26 enum lttng_ust_abi_instrumentation
{
27 LTTNG_UST_ABI_TRACEPOINT
= 0,
28 LTTNG_UST_ABI_PROBE
= 1,
29 LTTNG_UST_ABI_FUNCTION
= 2,
32 enum lttng_ust_abi_loglevel_type
{
33 LTTNG_UST_ABI_LOGLEVEL_ALL
= 0,
34 LTTNG_UST_ABI_LOGLEVEL_RANGE
= 1,
35 LTTNG_UST_ABI_LOGLEVEL_SINGLE
= 2,
38 enum lttng_ust_abi_output
{
39 LTTNG_UST_ABI_MMAP
= 0,
42 enum lttng_ust_abi_chan_type
{
43 LTTNG_UST_ABI_CHAN_PER_CPU
= 0,
44 LTTNG_UST_ABI_CHAN_METADATA
= 1,
47 struct lttng_ust_abi_tracer_version
{
51 } __attribute__((packed
));
53 #define LTTNG_UST_ABI_CHANNEL_PADDING (LTTNG_UST_ABI_SYM_NAME_LEN + 32)
55 * Given that the consumerd is limited to 64k file descriptors, we
56 * cannot expect much more than 1MB channel structure size. This size is
57 * depends on the number of streams within a channel, which depends on
58 * the number of possible CPUs on the system.
60 #define LTTNG_UST_ABI_CHANNEL_DATA_MAX_LEN 1048576U
61 struct lttng_ust_abi_channel
{
63 int32_t type
; /* enum lttng_ust_abi_chan_type */
64 char padding
[LTTNG_UST_ABI_CHANNEL_PADDING
];
65 char data
[]; /* variable sized data */
66 } __attribute__((packed
));
68 #define LTTNG_UST_ABI_STREAM_PADDING1 (LTTNG_UST_ABI_SYM_NAME_LEN + 32)
69 struct lttng_ust_abi_stream
{
70 uint64_t len
; /* shm len */
71 uint32_t stream_nr
; /* stream number */
72 char padding
[LTTNG_UST_ABI_STREAM_PADDING1
];
74 * shm_fd and wakeup_fd are send over unix socket as file
75 * descriptors after this structure.
77 } __attribute__((packed
));
79 #define LTTNG_UST_ABI_COUNTER_DIMENSION_MAX 4
81 enum lttng_ust_abi_counter_arithmetic
{
82 LTTNG_UST_ABI_COUNTER_ARITHMETIC_MODULAR
= 0,
83 LTTNG_UST_ABI_COUNTER_ARITHMETIC_SATURATION
= 1,
86 enum lttng_ust_abi_counter_bitness
{
87 LTTNG_UST_ABI_COUNTER_BITNESS_32
= 0,
88 LTTNG_UST_ABI_COUNTER_BITNESS_64
= 1,
91 struct lttng_ust_abi_counter_dimension
{
93 uint64_t underflow_index
;
94 uint64_t overflow_index
;
95 uint8_t has_underflow
;
97 } __attribute__((packed
));
99 #define LTTNG_UST_ABI_COUNTER_CONF_PADDING1 67
100 struct lttng_ust_abi_counter_conf
{
101 uint32_t arithmetic
; /* enum lttng_ust_abi_counter_arithmetic */
102 uint32_t bitness
; /* enum lttng_ust_abi_counter_bitness */
103 uint32_t number_dimensions
;
104 int64_t global_sum_step
;
105 struct lttng_ust_abi_counter_dimension dimensions
[LTTNG_UST_ABI_COUNTER_DIMENSION_MAX
];
106 uint8_t coalesce_hits
;
107 char padding
[LTTNG_UST_ABI_COUNTER_CONF_PADDING1
];
108 } __attribute__((packed
));
110 struct lttng_ust_abi_counter_value
{
111 uint32_t number_dimensions
;
112 uint64_t dimension_indexes
[LTTNG_UST_ABI_COUNTER_DIMENSION_MAX
];
114 } __attribute__((packed
));
116 #define LTTNG_UST_ABI_EVENT_PADDING1 8
117 #define LTTNG_UST_ABI_EVENT_PADDING2 (LTTNG_UST_ABI_SYM_NAME_LEN + 32)
118 struct lttng_ust_abi_event
{
119 int32_t instrumentation
; /* enum lttng_ust_abi_instrumentation */
120 char name
[LTTNG_UST_ABI_SYM_NAME_LEN
]; /* event name */
122 int32_t loglevel_type
; /* enum lttng_ust_abi_loglevel_type */
123 int32_t loglevel
; /* value, -1: all */
124 uint64_t token
; /* User-provided token */
125 char padding
[LTTNG_UST_ABI_EVENT_PADDING1
];
127 /* Per instrumentation type configuration */
129 char padding
[LTTNG_UST_ABI_EVENT_PADDING2
];
131 } __attribute__((packed
));
133 #define LTTNG_UST_ABI_EVENT_NOTIFIER_PADDING 32
134 struct lttng_ust_abi_event_notifier
{
135 struct lttng_ust_abi_event event
;
136 uint64_t error_counter_index
;
137 char padding
[LTTNG_UST_ABI_EVENT_NOTIFIER_PADDING
];
138 } __attribute__((packed
));
140 #define LTTNG_UST_ABI_EVENT_NOTIFIER_NOTIFICATION_PADDING 32
141 struct lttng_ust_abi_event_notifier_notification
{
143 uint16_t capture_buf_size
;
144 char padding
[LTTNG_UST_ABI_EVENT_NOTIFIER_NOTIFICATION_PADDING
];
145 } __attribute__((packed
));
147 #define LTTNG_UST_ABI_COUNTER_PADDING1 (LTTNG_UST_ABI_SYM_NAME_LEN + 32)
148 #define LTTNG_UST_ABI_COUNTER_DATA_MAX_LEN 4096U
149 struct lttng_ust_abi_counter
{
151 char padding
[LTTNG_UST_ABI_COUNTER_PADDING1
];
152 char data
[]; /* variable sized data */
153 } __attribute__((packed
));
155 #define LTTNG_UST_ABI_COUNTER_GLOBAL_PADDING1 (LTTNG_UST_ABI_SYM_NAME_LEN + 32)
156 struct lttng_ust_abi_counter_global
{
157 uint64_t len
; /* shm len */
158 char padding
[LTTNG_UST_ABI_COUNTER_GLOBAL_PADDING1
];
159 } __attribute__((packed
));
161 #define LTTNG_UST_ABI_COUNTER_CPU_PADDING1 (LTTNG_UST_ABI_SYM_NAME_LEN + 32)
162 struct lttng_ust_abi_counter_cpu
{
163 uint64_t len
; /* shm len */
165 char padding
[LTTNG_UST_ABI_COUNTER_CPU_PADDING1
];
166 } __attribute__((packed
));
168 enum lttng_ust_abi_field_type
{
169 LTTNG_UST_ABI_FIELD_OTHER
= 0,
170 LTTNG_UST_ABI_FIELD_INTEGER
= 1,
171 LTTNG_UST_ABI_FIELD_ENUM
= 2,
172 LTTNG_UST_ABI_FIELD_FLOAT
= 3,
173 LTTNG_UST_ABI_FIELD_STRING
= 4,
176 #define LTTNG_UST_ABI_FIELD_ITER_PADDING (LTTNG_UST_ABI_SYM_NAME_LEN + 28)
177 struct lttng_ust_abi_field_iter
{
178 char event_name
[LTTNG_UST_ABI_SYM_NAME_LEN
];
179 char field_name
[LTTNG_UST_ABI_SYM_NAME_LEN
];
180 int32_t type
; /* enum lttng_ust_abi_field_type */
181 int loglevel
; /* event loglevel */
183 char padding
[LTTNG_UST_ABI_FIELD_ITER_PADDING
];
184 } __attribute__((packed
));
186 enum lttng_ust_abi_context_type
{
187 LTTNG_UST_ABI_CONTEXT_VTID
= 0,
188 LTTNG_UST_ABI_CONTEXT_VPID
= 1,
189 LTTNG_UST_ABI_CONTEXT_PTHREAD_ID
= 2,
190 LTTNG_UST_ABI_CONTEXT_PROCNAME
= 3,
191 LTTNG_UST_ABI_CONTEXT_IP
= 4,
192 LTTNG_UST_ABI_CONTEXT_PERF_THREAD_COUNTER
= 5,
193 LTTNG_UST_ABI_CONTEXT_CPU_ID
= 6,
194 LTTNG_UST_ABI_CONTEXT_APP_CONTEXT
= 7,
195 LTTNG_UST_ABI_CONTEXT_CGROUP_NS
= 8,
196 LTTNG_UST_ABI_CONTEXT_IPC_NS
= 9,
197 LTTNG_UST_ABI_CONTEXT_MNT_NS
= 10,
198 LTTNG_UST_ABI_CONTEXT_NET_NS
= 11,
199 LTTNG_UST_ABI_CONTEXT_PID_NS
= 12,
200 LTTNG_UST_ABI_CONTEXT_USER_NS
= 13,
201 LTTNG_UST_ABI_CONTEXT_UTS_NS
= 14,
202 LTTNG_UST_ABI_CONTEXT_VUID
= 15,
203 LTTNG_UST_ABI_CONTEXT_VEUID
= 16,
204 LTTNG_UST_ABI_CONTEXT_VSUID
= 17,
205 LTTNG_UST_ABI_CONTEXT_VGID
= 18,
206 LTTNG_UST_ABI_CONTEXT_VEGID
= 19,
207 LTTNG_UST_ABI_CONTEXT_VSGID
= 20,
208 LTTNG_UST_ABI_CONTEXT_TIME_NS
= 21,
211 struct lttng_ust_abi_perf_counter_ctx
{
214 char name
[LTTNG_UST_ABI_SYM_NAME_LEN
];
215 } __attribute__((packed
));
217 #define LTTNG_UST_ABI_CONTEXT_PADDING1 16
218 #define LTTNG_UST_ABI_CONTEXT_PADDING2 (LTTNG_UST_ABI_SYM_NAME_LEN + 32)
219 struct lttng_ust_abi_context
{
220 int32_t ctx
; /* enum lttng_ust_abi_context_type */
221 char padding
[LTTNG_UST_ABI_CONTEXT_PADDING1
];
224 struct lttng_ust_abi_perf_counter_ctx perf_counter
;
226 /* Includes trailing '\0'. */
227 uint32_t provider_name_len
;
228 uint32_t ctx_name_len
;
230 char padding
[LTTNG_UST_ABI_CONTEXT_PADDING2
];
232 } __attribute__((packed
));
235 * Tracer channel attributes.
237 #define LTTNG_UST_ABI_CHANNEL_ATTR_PADDING (LTTNG_UST_ABI_SYM_NAME_LEN + 32)
238 struct lttng_ust_abi_channel_attr
{
239 uint64_t subbuf_size
; /* bytes */
240 uint64_t num_subbuf
; /* power of 2 */
241 int overwrite
; /* 1: overwrite, 0: discard */
242 unsigned int switch_timer_interval
; /* usec */
243 unsigned int read_timer_interval
; /* usec */
244 int32_t output
; /* enum lttng_ust_abi_output */
247 int64_t blocking_timeout
; /* Blocking timeout (usec) */
249 char padding
[LTTNG_UST_ABI_CHANNEL_ATTR_PADDING
];
251 } __attribute__((packed
));
253 #define LTTNG_UST_ABI_TRACEPOINT_ITER_PADDING 16
254 struct lttng_ust_abi_tracepoint_iter
{
255 char name
[LTTNG_UST_ABI_SYM_NAME_LEN
]; /* provider:name */
257 char padding
[LTTNG_UST_ABI_TRACEPOINT_ITER_PADDING
];
258 } __attribute__((packed
));
260 enum lttng_ust_abi_object_type
{
261 LTTNG_UST_ABI_OBJECT_TYPE_UNKNOWN
= -1,
262 LTTNG_UST_ABI_OBJECT_TYPE_CHANNEL
= 0,
263 LTTNG_UST_ABI_OBJECT_TYPE_STREAM
= 1,
264 LTTNG_UST_ABI_OBJECT_TYPE_EVENT
= 2,
265 LTTNG_UST_ABI_OBJECT_TYPE_CONTEXT
= 3,
266 LTTNG_UST_ABI_OBJECT_TYPE_EVENT_NOTIFIER_GROUP
= 4,
267 LTTNG_UST_ABI_OBJECT_TYPE_EVENT_NOTIFIER
= 5,
268 LTTNG_UST_ABI_OBJECT_TYPE_COUNTER
= 6,
269 LTTNG_UST_ABI_OBJECT_TYPE_COUNTER_GLOBAL
= 7,
270 LTTNG_UST_ABI_OBJECT_TYPE_COUNTER_CPU
= 8,
273 #define LTTNG_UST_ABI_OBJECT_DATA_PADDING1 32
274 #define LTTNG_UST_ABI_OBJECT_DATA_PADDING2 (LTTNG_UST_ABI_SYM_NAME_LEN + 32)
276 struct lttng_ust_abi_object_data
{
277 int32_t type
; /* enum lttng_ust_abi_object_type */
280 char padding1
[LTTNG_UST_ABI_OBJECT_DATA_PADDING1
];
284 int32_t type
; /* enum lttng_ust_abi_chan_type */
302 char padding2
[LTTNG_UST_ABI_OBJECT_DATA_PADDING2
];
304 } __attribute__((packed
));
306 enum lttng_ust_abi_calibrate_type
{
307 LTTNG_UST_ABI_CALIBRATE_TRACEPOINT
,
310 #define LTTNG_UST_ABI_CALIBRATE_PADDING1 16
311 #define LTTNG_UST_ABI_CALIBRATE_PADDING2 (LTTNG_UST_ABI_SYM_NAME_LEN + 32)
312 struct lttng_ust_abi_calibrate
{
313 enum lttng_ust_abi_calibrate_type type
; /* type (input) */
314 char padding
[LTTNG_UST_ABI_CALIBRATE_PADDING1
];
317 char padding
[LTTNG_UST_ABI_CALIBRATE_PADDING2
];
319 } __attribute__((packed
));
321 #define LTTNG_UST_ABI_FILTER_BYTECODE_MAX_LEN 65536
322 #define LTTNG_UST_ABI_FILTER_PADDING 32
323 struct lttng_ust_abi_filter_bytecode
{
325 uint32_t reloc_offset
;
327 char padding
[LTTNG_UST_ABI_FILTER_PADDING
];
329 } __attribute__((packed
));
331 #define LTTNG_UST_ABI_CAPTURE_BYTECODE_MAX_LEN 65536
332 #define LTTNG_UST_ABI_CAPTURE_PADDING 32
333 struct lttng_ust_abi_capture_bytecode
{
335 uint32_t reloc_offset
;
337 char padding
[LTTNG_UST_ABI_CAPTURE_PADDING
];
339 } __attribute__((packed
));
341 #define LTTNG_UST_ABI_EXCLUSION_PADDING 32
342 struct lttng_ust_abi_event_exclusion
{
344 char padding
[LTTNG_UST_ABI_EXCLUSION_PADDING
];
345 char names
[LTTNG_UST_ABI_SYM_NAME_LEN
][0];
346 } __attribute__((packed
));
348 #define LTTNG_UST_ABI_CMD(minor) (minor)
349 #define LTTNG_UST_ABI_CMDR(minor, type) (minor)
350 #define LTTNG_UST_ABI_CMDW(minor, type) (minor)
352 /* Handled by object descriptor */
353 #define LTTNG_UST_ABI_RELEASE LTTNG_UST_ABI_CMD(0x1)
355 /* Handled by object cmd */
357 /* LTTng-UST commands */
358 #define LTTNG_UST_ABI_SESSION LTTNG_UST_ABI_CMD(0x40)
359 #define LTTNG_UST_ABI_TRACER_VERSION \
360 LTTNG_UST_ABI_CMDR(0x41, struct lttng_ust_abi_tracer_version)
361 #define LTTNG_UST_ABI_TRACEPOINT_LIST LTTNG_UST_ABI_CMD(0x42)
362 #define LTTNG_UST_ABI_WAIT_QUIESCENT LTTNG_UST_ABI_CMD(0x43)
363 #define LTTNG_UST_ABI_REGISTER_DONE LTTNG_UST_ABI_CMD(0x44)
364 #define LTTNG_UST_ABI_TRACEPOINT_FIELD_LIST LTTNG_UST_ABI_CMD(0x45)
365 #define LTTNG_UST_ABI_EVENT_NOTIFIER_GROUP_CREATE \
366 LTTNG_UST_ABI_CMD(0x46)
368 /* Session commands */
369 #define LTTNG_UST_ABI_CHANNEL \
370 LTTNG_UST_ABI_CMDW(0x51, struct lttng_ust_abi_channel)
371 #define LTTNG_UST_ABI_SESSION_START LTTNG_UST_ABI_CMD(0x52)
372 #define LTTNG_UST_ABI_SESSION_STOP LTTNG_UST_ABI_CMD(0x53)
373 #define LTTNG_UST_ABI_SESSION_STATEDUMP LTTNG_UST_ABI_CMD(0x54)
375 /* Channel commands */
376 #define LTTNG_UST_ABI_STREAM LTTNG_UST_ABI_CMD(0x60)
377 #define LTTNG_UST_ABI_EVENT \
378 LTTNG_UST_ABI_CMDW(0x61, struct lttng_ust_abi_event)
380 /* Event and channel commands */
381 #define LTTNG_UST_ABI_CONTEXT \
382 LTTNG_UST_ABI_CMDW(0x70, struct lttng_ust_abi_context)
383 #define LTTNG_UST_ABI_FLUSH_BUFFER \
384 LTTNG_UST_ABI_CMD(0x71)
386 /* Event, event notifier, channel and session commands */
387 #define LTTNG_UST_ABI_ENABLE LTTNG_UST_ABI_CMD(0x80)
388 #define LTTNG_UST_ABI_DISABLE LTTNG_UST_ABI_CMD(0x81)
390 /* Tracepoint list commands */
391 #define LTTNG_UST_ABI_TRACEPOINT_LIST_GET LTTNG_UST_ABI_CMD(0x90)
392 #define LTTNG_UST_ABI_TRACEPOINT_FIELD_LIST_GET LTTNG_UST_ABI_CMD(0x91)
394 /* Event and event notifier commands */
395 #define LTTNG_UST_ABI_FILTER LTTNG_UST_ABI_CMD(0xA0)
396 #define LTTNG_UST_ABI_EXCLUSION LTTNG_UST_ABI_CMD(0xA1)
398 /* Event notifier group commands */
399 #define LTTNG_UST_ABI_EVENT_NOTIFIER_CREATE \
400 LTTNG_UST_ABI_CMDW(0xB0, struct lttng_ust_abi_event_notifier)
402 /* Event notifier commands */
403 #define LTTNG_UST_ABI_CAPTURE LTTNG_UST_ABI_CMD(0xB6)
405 /* Session and event notifier group commands */
406 #define LTTNG_UST_ABI_COUNTER \
407 LTTNG_UST_ABI_CMDW(0xC0, struct lttng_ust_abi_counter)
409 /* Counter commands */
410 #define LTTNG_UST_ABI_COUNTER_GLOBAL \
411 LTTNG_UST_ABI_CMDW(0xD0, struct lttng_ust_abi_counter_global)
412 #define LTTNG_UST_ABI_COUNTER_CPU \
413 LTTNG_UST_ABI_CMDW(0xD1, struct lttng_ust_abi_counter_cpu)
415 #define LTTNG_UST_ABI_ROOT_HANDLE 0
417 #endif /* _LTTNG_UST_ABI_H */