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 #ifndef __ust_stringify
16 #define __ust_stringify1(x) #x
17 #define __ust_stringify(x) __ust_stringify1(x)
18 #endif /* __ust_stringify */
20 #define LTTNG_UST_ABI_SYM_NAME_LEN 256
21 #define LTTNG_UST_ABI_PROCNAME_LEN 16
23 /* UST comm magic number, used to validate protocol and endianness. */
24 #define LTTNG_UST_ABI_COMM_MAGIC 0xC57C57C5
26 /* Version for ABI between liblttng-ust, sessiond, consumerd */
27 #define LTTNG_UST_ABI_MAJOR_VERSION 9
28 #define LTTNG_UST_ABI_MAJOR_VERSION_OLDEST_COMPATIBLE 8
29 #define LTTNG_UST_ABI_MINOR_VERSION 0
31 enum lttng_ust_abi_instrumentation
{
32 LTTNG_UST_ABI_TRACEPOINT
= 0,
33 LTTNG_UST_ABI_PROBE
= 1,
34 LTTNG_UST_ABI_FUNCTION
= 2,
37 enum lttng_ust_abi_loglevel_type
{
38 LTTNG_UST_ABI_LOGLEVEL_ALL
= 0,
39 LTTNG_UST_ABI_LOGLEVEL_RANGE
= 1,
40 LTTNG_UST_ABI_LOGLEVEL_SINGLE
= 2,
43 enum lttng_ust_abi_output
{
44 LTTNG_UST_ABI_MMAP
= 0,
47 enum lttng_ust_abi_chan_type
{
48 LTTNG_UST_ABI_CHAN_PER_CPU
= 0,
49 LTTNG_UST_ABI_CHAN_METADATA
= 1,
52 struct lttng_ust_abi_tracer_version
{
56 } __attribute__((packed
));
58 #define LTTNG_UST_ABI_CHANNEL_PADDING (LTTNG_UST_ABI_SYM_NAME_LEN + 32)
60 * Given that the consumerd is limited to 64k file descriptors, we
61 * cannot expect much more than 1MB channel structure size. This size is
62 * depends on the number of streams within a channel, which depends on
63 * the number of possible CPUs on the system.
65 #define LTTNG_UST_ABI_CHANNEL_DATA_MAX_LEN 1048576U
66 struct lttng_ust_abi_channel
{
68 int32_t type
; /* enum lttng_ust_abi_chan_type */
69 char padding
[LTTNG_UST_ABI_CHANNEL_PADDING
];
70 char data
[]; /* variable sized data */
71 } __attribute__((packed
));
73 #define LTTNG_UST_ABI_STREAM_PADDING1 (LTTNG_UST_ABI_SYM_NAME_LEN + 32)
74 struct lttng_ust_abi_stream
{
75 uint64_t len
; /* shm len */
76 uint32_t stream_nr
; /* stream number */
77 char padding
[LTTNG_UST_ABI_STREAM_PADDING1
];
79 * shm_fd and wakeup_fd are send over unix socket as file
80 * descriptors after this structure.
82 } __attribute__((packed
));
84 #define LTTNG_UST_ABI_COUNTER_DIMENSION_MAX 4
86 enum lttng_ust_abi_counter_arithmetic
{
87 LTTNG_UST_ABI_COUNTER_ARITHMETIC_MODULAR
= 0,
88 LTTNG_UST_ABI_COUNTER_ARITHMETIC_SATURATION
= 1,
91 enum lttng_ust_abi_counter_bitness
{
92 LTTNG_UST_ABI_COUNTER_BITNESS_32
= 0,
93 LTTNG_UST_ABI_COUNTER_BITNESS_64
= 1,
96 struct lttng_ust_abi_counter_dimension
{
98 uint64_t underflow_index
;
99 uint64_t overflow_index
;
100 uint8_t has_underflow
;
101 uint8_t has_overflow
;
102 } __attribute__((packed
));
104 #define LTTNG_UST_ABI_COUNTER_CONF_PADDING1 67
105 struct lttng_ust_abi_counter_conf
{
106 uint32_t arithmetic
; /* enum lttng_ust_counter_arithmetic */
107 uint32_t bitness
; /* enum lttng_ust_counter_bitness */
108 uint32_t number_dimensions
;
109 int64_t global_sum_step
;
110 struct lttng_ust_abi_counter_dimension dimensions
[LTTNG_UST_ABI_COUNTER_DIMENSION_MAX
];
111 uint8_t coalesce_hits
;
112 char padding
[LTTNG_UST_ABI_COUNTER_CONF_PADDING1
];
113 } __attribute__((packed
));
115 struct lttng_ust_abi_counter_value
{
116 uint32_t number_dimensions
;
117 uint64_t dimension_indexes
[LTTNG_UST_ABI_COUNTER_DIMENSION_MAX
];
119 } __attribute__((packed
));
121 #define LTTNG_UST_ABI_EVENT_PADDING1 8
122 #define LTTNG_UST_ABI_EVENT_PADDING2 (LTTNG_UST_ABI_SYM_NAME_LEN + 32)
123 struct lttng_ust_abi_event
{
124 int32_t instrumentation
; /* enum lttng_ust_abi_instrumentation */
125 char name
[LTTNG_UST_ABI_SYM_NAME_LEN
]; /* event name */
127 int32_t loglevel_type
; /* enum lttng_ust_abi_loglevel_type */
128 int32_t loglevel
; /* value, -1: all */
129 uint64_t token
; /* User-provided token */
130 char padding
[LTTNG_UST_ABI_EVENT_PADDING1
];
132 /* Per instrumentation type configuration */
134 char padding
[LTTNG_UST_ABI_EVENT_PADDING2
];
136 } __attribute__((packed
));
138 #define LTTNG_UST_ABI_EVENT_NOTIFIER_PADDING 32
139 struct lttng_ust_abi_event_notifier
{
140 struct lttng_ust_abi_event event
;
141 uint64_t error_counter_index
;
142 char padding
[LTTNG_UST_ABI_EVENT_NOTIFIER_PADDING
];
143 } __attribute__((packed
));
145 #define LTTNG_UST_ABI_EVENT_NOTIFIER_NOTIFICATION_PADDING 32
146 struct lttng_ust_abi_event_notifier_notification
{
148 uint16_t capture_buf_size
;
149 char padding
[LTTNG_UST_ABI_EVENT_NOTIFIER_NOTIFICATION_PADDING
];
150 } __attribute__((packed
));
152 #define LTTNG_UST_ABI_COUNTER_PADDING1 (LTTNG_UST_ABI_SYM_NAME_LEN + 32)
153 #define LTTNG_UST_ABI_COUNTER_DATA_MAX_LEN 4096U
154 struct lttng_ust_abi_counter
{
156 char padding
[LTTNG_UST_ABI_COUNTER_PADDING1
];
157 char data
[]; /* variable sized data */
158 } __attribute__((packed
));
160 #define LTTNG_UST_ABI_COUNTER_GLOBAL_PADDING1 (LTTNG_UST_ABI_SYM_NAME_LEN + 32)
161 struct lttng_ust_abi_counter_global
{
162 uint64_t len
; /* shm len */
163 char padding
[LTTNG_UST_ABI_COUNTER_GLOBAL_PADDING1
];
164 } __attribute__((packed
));
166 #define LTTNG_UST_ABI_COUNTER_CPU_PADDING1 (LTTNG_UST_ABI_SYM_NAME_LEN + 32)
167 struct lttng_ust_abi_counter_cpu
{
168 uint64_t len
; /* shm len */
170 char padding
[LTTNG_UST_ABI_COUNTER_CPU_PADDING1
];
171 } __attribute__((packed
));
173 enum lttng_ust_abi_field_type
{
174 LTTNG_UST_ABI_FIELD_OTHER
= 0,
175 LTTNG_UST_ABI_FIELD_INTEGER
= 1,
176 LTTNG_UST_ABI_FIELD_ENUM
= 2,
177 LTTNG_UST_ABI_FIELD_FLOAT
= 3,
178 LTTNG_UST_ABI_FIELD_STRING
= 4,
181 #define LTTNG_UST_ABI_FIELD_ITER_PADDING (LTTNG_UST_ABI_SYM_NAME_LEN + 28)
182 struct lttng_ust_abi_field_iter
{
183 char event_name
[LTTNG_UST_ABI_SYM_NAME_LEN
];
184 char field_name
[LTTNG_UST_ABI_SYM_NAME_LEN
];
185 int32_t type
; /* enum lttng_ust_abi_field_type */
186 int loglevel
; /* event loglevel */
188 char padding
[LTTNG_UST_ABI_FIELD_ITER_PADDING
];
189 } __attribute__((packed
));
191 enum lttng_ust_abi_context_type
{
192 LTTNG_UST_ABI_CONTEXT_VTID
= 0,
193 LTTNG_UST_ABI_CONTEXT_VPID
= 1,
194 LTTNG_UST_ABI_CONTEXT_PTHREAD_ID
= 2,
195 LTTNG_UST_ABI_CONTEXT_PROCNAME
= 3,
196 LTTNG_UST_ABI_CONTEXT_IP
= 4,
197 LTTNG_UST_ABI_CONTEXT_PERF_THREAD_COUNTER
= 5,
198 LTTNG_UST_ABI_CONTEXT_CPU_ID
= 6,
199 LTTNG_UST_ABI_CONTEXT_APP_CONTEXT
= 7,
200 LTTNG_UST_ABI_CONTEXT_CGROUP_NS
= 8,
201 LTTNG_UST_ABI_CONTEXT_IPC_NS
= 9,
202 LTTNG_UST_ABI_CONTEXT_MNT_NS
= 10,
203 LTTNG_UST_ABI_CONTEXT_NET_NS
= 11,
204 LTTNG_UST_ABI_CONTEXT_PID_NS
= 12,
205 LTTNG_UST_ABI_CONTEXT_USER_NS
= 13,
206 LTTNG_UST_ABI_CONTEXT_UTS_NS
= 14,
207 LTTNG_UST_ABI_CONTEXT_VUID
= 15,
208 LTTNG_UST_ABI_CONTEXT_VEUID
= 16,
209 LTTNG_UST_ABI_CONTEXT_VSUID
= 17,
210 LTTNG_UST_ABI_CONTEXT_VGID
= 18,
211 LTTNG_UST_ABI_CONTEXT_VEGID
= 19,
212 LTTNG_UST_ABI_CONTEXT_VSGID
= 20,
213 LTTNG_UST_ABI_CONTEXT_TIME_NS
= 21,
216 struct lttng_ust_abi_perf_counter_ctx
{
219 char name
[LTTNG_UST_ABI_SYM_NAME_LEN
];
220 } __attribute__((packed
));
222 #define LTTNG_UST_ABI_CONTEXT_PADDING1 16
223 #define LTTNG_UST_ABI_CONTEXT_PADDING2 (LTTNG_UST_ABI_SYM_NAME_LEN + 32)
224 struct lttng_ust_abi_context
{
225 int32_t ctx
; /* enum lttng_ust_abi_context_type */
226 char padding
[LTTNG_UST_ABI_CONTEXT_PADDING1
];
229 struct lttng_ust_abi_perf_counter_ctx perf_counter
;
231 /* Includes trailing '\0'. */
232 uint32_t provider_name_len
;
233 uint32_t ctx_name_len
;
235 char padding
[LTTNG_UST_ABI_CONTEXT_PADDING2
];
237 } __attribute__((packed
));
240 * Tracer channel attributes.
242 #define LTTNG_UST_ABI_CHANNEL_ATTR_PADDING (LTTNG_UST_ABI_SYM_NAME_LEN + 32)
243 struct lttng_ust_abi_channel_attr
{
244 uint64_t subbuf_size
; /* bytes */
245 uint64_t num_subbuf
; /* power of 2 */
246 int overwrite
; /* 1: overwrite, 0: discard */
247 unsigned int switch_timer_interval
; /* usec */
248 unsigned int read_timer_interval
; /* usec */
249 int32_t output
; /* enum lttng_ust_abi_output */
252 int64_t blocking_timeout
; /* Blocking timeout (usec) */
254 char padding
[LTTNG_UST_ABI_CHANNEL_ATTR_PADDING
];
256 } __attribute__((packed
));
258 #define LTTNG_UST_ABI_TRACEPOINT_ITER_PADDING 16
259 struct lttng_ust_abi_tracepoint_iter
{
260 char name
[LTTNG_UST_ABI_SYM_NAME_LEN
]; /* provider:name */
262 char padding
[LTTNG_UST_ABI_TRACEPOINT_ITER_PADDING
];
263 } __attribute__((packed
));
265 enum lttng_ust_abi_object_type
{
266 LTTNG_UST_ABI_OBJECT_TYPE_UNKNOWN
= -1,
267 LTTNG_UST_ABI_OBJECT_TYPE_CHANNEL
= 0,
268 LTTNG_UST_ABI_OBJECT_TYPE_STREAM
= 1,
269 LTTNG_UST_ABI_OBJECT_TYPE_EVENT
= 2,
270 LTTNG_UST_ABI_OBJECT_TYPE_CONTEXT
= 3,
271 LTTNG_UST_ABI_OBJECT_TYPE_EVENT_NOTIFIER_GROUP
= 4,
272 LTTNG_UST_ABI_OBJECT_TYPE_EVENT_NOTIFIER
= 5,
273 LTTNG_UST_ABI_OBJECT_TYPE_COUNTER
= 6,
274 LTTNG_UST_ABI_OBJECT_TYPE_COUNTER_GLOBAL
= 7,
275 LTTNG_UST_ABI_OBJECT_TYPE_COUNTER_CPU
= 8,
278 #define LTTNG_UST_ABI_OBJECT_DATA_PADDING1 32
279 #define LTTNG_UST_ABI_OBJECT_DATA_PADDING2 (LTTNG_UST_ABI_SYM_NAME_LEN + 32)
281 struct lttng_ust_abi_object_data
{
282 int32_t type
; /* enum lttng_ust_abi_object_type */
285 char padding1
[LTTNG_UST_ABI_OBJECT_DATA_PADDING1
];
289 int32_t type
; /* enum lttng_ust_abi_chan_type */
307 char padding2
[LTTNG_UST_ABI_OBJECT_DATA_PADDING2
];
309 } __attribute__((packed
));
311 enum lttng_ust_calibrate_type
{
312 LTTNG_UST_ABI_CALIBRATE_TRACEPOINT
,
315 #define LTTNG_UST_ABI_CALIBRATE_PADDING1 16
316 #define LTTNG_UST_ABI_CALIBRATE_PADDING2 (LTTNG_UST_ABI_SYM_NAME_LEN + 32)
317 struct lttng_ust_abi_calibrate
{
318 enum lttng_ust_calibrate_type type
; /* type (input) */
319 char padding
[LTTNG_UST_ABI_CALIBRATE_PADDING1
];
322 char padding
[LTTNG_UST_ABI_CALIBRATE_PADDING2
];
324 } __attribute__((packed
));
326 #define LTTNG_UST_ABI_FILTER_BYTECODE_MAX_LEN 65536
327 #define LTTNG_UST_ABI_FILTER_PADDING 32
328 struct lttng_ust_abi_filter_bytecode
{
330 uint32_t reloc_offset
;
332 char padding
[LTTNG_UST_ABI_FILTER_PADDING
];
334 } __attribute__((packed
));
336 #define LTTNG_UST_ABI_CAPTURE_BYTECODE_MAX_LEN 65536
337 #define LTTNG_UST_ABI_CAPTURE_PADDING 32
338 struct lttng_ust_abi_capture_bytecode
{
340 uint32_t reloc_offset
;
342 char padding
[LTTNG_UST_ABI_CAPTURE_PADDING
];
344 } __attribute__((packed
));
346 #define LTTNG_UST_ABI_EXCLUSION_PADDING 32
347 struct lttng_ust_abi_event_exclusion
{
349 char padding
[LTTNG_UST_ABI_EXCLUSION_PADDING
];
350 char names
[LTTNG_UST_ABI_SYM_NAME_LEN
][0];
351 } __attribute__((packed
));
353 #define LTTNG_UST_ABI_CMD(minor) (minor)
354 #define LTTNG_UST_ABI_CMDR(minor, type) (minor)
355 #define LTTNG_UST_ABI_CMDW(minor, type) (minor)
357 /* Handled by object descriptor */
358 #define LTTNG_UST_ABI_RELEASE LTTNG_UST_ABI_CMD(0x1)
360 /* Handled by object cmd */
362 /* LTTng-UST commands */
363 #define LTTNG_UST_ABI_SESSION LTTNG_UST_ABI_CMD(0x40)
364 #define LTTNG_UST_ABI_TRACER_VERSION \
365 LTTNG_UST_ABI_CMDR(0x41, struct lttng_ust_abi_tracer_version)
366 #define LTTNG_UST_ABI_TRACEPOINT_LIST LTTNG_UST_ABI_CMD(0x42)
367 #define LTTNG_UST_ABI_WAIT_QUIESCENT LTTNG_UST_ABI_CMD(0x43)
368 #define LTTNG_UST_ABI_REGISTER_DONE LTTNG_UST_ABI_CMD(0x44)
369 #define LTTNG_UST_ABI_TRACEPOINT_FIELD_LIST LTTNG_UST_ABI_CMD(0x45)
370 #define LTTNG_UST_ABI_EVENT_NOTIFIER_GROUP_CREATE \
371 LTTNG_UST_ABI_CMD(0x46)
373 /* Session commands */
374 #define LTTNG_UST_ABI_CHANNEL \
375 LTTNG_UST_ABI_CMDW(0x51, struct lttng_ust_abi_channel)
376 #define LTTNG_UST_ABI_SESSION_START LTTNG_UST_ABI_CMD(0x52)
377 #define LTTNG_UST_ABI_SESSION_STOP LTTNG_UST_ABI_CMD(0x53)
378 #define LTTNG_UST_ABI_SESSION_STATEDUMP LTTNG_UST_ABI_CMD(0x54)
380 /* Channel commands */
381 #define LTTNG_UST_ABI_STREAM LTTNG_UST_ABI_CMD(0x60)
382 #define LTTNG_UST_ABI_EVENT \
383 LTTNG_UST_ABI_CMDW(0x61, struct lttng_ust_abi_event)
385 /* Event and channel commands */
386 #define LTTNG_UST_ABI_CONTEXT \
387 LTTNG_UST_ABI_CMDW(0x70, struct lttng_ust_abi_context)
388 #define LTTNG_UST_ABI_FLUSH_BUFFER \
389 LTTNG_UST_ABI_CMD(0x71)
391 /* Event, event notifier, channel and session commands */
392 #define LTTNG_UST_ABI_ENABLE LTTNG_UST_ABI_CMD(0x80)
393 #define LTTNG_UST_ABI_DISABLE LTTNG_UST_ABI_CMD(0x81)
395 /* Tracepoint list commands */
396 #define LTTNG_UST_ABI_TRACEPOINT_LIST_GET LTTNG_UST_ABI_CMD(0x90)
397 #define LTTNG_UST_ABI_TRACEPOINT_FIELD_LIST_GET LTTNG_UST_ABI_CMD(0x91)
399 /* Event and event notifier commands */
400 #define LTTNG_UST_ABI_FILTER LTTNG_UST_ABI_CMD(0xA0)
401 #define LTTNG_UST_ABI_EXCLUSION LTTNG_UST_ABI_CMD(0xA1)
403 /* Event notifier group commands */
404 #define LTTNG_UST_ABI_EVENT_NOTIFIER_CREATE \
405 LTTNG_UST_ABI_CMDW(0xB0, struct lttng_ust_abi_event_notifier)
407 /* Event notifier commands */
408 #define LTTNG_UST_ABI_CAPTURE LTTNG_UST_ABI_CMD(0xB6)
410 /* Session and event notifier group commands */
411 #define LTTNG_UST_ABI_COUNTER \
412 LTTNG_UST_ABI_CMDW(0xC0, struct lttng_ust_abi_counter)
414 /* Counter commands */
415 #define LTTNG_UST_ABI_COUNTER_GLOBAL \
416 LTTNG_UST_ABI_CMDW(0xD0, struct lttng_ust_abi_counter_global)
417 #define LTTNG_UST_ABI_COUNTER_CPU \
418 LTTNG_UST_ABI_CMDW(0xD1, struct lttng_ust_abi_counter_cpu)
420 #define LTTNG_UST_ABI_ROOT_HANDLE 0
422 #endif /* _LTTNG_UST_ABI_H */