ebe96021260d9d1ec687a548d84c7597e83cedc3
[lttng-tools.git] / src / bin / lttng-sessiond / ust-abi-internal.h
1 /*
2 * Copyright 2010-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
3 *
4 * SPDX-License-Identifier: MIT
5 *
6 * Copied from LTTng-UST lttng/ust-abi.h
7 *
8 * LTTng-UST ABI header
9 *
10 */
11
12 #ifndef LTTNG_UST_ABI_INTERNAL_H
13 #define LTTNG_UST_ABI_INTERNAL_H
14
15 #include <stdint.h>
16 #include <common/macros.h>
17
18 #ifndef LTTNG_PACKED
19 #error "LTTNG_PACKED should be defined"
20 #endif
21
22 #ifndef __ust_stringify
23 #define __ust_stringify1(x) #x
24 #define __ust_stringify(x) __ust_stringify1(x)
25 #endif /* __ust_stringify */
26
27 #define LTTNG_UST_ABI_SYM_NAME_LEN 256
28 #define LTTNG_UST_ABI_PROCNAME_LEN 16
29
30 /* UST comm magic number, used to validate protocol and endianness. */
31 #define LTTNG_UST_ABI_COMM_MAGIC 0xC57C57C5
32
33 /* Version for ABI between liblttng-ust, sessiond, consumerd */
34 #define LTTNG_UST_ABI_MAJOR_VERSION 9
35 #define LTTNG_UST_ABI_MAJOR_VERSION_OLDEST_COMPATIBLE 8
36 #define LTTNG_UST_ABI_MINOR_VERSION 0
37
38 enum lttng_ust_abi_instrumentation {
39 LTTNG_UST_ABI_TRACEPOINT = 0,
40 LTTNG_UST_ABI_PROBE = 1,
41 LTTNG_UST_ABI_FUNCTION = 2,
42 };
43
44 enum lttng_ust_abi_loglevel_type {
45 LTTNG_UST_ABI_LOGLEVEL_ALL = 0,
46 LTTNG_UST_ABI_LOGLEVEL_RANGE = 1,
47 LTTNG_UST_ABI_LOGLEVEL_SINGLE = 2,
48 };
49
50 enum lttng_ust_abi_output {
51 LTTNG_UST_ABI_MMAP = 0,
52 };
53
54 enum lttng_ust_abi_chan_type {
55 LTTNG_UST_ABI_CHAN_PER_CPU = 0,
56 LTTNG_UST_ABI_CHAN_METADATA = 1,
57 };
58
59 struct lttng_ust_abi_tracer_version {
60 uint32_t major;
61 uint32_t minor;
62 uint32_t patchlevel;
63 } LTTNG_PACKED;
64
65 #define LTTNG_UST_ABI_CHANNEL_PADDING (LTTNG_UST_ABI_SYM_NAME_LEN + 32)
66 /*
67 * Given that the consumerd is limited to 64k file descriptors, we
68 * cannot expect much more than 1MB channel structure size. This size is
69 * depends on the number of streams within a channel, which depends on
70 * the number of possible CPUs on the system.
71 */
72 #define LTTNG_UST_ABI_CHANNEL_DATA_MAX_LEN 1048576U
73 struct lttng_ust_abi_channel {
74 uint64_t len;
75 int32_t type; /* enum lttng_ust_abi_chan_type */
76 char padding[LTTNG_UST_ABI_CHANNEL_PADDING];
77 char data[]; /* variable sized data */
78 } LTTNG_PACKED;
79
80 #define LTTNG_UST_ABI_STREAM_PADDING1 (LTTNG_UST_ABI_SYM_NAME_LEN + 32)
81 struct lttng_ust_abi_stream {
82 uint64_t len; /* shm len */
83 uint32_t stream_nr; /* stream number */
84 char padding[LTTNG_UST_ABI_STREAM_PADDING1];
85 /*
86 * shm_fd and wakeup_fd are send over unix socket as file
87 * descriptors after this structure.
88 */
89 } LTTNG_PACKED;
90
91 #define LTTNG_UST_ABI_COUNTER_DIMENSION_MAX 4
92
93 enum lttng_ust_abi_counter_arithmetic {
94 LTTNG_UST_ABI_COUNTER_ARITHMETIC_MODULAR = 0,
95 LTTNG_UST_ABI_COUNTER_ARITHMETIC_SATURATION = 1,
96 };
97
98 enum lttng_ust_abi_counter_bitness {
99 LTTNG_UST_ABI_COUNTER_BITNESS_32 = 0,
100 LTTNG_UST_ABI_COUNTER_BITNESS_64 = 1,
101 };
102
103 struct lttng_ust_abi_counter_dimension {
104 uint64_t size;
105 uint64_t underflow_index;
106 uint64_t overflow_index;
107 uint8_t has_underflow;
108 uint8_t has_overflow;
109 } LTTNG_PACKED;
110
111 #define LTTNG_UST_ABI_COUNTER_CONF_PADDING1 67
112 struct lttng_ust_abi_counter_conf {
113 uint32_t arithmetic; /* enum lttng_ust_counter_arithmetic */
114 uint32_t bitness; /* enum lttng_ust_counter_bitness */
115 uint32_t number_dimensions;
116 int64_t global_sum_step;
117 struct lttng_ust_abi_counter_dimension dimensions[LTTNG_UST_ABI_COUNTER_DIMENSION_MAX];
118 uint8_t coalesce_hits;
119 char padding[LTTNG_UST_ABI_COUNTER_CONF_PADDING1];
120 } LTTNG_PACKED;
121
122 struct lttng_ust_abi_counter_value {
123 uint32_t number_dimensions;
124 uint64_t dimension_indexes[LTTNG_UST_ABI_COUNTER_DIMENSION_MAX];
125 int64_t value;
126 } LTTNG_PACKED;
127
128 #define LTTNG_UST_ABI_EVENT_PADDING1 8
129 #define LTTNG_UST_ABI_EVENT_PADDING2 (LTTNG_UST_ABI_SYM_NAME_LEN + 32)
130 struct lttng_ust_abi_event {
131 int32_t instrumentation; /* enum lttng_ust_abi_instrumentation */
132 char name[LTTNG_UST_ABI_SYM_NAME_LEN]; /* event name */
133
134 int32_t loglevel_type; /* enum lttng_ust_abi_loglevel_type */
135 int32_t loglevel; /* value, -1: all */
136 uint64_t token; /* User-provided token */
137 char padding[LTTNG_UST_ABI_EVENT_PADDING1];
138
139 /* Per instrumentation type configuration */
140 union {
141 char padding[LTTNG_UST_ABI_EVENT_PADDING2];
142 } u;
143 } LTTNG_PACKED;
144
145 #define LTTNG_UST_ABI_EVENT_NOTIFIER_PADDING 32
146 struct lttng_ust_abi_event_notifier {
147 struct lttng_ust_abi_event event;
148 uint64_t error_counter_index;
149 char padding[LTTNG_UST_ABI_EVENT_NOTIFIER_PADDING];
150 } LTTNG_PACKED;
151
152 #define LTTNG_UST_ABI_EVENT_NOTIFIER_NOTIFICATION_PADDING 32
153 struct lttng_ust_abi_event_notifier_notification {
154 uint64_t token;
155 uint16_t capture_buf_size;
156 char padding[LTTNG_UST_ABI_EVENT_NOTIFIER_NOTIFICATION_PADDING];
157 } LTTNG_PACKED;
158
159 #define LTTNG_UST_ABI_COUNTER_PADDING1 (LTTNG_UST_ABI_SYM_NAME_LEN + 32)
160 #define LTTNG_UST_ABI_COUNTER_DATA_MAX_LEN 4096U
161 struct lttng_ust_abi_counter {
162 uint64_t len;
163 char padding[LTTNG_UST_ABI_COUNTER_PADDING1];
164 char data[]; /* variable sized data */
165 } LTTNG_PACKED;
166
167 #define LTTNG_UST_ABI_COUNTER_GLOBAL_PADDING1 (LTTNG_UST_ABI_SYM_NAME_LEN + 32)
168 struct lttng_ust_abi_counter_global {
169 uint64_t len; /* shm len */
170 char padding[LTTNG_UST_ABI_COUNTER_GLOBAL_PADDING1];
171 } LTTNG_PACKED;
172
173 #define LTTNG_UST_ABI_COUNTER_CPU_PADDING1 (LTTNG_UST_ABI_SYM_NAME_LEN + 32)
174 struct lttng_ust_abi_counter_cpu {
175 uint64_t len; /* shm len */
176 uint32_t cpu_nr;
177 char padding[LTTNG_UST_ABI_COUNTER_CPU_PADDING1];
178 } LTTNG_PACKED;
179
180 enum lttng_ust_abi_field_type {
181 LTTNG_UST_ABI_FIELD_OTHER = 0,
182 LTTNG_UST_ABI_FIELD_INTEGER = 1,
183 LTTNG_UST_ABI_FIELD_ENUM = 2,
184 LTTNG_UST_ABI_FIELD_FLOAT = 3,
185 LTTNG_UST_ABI_FIELD_STRING = 4,
186 };
187
188 #define LTTNG_UST_ABI_FIELD_ITER_PADDING (LTTNG_UST_ABI_SYM_NAME_LEN + 28)
189 struct lttng_ust_abi_field_iter {
190 char event_name[LTTNG_UST_ABI_SYM_NAME_LEN];
191 char field_name[LTTNG_UST_ABI_SYM_NAME_LEN];
192 int32_t type; /* enum lttng_ust_abi_field_type */
193 int loglevel; /* event loglevel */
194 int nowrite;
195 char padding[LTTNG_UST_ABI_FIELD_ITER_PADDING];
196 } LTTNG_PACKED;
197
198 enum lttng_ust_abi_context_type {
199 LTTNG_UST_ABI_CONTEXT_VTID = 0,
200 LTTNG_UST_ABI_CONTEXT_VPID = 1,
201 LTTNG_UST_ABI_CONTEXT_PTHREAD_ID = 2,
202 LTTNG_UST_ABI_CONTEXT_PROCNAME = 3,
203 LTTNG_UST_ABI_CONTEXT_IP = 4,
204 LTTNG_UST_ABI_CONTEXT_PERF_THREAD_COUNTER = 5,
205 LTTNG_UST_ABI_CONTEXT_CPU_ID = 6,
206 LTTNG_UST_ABI_CONTEXT_APP_CONTEXT = 7,
207 LTTNG_UST_ABI_CONTEXT_CGROUP_NS = 8,
208 LTTNG_UST_ABI_CONTEXT_IPC_NS = 9,
209 LTTNG_UST_ABI_CONTEXT_MNT_NS = 10,
210 LTTNG_UST_ABI_CONTEXT_NET_NS = 11,
211 LTTNG_UST_ABI_CONTEXT_PID_NS = 12,
212 LTTNG_UST_ABI_CONTEXT_USER_NS = 13,
213 LTTNG_UST_ABI_CONTEXT_UTS_NS = 14,
214 LTTNG_UST_ABI_CONTEXT_VUID = 15,
215 LTTNG_UST_ABI_CONTEXT_VEUID = 16,
216 LTTNG_UST_ABI_CONTEXT_VSUID = 17,
217 LTTNG_UST_ABI_CONTEXT_VGID = 18,
218 LTTNG_UST_ABI_CONTEXT_VEGID = 19,
219 LTTNG_UST_ABI_CONTEXT_VSGID = 20,
220 LTTNG_UST_ABI_CONTEXT_TIME_NS = 21,
221 };
222
223 struct lttng_ust_abi_perf_counter_ctx {
224 uint32_t type;
225 uint64_t config;
226 char name[LTTNG_UST_ABI_SYM_NAME_LEN];
227 } LTTNG_PACKED;
228
229 #define LTTNG_UST_ABI_CONTEXT_PADDING1 16
230 #define LTTNG_UST_ABI_CONTEXT_PADDING2 (LTTNG_UST_ABI_SYM_NAME_LEN + 32)
231 struct lttng_ust_abi_context {
232 int32_t ctx; /* enum lttng_ust_abi_context_type */
233 char padding[LTTNG_UST_ABI_CONTEXT_PADDING1];
234
235 union {
236 struct lttng_ust_abi_perf_counter_ctx perf_counter;
237 struct {
238 /* Includes trailing '\0'. */
239 uint32_t provider_name_len;
240 uint32_t ctx_name_len;
241 } app_ctx;
242 char padding[LTTNG_UST_ABI_CONTEXT_PADDING2];
243 } u;
244 } LTTNG_PACKED;
245
246 /*
247 * Tracer channel attributes.
248 */
249 #define LTTNG_UST_ABI_CHANNEL_ATTR_PADDING (LTTNG_UST_ABI_SYM_NAME_LEN + 32)
250 struct lttng_ust_abi_channel_attr {
251 uint64_t subbuf_size; /* bytes */
252 uint64_t num_subbuf; /* power of 2 */
253 int overwrite; /* 1: overwrite, 0: discard */
254 unsigned int switch_timer_interval; /* usec */
255 unsigned int read_timer_interval; /* usec */
256 int32_t output; /* enum lttng_ust_abi_output */
257 union {
258 struct {
259 int64_t blocking_timeout; /* Blocking timeout (usec) */
260 } s;
261 char padding[LTTNG_UST_ABI_CHANNEL_ATTR_PADDING];
262 } u;
263 } LTTNG_PACKED;
264
265 #define LTTNG_UST_ABI_TRACEPOINT_ITER_PADDING 16
266 struct lttng_ust_abi_tracepoint_iter {
267 char name[LTTNG_UST_ABI_SYM_NAME_LEN]; /* provider:name */
268 int loglevel;
269 char padding[LTTNG_UST_ABI_TRACEPOINT_ITER_PADDING];
270 } LTTNG_PACKED;
271
272 enum lttng_ust_abi_object_type {
273 LTTNG_UST_ABI_OBJECT_TYPE_UNKNOWN = -1,
274 LTTNG_UST_ABI_OBJECT_TYPE_CHANNEL = 0,
275 LTTNG_UST_ABI_OBJECT_TYPE_STREAM = 1,
276 LTTNG_UST_ABI_OBJECT_TYPE_EVENT = 2,
277 LTTNG_UST_ABI_OBJECT_TYPE_CONTEXT = 3,
278 LTTNG_UST_ABI_OBJECT_TYPE_EVENT_NOTIFIER_GROUP = 4,
279 LTTNG_UST_ABI_OBJECT_TYPE_EVENT_NOTIFIER = 5,
280 LTTNG_UST_ABI_OBJECT_TYPE_COUNTER = 6,
281 LTTNG_UST_ABI_OBJECT_TYPE_COUNTER_GLOBAL = 7,
282 LTTNG_UST_ABI_OBJECT_TYPE_COUNTER_CPU = 8,
283 };
284
285 #define LTTNG_UST_ABI_OBJECT_DATA_PADDING1 32
286 #define LTTNG_UST_ABI_OBJECT_DATA_PADDING2 (LTTNG_UST_ABI_SYM_NAME_LEN + 32)
287
288 struct lttng_ust_abi_object_data {
289 int32_t type; /* enum lttng_ust_abi_object_type */
290 int handle;
291 uint64_t size;
292 char padding1[LTTNG_UST_ABI_OBJECT_DATA_PADDING1];
293 union {
294 struct {
295 void *data;
296 int32_t type; /* enum lttng_ust_abi_chan_type */
297 int wakeup_fd;
298 } channel;
299 struct {
300 int shm_fd;
301 int wakeup_fd;
302 uint32_t stream_nr;
303 } stream;
304 struct {
305 void *data;
306 } counter;
307 struct {
308 int shm_fd;
309 } counter_global;
310 struct {
311 int shm_fd;
312 uint32_t cpu_nr;
313 } counter_cpu;
314 char padding2[LTTNG_UST_ABI_OBJECT_DATA_PADDING2];
315 } u;
316 } LTTNG_PACKED;
317
318 enum lttng_ust_calibrate_type {
319 LTTNG_UST_ABI_CALIBRATE_TRACEPOINT,
320 };
321
322 #define LTTNG_UST_ABI_CALIBRATE_PADDING1 16
323 #define LTTNG_UST_ABI_CALIBRATE_PADDING2 (LTTNG_UST_ABI_SYM_NAME_LEN + 32)
324 struct lttng_ust_abi_calibrate {
325 enum lttng_ust_calibrate_type type; /* type (input) */
326 char padding[LTTNG_UST_ABI_CALIBRATE_PADDING1];
327
328 union {
329 char padding[LTTNG_UST_ABI_CALIBRATE_PADDING2];
330 } u;
331 } LTTNG_PACKED;
332
333 #define LTTNG_UST_ABI_FILTER_BYTECODE_MAX_LEN 65536
334 #define LTTNG_UST_ABI_FILTER_PADDING 32
335 struct lttng_ust_abi_filter_bytecode {
336 uint32_t len;
337 uint32_t reloc_offset;
338 uint64_t seqnum;
339 char padding[LTTNG_UST_ABI_FILTER_PADDING];
340 char data[0];
341 } LTTNG_PACKED;
342
343 #define LTTNG_UST_ABI_CAPTURE_BYTECODE_MAX_LEN 65536
344 #define LTTNG_UST_ABI_CAPTURE_PADDING 32
345 struct lttng_ust_abi_capture_bytecode {
346 uint32_t len;
347 uint32_t reloc_offset;
348 uint64_t seqnum;
349 char padding[LTTNG_UST_ABI_CAPTURE_PADDING];
350 char data[0];
351 } LTTNG_PACKED;
352
353 #define LTTNG_UST_ABI_EXCLUSION_PADDING 32
354 struct lttng_ust_abi_event_exclusion {
355 uint32_t count;
356 char padding[LTTNG_UST_ABI_EXCLUSION_PADDING];
357 char names[LTTNG_UST_ABI_SYM_NAME_LEN][0];
358 } LTTNG_PACKED;
359
360 #define LTTNG_UST_ABI_CMD(minor) (minor)
361 #define LTTNG_UST_ABI_CMDR(minor, type) (minor)
362 #define LTTNG_UST_ABI_CMDW(minor, type) (minor)
363
364 /* Handled by object descriptor */
365 #define LTTNG_UST_ABI_RELEASE LTTNG_UST_ABI_CMD(0x1)
366
367 /* Handled by object cmd */
368
369 /* LTTng-UST commands */
370 #define LTTNG_UST_ABI_SESSION LTTNG_UST_ABI_CMD(0x40)
371 #define LTTNG_UST_ABI_TRACER_VERSION \
372 LTTNG_UST_ABI_CMDR(0x41, struct lttng_ust_abi_tracer_version)
373 #define LTTNG_UST_ABI_TRACEPOINT_LIST LTTNG_UST_ABI_CMD(0x42)
374 #define LTTNG_UST_ABI_WAIT_QUIESCENT LTTNG_UST_ABI_CMD(0x43)
375 #define LTTNG_UST_ABI_REGISTER_DONE LTTNG_UST_ABI_CMD(0x44)
376 #define LTTNG_UST_ABI_TRACEPOINT_FIELD_LIST LTTNG_UST_ABI_CMD(0x45)
377 #define LTTNG_UST_ABI_EVENT_NOTIFIER_GROUP_CREATE \
378 LTTNG_UST_ABI_CMD(0x46)
379
380 /* Session commands */
381 #define LTTNG_UST_ABI_CHANNEL \
382 LTTNG_UST_ABI_CMDW(0x51, struct lttng_ust_abi_channel)
383 #define LTTNG_UST_ABI_SESSION_START LTTNG_UST_ABI_CMD(0x52)
384 #define LTTNG_UST_ABI_SESSION_STOP LTTNG_UST_ABI_CMD(0x53)
385 #define LTTNG_UST_ABI_SESSION_STATEDUMP LTTNG_UST_ABI_CMD(0x54)
386
387 /* Channel commands */
388 #define LTTNG_UST_ABI_STREAM LTTNG_UST_ABI_CMD(0x60)
389 #define LTTNG_UST_ABI_EVENT \
390 LTTNG_UST_ABI_CMDW(0x61, struct lttng_ust_abi_event)
391
392 /* Event and channel commands */
393 #define LTTNG_UST_ABI_CONTEXT \
394 LTTNG_UST_ABI_CMDW(0x70, struct lttng_ust_abi_context)
395 #define LTTNG_UST_ABI_FLUSH_BUFFER \
396 LTTNG_UST_ABI_CMD(0x71)
397
398 /* Event, event notifier, channel and session commands */
399 #define LTTNG_UST_ABI_ENABLE LTTNG_UST_ABI_CMD(0x80)
400 #define LTTNG_UST_ABI_DISABLE LTTNG_UST_ABI_CMD(0x81)
401
402 /* Tracepoint list commands */
403 #define LTTNG_UST_ABI_TRACEPOINT_LIST_GET LTTNG_UST_ABI_CMD(0x90)
404 #define LTTNG_UST_ABI_TRACEPOINT_FIELD_LIST_GET LTTNG_UST_ABI_CMD(0x91)
405
406 /* Event and event notifier commands */
407 #define LTTNG_UST_ABI_FILTER LTTNG_UST_ABI_CMD(0xA0)
408 #define LTTNG_UST_ABI_EXCLUSION LTTNG_UST_ABI_CMD(0xA1)
409
410 /* Event notifier group commands */
411 #define LTTNG_UST_ABI_EVENT_NOTIFIER_CREATE \
412 LTTNG_UST_ABI_CMDW(0xB0, struct lttng_ust_abi_event_notifier)
413
414 /* Event notifier commands */
415 #define LTTNG_UST_ABI_CAPTURE LTTNG_UST_ABI_CMD(0xB6)
416
417 /* Session and event notifier group commands */
418 #define LTTNG_UST_ABI_COUNTER \
419 LTTNG_UST_ABI_CMDW(0xC0, struct lttng_ust_abi_counter)
420
421 /* Counter commands */
422 #define LTTNG_UST_ABI_COUNTER_GLOBAL \
423 LTTNG_UST_ABI_CMDW(0xD0, struct lttng_ust_abi_counter_global)
424 #define LTTNG_UST_ABI_COUNTER_CPU \
425 LTTNG_UST_ABI_CMDW(0xD1, struct lttng_ust_abi_counter_cpu)
426
427 #define LTTNG_UST_ABI_ROOT_HANDLE 0
428
429 #endif /* LTTNG_UST_ABI_INTERNAL_H */
This page took 0.061338 seconds and 3 git commands to generate.