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