843fe4ed97c2fccf85e195b80578ca873f19cc5d
[lttng-ust.git] / include / lttng / ust-abi.h
1 /*
2 * SPDX-License-Identifier: MIT
3 *
4 * Copyright (C) 2010-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
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 #ifndef __ust_stringify
16 #define __ust_stringify1(x) #x
17 #define __ust_stringify(x) __ust_stringify1(x)
18 #endif /* __ust_stringify */
19
20 #define LTTNG_UST_ABI_SYM_NAME_LEN 256
21 #define LTTNG_UST_ABI_PROCNAME_LEN 16
22
23 /* UST comm magic number, used to validate protocol and endianness. */
24 #define LTTNG_UST_ABI_COMM_MAGIC 0xC57C57C5
25
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
30
31 enum lttng_ust_abi_instrumentation {
32 LTTNG_UST_ABI_TRACEPOINT = 0,
33 LTTNG_UST_ABI_PROBE = 1,
34 LTTNG_UST_ABI_FUNCTION = 2,
35 };
36
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,
41 };
42
43 enum lttng_ust_abi_output {
44 LTTNG_UST_ABI_MMAP = 0,
45 };
46
47 enum lttng_ust_abi_chan_type {
48 LTTNG_UST_ABI_CHAN_PER_CPU = 0,
49 LTTNG_UST_ABI_CHAN_METADATA = 1,
50 };
51
52 struct lttng_ust_abi_tracer_version {
53 uint32_t major;
54 uint32_t minor;
55 uint32_t patchlevel;
56 } __attribute__((packed));
57
58 #define LTTNG_UST_ABI_CHANNEL_PADDING (LTTNG_UST_ABI_SYM_NAME_LEN + 32)
59 /*
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.
64 */
65 #define LTTNG_UST_ABI_CHANNEL_DATA_MAX_LEN 1048576U
66 struct lttng_ust_abi_channel {
67 uint64_t len;
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));
72
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];
78 /*
79 * shm_fd and wakeup_fd are send over unix socket as file
80 * descriptors after this structure.
81 */
82 } __attribute__((packed));
83
84 #define LTTNG_UST_ABI_COUNTER_DIMENSION_MAX 4
85
86 enum lttng_ust_abi_counter_arithmetic {
87 LTTNG_UST_ABI_COUNTER_ARITHMETIC_MODULAR = 0,
88 LTTNG_UST_ABI_COUNTER_ARITHMETIC_SATURATION = 1,
89 };
90
91 enum lttng_ust_abi_counter_bitness {
92 LTTNG_UST_ABI_COUNTER_BITNESS_32 = 0,
93 LTTNG_UST_ABI_COUNTER_BITNESS_64 = 1,
94 };
95
96 struct lttng_ust_abi_counter_dimension {
97 uint64_t size;
98 uint64_t underflow_index;
99 uint64_t overflow_index;
100 uint8_t has_underflow;
101 uint8_t has_overflow;
102 } __attribute__((packed));
103
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));
114
115 struct lttng_ust_abi_counter_value {
116 uint32_t number_dimensions;
117 uint64_t dimension_indexes[LTTNG_UST_ABI_COUNTER_DIMENSION_MAX];
118 int64_t value;
119 } __attribute__((packed));
120
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 */
126
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];
131
132 /* Per instrumentation type configuration */
133 union {
134 char padding[LTTNG_UST_ABI_EVENT_PADDING2];
135 } u;
136 } __attribute__((packed));
137
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));
144
145 #define LTTNG_UST_ABI_EVENT_NOTIFIER_NOTIFICATION_PADDING 32
146 struct lttng_ust_abi_event_notifier_notification {
147 uint64_t token;
148 uint16_t capture_buf_size;
149 char padding[LTTNG_UST_ABI_EVENT_NOTIFIER_NOTIFICATION_PADDING];
150 } __attribute__((packed));
151
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 {
155 uint64_t len;
156 char padding[LTTNG_UST_ABI_COUNTER_PADDING1];
157 char data[]; /* variable sized data */
158 } __attribute__((packed));
159
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));
165
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 */
169 uint32_t cpu_nr;
170 char padding[LTTNG_UST_ABI_COUNTER_CPU_PADDING1];
171 } __attribute__((packed));
172
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,
179 };
180
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 */
187 int nowrite;
188 char padding[LTTNG_UST_ABI_FIELD_ITER_PADDING];
189 } __attribute__((packed));
190
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,
214 };
215
216 struct lttng_ust_abi_perf_counter_ctx {
217 uint32_t type;
218 uint64_t config;
219 char name[LTTNG_UST_ABI_SYM_NAME_LEN];
220 } __attribute__((packed));
221
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];
227
228 union {
229 struct lttng_ust_abi_perf_counter_ctx perf_counter;
230 struct {
231 /* Includes trailing '\0'. */
232 uint32_t provider_name_len;
233 uint32_t ctx_name_len;
234 } app_ctx;
235 char padding[LTTNG_UST_ABI_CONTEXT_PADDING2];
236 } u;
237 } __attribute__((packed));
238
239 /*
240 * Tracer channel attributes.
241 */
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 */
250 union {
251 struct {
252 int64_t blocking_timeout; /* Blocking timeout (usec) */
253 } s;
254 char padding[LTTNG_UST_ABI_CHANNEL_ATTR_PADDING];
255 } u;
256 } __attribute__((packed));
257
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 */
261 int loglevel;
262 char padding[LTTNG_UST_ABI_TRACEPOINT_ITER_PADDING];
263 } __attribute__((packed));
264
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,
276 };
277
278 #define LTTNG_UST_ABI_OBJECT_DATA_PADDING1 32
279 #define LTTNG_UST_ABI_OBJECT_DATA_PADDING2 (LTTNG_UST_ABI_SYM_NAME_LEN + 32)
280
281 struct lttng_ust_abi_object_data {
282 int32_t type; /* enum lttng_ust_abi_object_type */
283 int handle;
284 uint64_t size;
285 char padding1[LTTNG_UST_ABI_OBJECT_DATA_PADDING1];
286 union {
287 struct {
288 void *data;
289 int32_t type; /* enum lttng_ust_abi_chan_type */
290 int wakeup_fd;
291 } channel;
292 struct {
293 int shm_fd;
294 int wakeup_fd;
295 uint32_t stream_nr;
296 } stream;
297 struct {
298 void *data;
299 } counter;
300 struct {
301 int shm_fd;
302 } counter_global;
303 struct {
304 int shm_fd;
305 uint32_t cpu_nr;
306 } counter_cpu;
307 char padding2[LTTNG_UST_ABI_OBJECT_DATA_PADDING2];
308 } u;
309 } __attribute__((packed));
310
311 enum lttng_ust_calibrate_type {
312 LTTNG_UST_ABI_CALIBRATE_TRACEPOINT,
313 };
314
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];
320
321 union {
322 char padding[LTTNG_UST_ABI_CALIBRATE_PADDING2];
323 } u;
324 } __attribute__((packed));
325
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 {
329 uint32_t len;
330 uint32_t reloc_offset;
331 uint64_t seqnum;
332 char padding[LTTNG_UST_ABI_FILTER_PADDING];
333 char data[0];
334 } __attribute__((packed));
335
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 {
339 uint32_t len;
340 uint32_t reloc_offset;
341 uint64_t seqnum;
342 char padding[LTTNG_UST_ABI_CAPTURE_PADDING];
343 char data[0];
344 } __attribute__((packed));
345
346 #define LTTNG_UST_ABI_EXCLUSION_PADDING 32
347 struct lttng_ust_abi_event_exclusion {
348 uint32_t count;
349 char padding[LTTNG_UST_ABI_EXCLUSION_PADDING];
350 char names[LTTNG_UST_ABI_SYM_NAME_LEN][0];
351 } __attribute__((packed));
352
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)
356
357 /* Handled by object descriptor */
358 #define LTTNG_UST_ABI_RELEASE LTTNG_UST_ABI_CMD(0x1)
359
360 /* Handled by object cmd */
361
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)
372
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)
379
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)
384
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)
390
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)
394
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)
398
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)
402
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)
406
407 /* Event notifier commands */
408 #define LTTNG_UST_ABI_CAPTURE LTTNG_UST_ABI_CMD(0xB6)
409
410 /* Session and event notifier group commands */
411 #define LTTNG_UST_ABI_COUNTER \
412 LTTNG_UST_ABI_CMDW(0xC0, struct lttng_ust_abi_counter)
413
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)
419
420 #define LTTNG_UST_ABI_ROOT_HANDLE 0
421
422 #endif /* _LTTNG_UST_ABI_H */
This page took 0.048381 seconds and 3 git commands to generate.