Copyright ownership transfer
[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 #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 9
23 #define LTTNG_UST_ABI_MAJOR_VERSION_OLDEST_COMPATIBLE 8
24 #define LTTNG_UST_ABI_MINOR_VERSION 0
25
26 enum lttng_ust_abi_instrumentation {
27 LTTNG_UST_ABI_TRACEPOINT = 0,
28 LTTNG_UST_ABI_PROBE = 1,
29 LTTNG_UST_ABI_FUNCTION = 2,
30 };
31
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,
36 };
37
38 enum lttng_ust_abi_output {
39 LTTNG_UST_ABI_MMAP = 0,
40 };
41
42 enum lttng_ust_abi_chan_type {
43 LTTNG_UST_ABI_CHAN_PER_CPU = 0,
44 LTTNG_UST_ABI_CHAN_METADATA = 1,
45 };
46
47 struct lttng_ust_abi_tracer_version {
48 uint32_t major;
49 uint32_t minor;
50 uint32_t patchlevel;
51 } __attribute__((packed));
52
53 #define LTTNG_UST_ABI_CHANNEL_PADDING (LTTNG_UST_ABI_SYM_NAME_LEN + 32)
54 /*
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.
59 */
60 #define LTTNG_UST_ABI_CHANNEL_DATA_MAX_LEN 1048576U
61 struct lttng_ust_abi_channel {
62 uint64_t len;
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));
67
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];
73 /*
74 * shm_fd and wakeup_fd are send over unix socket as file
75 * descriptors after this structure.
76 */
77 } __attribute__((packed));
78
79 #define LTTNG_UST_ABI_COUNTER_DIMENSION_MAX 4
80
81 enum lttng_ust_abi_counter_arithmetic {
82 LTTNG_UST_ABI_COUNTER_ARITHMETIC_MODULAR = 0,
83 LTTNG_UST_ABI_COUNTER_ARITHMETIC_SATURATION = 1,
84 };
85
86 enum lttng_ust_abi_counter_bitness {
87 LTTNG_UST_ABI_COUNTER_BITNESS_32 = 0,
88 LTTNG_UST_ABI_COUNTER_BITNESS_64 = 1,
89 };
90
91 struct lttng_ust_abi_counter_dimension {
92 uint64_t size;
93 uint64_t underflow_index;
94 uint64_t overflow_index;
95 uint8_t has_underflow;
96 uint8_t has_overflow;
97 } __attribute__((packed));
98
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));
109
110 struct lttng_ust_abi_counter_value {
111 uint32_t number_dimensions;
112 uint64_t dimension_indexes[LTTNG_UST_ABI_COUNTER_DIMENSION_MAX];
113 int64_t value;
114 } __attribute__((packed));
115
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 */
121
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];
126
127 /* Per instrumentation type configuration */
128 union {
129 char padding[LTTNG_UST_ABI_EVENT_PADDING2];
130 } u;
131 } __attribute__((packed));
132
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));
139
140 #define LTTNG_UST_ABI_EVENT_NOTIFIER_NOTIFICATION_PADDING 32
141 struct lttng_ust_abi_event_notifier_notification {
142 uint64_t token;
143 uint16_t capture_buf_size;
144 char padding[LTTNG_UST_ABI_EVENT_NOTIFIER_NOTIFICATION_PADDING];
145 } __attribute__((packed));
146
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 {
150 uint64_t len;
151 char padding[LTTNG_UST_ABI_COUNTER_PADDING1];
152 char data[]; /* variable sized data */
153 } __attribute__((packed));
154
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));
160
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 */
164 uint32_t cpu_nr;
165 char padding[LTTNG_UST_ABI_COUNTER_CPU_PADDING1];
166 } __attribute__((packed));
167
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,
174 };
175
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 */
182 int nowrite;
183 char padding[LTTNG_UST_ABI_FIELD_ITER_PADDING];
184 } __attribute__((packed));
185
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,
209 };
210
211 struct lttng_ust_abi_perf_counter_ctx {
212 uint32_t type;
213 uint64_t config;
214 char name[LTTNG_UST_ABI_SYM_NAME_LEN];
215 } __attribute__((packed));
216
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];
222
223 union {
224 struct lttng_ust_abi_perf_counter_ctx perf_counter;
225 struct {
226 /* Includes trailing '\0'. */
227 uint32_t provider_name_len;
228 uint32_t ctx_name_len;
229 } app_ctx;
230 char padding[LTTNG_UST_ABI_CONTEXT_PADDING2];
231 } u;
232 } __attribute__((packed));
233
234 /*
235 * Tracer channel attributes.
236 */
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 */
245 union {
246 struct {
247 int64_t blocking_timeout; /* Blocking timeout (usec) */
248 } s;
249 char padding[LTTNG_UST_ABI_CHANNEL_ATTR_PADDING];
250 } u;
251 } __attribute__((packed));
252
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 */
256 int loglevel;
257 char padding[LTTNG_UST_ABI_TRACEPOINT_ITER_PADDING];
258 } __attribute__((packed));
259
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,
271 };
272
273 #define LTTNG_UST_ABI_OBJECT_DATA_PADDING1 32
274 #define LTTNG_UST_ABI_OBJECT_DATA_PADDING2 (LTTNG_UST_ABI_SYM_NAME_LEN + 32)
275
276 struct lttng_ust_abi_object_data {
277 int32_t type; /* enum lttng_ust_abi_object_type */
278 int handle;
279 uint64_t size;
280 char padding1[LTTNG_UST_ABI_OBJECT_DATA_PADDING1];
281 union {
282 struct {
283 void *data;
284 int32_t type; /* enum lttng_ust_abi_chan_type */
285 int wakeup_fd;
286 } channel;
287 struct {
288 int shm_fd;
289 int wakeup_fd;
290 uint32_t stream_nr;
291 } stream;
292 struct {
293 void *data;
294 } counter;
295 struct {
296 int shm_fd;
297 } counter_global;
298 struct {
299 int shm_fd;
300 uint32_t cpu_nr;
301 } counter_cpu;
302 char padding2[LTTNG_UST_ABI_OBJECT_DATA_PADDING2];
303 } u;
304 } __attribute__((packed));
305
306 enum lttng_ust_abi_calibrate_type {
307 LTTNG_UST_ABI_CALIBRATE_TRACEPOINT,
308 };
309
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];
315
316 union {
317 char padding[LTTNG_UST_ABI_CALIBRATE_PADDING2];
318 } u;
319 } __attribute__((packed));
320
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 {
324 uint32_t len;
325 uint32_t reloc_offset;
326 uint64_t seqnum;
327 char padding[LTTNG_UST_ABI_FILTER_PADDING];
328 char data[0];
329 } __attribute__((packed));
330
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 {
334 uint32_t len;
335 uint32_t reloc_offset;
336 uint64_t seqnum;
337 char padding[LTTNG_UST_ABI_CAPTURE_PADDING];
338 char data[0];
339 } __attribute__((packed));
340
341 #define LTTNG_UST_ABI_EXCLUSION_PADDING 32
342 struct lttng_ust_abi_event_exclusion {
343 uint32_t count;
344 char padding[LTTNG_UST_ABI_EXCLUSION_PADDING];
345 char names[LTTNG_UST_ABI_SYM_NAME_LEN][0];
346 } __attribute__((packed));
347
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)
351
352 /* Handled by object descriptor */
353 #define LTTNG_UST_ABI_RELEASE LTTNG_UST_ABI_CMD(0x1)
354
355 /* Handled by object cmd */
356
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)
367
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)
374
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)
379
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)
385
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)
389
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)
393
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)
397
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)
401
402 /* Event notifier commands */
403 #define LTTNG_UST_ABI_CAPTURE LTTNG_UST_ABI_CMD(0xB6)
404
405 /* Session and event notifier group commands */
406 #define LTTNG_UST_ABI_COUNTER \
407 LTTNG_UST_ABI_CMDW(0xC0, struct lttng_ust_abi_counter)
408
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)
414
415 #define LTTNG_UST_ABI_ROOT_HANDLE 0
416
417 #endif /* _LTTNG_UST_ABI_H */
This page took 0.037816 seconds and 4 git commands to generate.