1 #ifndef _LTTNG_UST_ABI_H
2 #define _LTTNG_UST_ABI_H
9 * Copyright 2010-2012 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
11 * Permission is hereby granted, free of charge, to any person obtaining a copy
12 * of this software and associated documentation files (the "Software"), to deal
13 * in the Software without restriction, including without limitation the rights
14 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15 * copies of the Software, and to permit persons to whom the Software is
16 * furnished to do so, subject to the following conditions:
18 * The above copyright notice and this permission notice shall be included in
19 * all copies or substantial portions of the Software.
21 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
31 #include <lttng/ust-compiler.h>
34 #error "LTTNG_PACKED should be defined"
37 #ifndef __ust_stringify
38 #define __ust_stringify1(x) #x
39 #define __ust_stringify(x) __ust_stringify1(x)
40 #endif /* __ust_stringify */
42 #define LTTNG_UST_SYM_NAME_LEN 256
43 #define LTTNG_UST_ABI_PROCNAME_LEN 16
45 /* UST comm magic number, used to validate protocol and endianness. */
46 #define LTTNG_UST_COMM_MAGIC 0xC57C57C5
48 /* Version for ABI between liblttng-ust, sessiond, consumerd */
49 #define LTTNG_UST_ABI_MAJOR_VERSION 9
50 #define LTTNG_UST_ABI_MAJOR_VERSION_OLDEST_COMPATIBLE 8
51 #define LTTNG_UST_ABI_MINOR_VERSION 0
53 enum lttng_ust_instrumentation
{
54 LTTNG_UST_TRACEPOINT
= 0,
56 LTTNG_UST_FUNCTION
= 2,
59 enum lttng_ust_loglevel_type
{
60 LTTNG_UST_LOGLEVEL_ALL
= 0,
61 LTTNG_UST_LOGLEVEL_RANGE
= 1,
62 LTTNG_UST_LOGLEVEL_SINGLE
= 2,
65 enum lttng_ust_output
{
69 enum lttng_ust_chan_type
{
70 LTTNG_UST_CHAN_PER_CPU
= 0,
71 LTTNG_UST_CHAN_METADATA
= 1,
74 struct lttng_ust_tracer_version
{
80 #define LTTNG_UST_CHANNEL_PADDING (LTTNG_UST_SYM_NAME_LEN + 32)
82 * Given that the consumerd is limited to 64k file descriptors, we
83 * cannot expect much more than 1MB channel structure size. This size is
84 * depends on the number of streams within a channel, which depends on
85 * the number of possible CPUs on the system.
87 #define LTTNG_UST_CHANNEL_DATA_MAX_LEN 1048576U
88 struct lttng_ust_channel
{
90 enum lttng_ust_chan_type type
;
91 char padding
[LTTNG_UST_CHANNEL_PADDING
];
92 char data
[]; /* variable sized data */
95 #define LTTNG_UST_STREAM_PADDING1 (LTTNG_UST_SYM_NAME_LEN + 32)
96 struct lttng_ust_stream
{
97 uint64_t len
; /* shm len */
98 uint32_t stream_nr
; /* stream number */
99 char padding
[LTTNG_UST_STREAM_PADDING1
];
101 * shm_fd and wakeup_fd are send over unix socket as file
102 * descriptors after this structure.
107 enum lttng_ust_counter_arithmetic
{
108 LTTNG_UST_COUNTER_ARITHMETIC_MODULAR
= 0,
109 LTTNG_UST_COUNTER_ARITHMETIC_SATURATION
= 1,
112 enum lttng_ust_counter_bitness
{
113 LTTNG_UST_COUNTER_BITNESS_32BITS
= 4,
114 LTTNG_UST_COUNTER_BITNESS_64BITS
= 8,
117 struct lttng_ust_counter_dimension
{
119 uint64_t underflow_index
;
120 uint64_t overflow_index
;
121 uint8_t has_underflow
;
122 uint8_t has_overflow
;
125 #define LTTNG_UST_COUNTER_DIMENSION_MAX 8
126 struct lttng_ust_counter_conf
{
127 uint32_t arithmetic
; /* enum lttng_ust_counter_arithmetic */
128 uint32_t bitness
; /* enum lttng_ust_counter_bitness */
129 uint32_t number_dimensions
;
130 int64_t global_sum_step
;
131 struct lttng_ust_counter_dimension dimensions
[LTTNG_UST_COUNTER_DIMENSION_MAX
];
134 struct lttng_ust_counter_value
{
135 uint32_t number_dimensions
;
136 uint64_t dimension_indexes
[LTTNG_UST_COUNTER_DIMENSION_MAX
];
140 #define LTTNG_UST_EVENT_PADDING1 8
141 #define LTTNG_UST_EVENT_PADDING2 (LTTNG_UST_SYM_NAME_LEN + 32)
142 struct lttng_ust_event
{
143 enum lttng_ust_instrumentation instrumentation
;
144 char name
[LTTNG_UST_SYM_NAME_LEN
]; /* event name */
146 enum lttng_ust_loglevel_type loglevel_type
;
147 int loglevel
; /* value, -1: all */
148 uint64_t token
; /* User-provided token */
149 char padding
[LTTNG_UST_EVENT_PADDING1
];
151 /* Per instrumentation type configuration */
153 char padding
[LTTNG_UST_EVENT_PADDING2
];
157 #define LTTNG_UST_EVENT_NOTIFIER_PADDING1 16
158 struct lttng_ust_event_notifier
{
159 struct lttng_ust_event event
;
160 uint64_t error_counter_index
;
161 char padding
[LTTNG_UST_EVENT_NOTIFIER_PADDING1
];
164 #define LTTNG_EVENT_NOTIFIER_NOTIFICATION_PADDING 32
165 struct lttng_ust_event_notifier_notification
{
167 uint16_t capture_buf_size
;
168 char padding
[LTTNG_EVENT_NOTIFIER_NOTIFICATION_PADDING
];
171 #define LTTNG_UST_COUNTER_PADDING1 (LTTNG_UST_SYM_NAME_LEN + 32)
172 #define LTTNG_UST_COUNTER_DATA_MAX_LEN 4096U
173 struct lttng_ust_counter
{
175 char padding
[LTTNG_UST_COUNTER_PADDING1
];
176 char data
[]; /* variable sized data */
179 #define LTTNG_UST_COUNTER_GLOBAL_PADDING1 (LTTNG_UST_SYM_NAME_LEN + 32)
180 struct lttng_ust_counter_global
{
181 uint64_t len
; /* shm len */
182 char padding
[LTTNG_UST_COUNTER_GLOBAL_PADDING1
];
185 #define LTTNG_UST_COUNTER_CPU_PADDING1 (LTTNG_UST_SYM_NAME_LEN + 32)
186 struct lttng_ust_counter_cpu
{
187 uint64_t len
; /* shm len */
189 char padding
[LTTNG_UST_COUNTER_CPU_PADDING1
];
192 enum lttng_ust_field_type
{
193 LTTNG_UST_FIELD_OTHER
= 0,
194 LTTNG_UST_FIELD_INTEGER
= 1,
195 LTTNG_UST_FIELD_ENUM
= 2,
196 LTTNG_UST_FIELD_FLOAT
= 3,
197 LTTNG_UST_FIELD_STRING
= 4,
200 #define LTTNG_UST_FIELD_ITER_PADDING (LTTNG_UST_SYM_NAME_LEN + 28)
201 struct lttng_ust_field_iter
{
202 char event_name
[LTTNG_UST_SYM_NAME_LEN
];
203 char field_name
[LTTNG_UST_SYM_NAME_LEN
];
204 enum lttng_ust_field_type type
;
205 int loglevel
; /* event loglevel */
207 char padding
[LTTNG_UST_FIELD_ITER_PADDING
];
210 enum lttng_ust_context_type
{
211 LTTNG_UST_CONTEXT_VTID
= 0,
212 LTTNG_UST_CONTEXT_VPID
= 1,
213 LTTNG_UST_CONTEXT_PTHREAD_ID
= 2,
214 LTTNG_UST_CONTEXT_PROCNAME
= 3,
215 LTTNG_UST_CONTEXT_IP
= 4,
216 LTTNG_UST_CONTEXT_PERF_THREAD_COUNTER
= 5,
217 LTTNG_UST_CONTEXT_CPU_ID
= 6,
218 LTTNG_UST_CONTEXT_APP_CONTEXT
= 7,
219 LTTNG_UST_CONTEXT_CGROUP_NS
= 8,
220 LTTNG_UST_CONTEXT_IPC_NS
= 9,
221 LTTNG_UST_CONTEXT_MNT_NS
= 10,
222 LTTNG_UST_CONTEXT_NET_NS
= 11,
223 LTTNG_UST_CONTEXT_PID_NS
= 12,
224 LTTNG_UST_CONTEXT_USER_NS
= 13,
225 LTTNG_UST_CONTEXT_UTS_NS
= 14,
226 LTTNG_UST_CONTEXT_VUID
= 15,
227 LTTNG_UST_CONTEXT_VEUID
= 16,
228 LTTNG_UST_CONTEXT_VSUID
= 17,
229 LTTNG_UST_CONTEXT_VGID
= 18,
230 LTTNG_UST_CONTEXT_VEGID
= 19,
231 LTTNG_UST_CONTEXT_VSGID
= 20,
232 LTTNG_UST_CONTEXT_TIME_NS
= 21,
235 struct lttng_ust_perf_counter_ctx
{
238 char name
[LTTNG_UST_SYM_NAME_LEN
];
241 #define LTTNG_UST_CONTEXT_PADDING1 16
242 #define LTTNG_UST_CONTEXT_PADDING2 (LTTNG_UST_SYM_NAME_LEN + 32)
243 struct lttng_ust_context
{
244 enum lttng_ust_context_type ctx
;
245 char padding
[LTTNG_UST_CONTEXT_PADDING1
];
248 struct lttng_ust_perf_counter_ctx perf_counter
;
250 /* Includes trailing '\0'. */
251 uint32_t provider_name_len
;
252 uint32_t ctx_name_len
;
254 char padding
[LTTNG_UST_CONTEXT_PADDING2
];
259 * Tracer channel attributes.
261 #define LTTNG_UST_CHANNEL_ATTR_PADDING (LTTNG_UST_SYM_NAME_LEN + 32)
262 struct lttng_ust_channel_attr
{
263 uint64_t subbuf_size
; /* bytes */
264 uint64_t num_subbuf
; /* power of 2 */
265 int overwrite
; /* 1: overwrite, 0: discard */
266 unsigned int switch_timer_interval
; /* usec */
267 unsigned int read_timer_interval
; /* usec */
268 enum lttng_ust_output output
; /* splice, mmap */
271 int64_t blocking_timeout
; /* Blocking timeout (usec) */
273 char padding
[LTTNG_UST_CHANNEL_ATTR_PADDING
];
277 #define LTTNG_UST_TRACEPOINT_ITER_PADDING 16
278 struct lttng_ust_tracepoint_iter
{
279 char name
[LTTNG_UST_SYM_NAME_LEN
]; /* provider:name */
281 char padding
[LTTNG_UST_TRACEPOINT_ITER_PADDING
];
284 enum lttng_ust_object_type
{
285 LTTNG_UST_OBJECT_TYPE_UNKNOWN
= -1,
286 LTTNG_UST_OBJECT_TYPE_CHANNEL
= 0,
287 LTTNG_UST_OBJECT_TYPE_STREAM
= 1,
288 LTTNG_UST_OBJECT_TYPE_EVENT
= 2,
289 LTTNG_UST_OBJECT_TYPE_CONTEXT
= 3,
290 LTTNG_UST_OBJECT_TYPE_EVENT_NOTIFIER_GROUP
= 4,
291 LTTNG_UST_OBJECT_TYPE_EVENT_NOTIFIER
= 5,
292 LTTNG_UST_OBJECT_TYPE_COUNTER
= 6,
293 LTTNG_UST_OBJECT_TYPE_COUNTER_GLOBAL
= 7,
294 LTTNG_UST_OBJECT_TYPE_COUNTER_CPU
= 8,
297 #define LTTNG_UST_OBJECT_DATA_PADDING1 32
298 #define LTTNG_UST_OBJECT_DATA_PADDING2 (LTTNG_UST_SYM_NAME_LEN + 32)
300 struct lttng_ust_object_data
{
301 enum lttng_ust_object_type type
;
304 char padding1
[LTTNG_UST_OBJECT_DATA_PADDING1
];
308 enum lttng_ust_chan_type type
;
326 char padding2
[LTTNG_UST_OBJECT_DATA_PADDING2
];
330 enum lttng_ust_calibrate_type
{
331 LTTNG_UST_CALIBRATE_TRACEPOINT
,
334 #define LTTNG_UST_CALIBRATE_PADDING1 16
335 #define LTTNG_UST_CALIBRATE_PADDING2 (LTTNG_UST_SYM_NAME_LEN + 32)
336 struct lttng_ust_calibrate
{
337 enum lttng_ust_calibrate_type type
; /* type (input) */
338 char padding
[LTTNG_UST_CALIBRATE_PADDING1
];
341 char padding
[LTTNG_UST_CALIBRATE_PADDING2
];
345 #define FILTER_BYTECODE_MAX_LEN 65536
346 #define LTTNG_UST_FILTER_PADDING 32
347 struct lttng_ust_filter_bytecode
{
349 uint32_t reloc_offset
;
351 char padding
[LTTNG_UST_FILTER_PADDING
];
355 #define CAPTURE_BYTECODE_MAX_LEN 65536
356 #define LTTNG_UST_CAPTURE_PADDING 32
357 struct lttng_ust_capture_bytecode
{
359 uint32_t reloc_offset
;
361 char padding
[LTTNG_UST_CAPTURE_PADDING
];
365 #define LTTNG_UST_EXCLUSION_PADDING 32
366 struct lttng_ust_event_exclusion
{
368 char padding
[LTTNG_UST_EXCLUSION_PADDING
];
369 char names
[LTTNG_UST_SYM_NAME_LEN
][0];
372 #define _UST_CMD(minor) (minor)
373 #define _UST_CMDR(minor, type) (minor)
374 #define _UST_CMDW(minor, type) (minor)
376 /* Handled by object descriptor */
377 #define LTTNG_UST_RELEASE _UST_CMD(0x1)
379 /* Handled by object cmd */
381 /* LTTng-UST commands */
382 #define LTTNG_UST_SESSION _UST_CMD(0x40)
383 #define LTTNG_UST_TRACER_VERSION \
384 _UST_CMDR(0x41, struct lttng_ust_tracer_version)
385 #define LTTNG_UST_TRACEPOINT_LIST _UST_CMD(0x42)
386 #define LTTNG_UST_WAIT_QUIESCENT _UST_CMD(0x43)
387 #define LTTNG_UST_REGISTER_DONE _UST_CMD(0x44)
388 #define LTTNG_UST_TRACEPOINT_FIELD_LIST _UST_CMD(0x45)
389 #define LTTNG_UST_EVENT_NOTIFIER_GROUP_CREATE _UST_CMD(0x46)
391 /* Session commands */
392 #define LTTNG_UST_CHANNEL \
393 _UST_CMDW(0x51, struct lttng_ust_channel)
394 #define LTTNG_UST_SESSION_START _UST_CMD(0x52)
395 #define LTTNG_UST_SESSION_STOP _UST_CMD(0x53)
396 #define LTTNG_UST_SESSION_STATEDUMP _UST_CMD(0x54)
398 /* Channel commands */
399 #define LTTNG_UST_STREAM _UST_CMD(0x60)
400 #define LTTNG_UST_EVENT \
401 _UST_CMDW(0x61, struct lttng_ust_event)
403 /* Event and channel commands */
404 #define LTTNG_UST_CONTEXT \
405 _UST_CMDW(0x70, struct lttng_ust_context)
406 #define LTTNG_UST_FLUSH_BUFFER \
409 /* Event, event notifier, channel and session commands */
410 #define LTTNG_UST_ENABLE _UST_CMD(0x80)
411 #define LTTNG_UST_DISABLE _UST_CMD(0x81)
413 /* Tracepoint list commands */
414 #define LTTNG_UST_TRACEPOINT_LIST_GET _UST_CMD(0x90)
415 #define LTTNG_UST_TRACEPOINT_FIELD_LIST_GET _UST_CMD(0x91)
417 /* Event and event notifier commands */
418 #define LTTNG_UST_FILTER _UST_CMD(0xA0)
419 #define LTTNG_UST_EXCLUSION _UST_CMD(0xA1)
421 /* Event notifier group commands */
422 #define LTTNG_UST_EVENT_NOTIFIER_CREATE \
423 _UST_CMDW(0xB0, struct lttng_ust_event_notifier)
425 /* Event notifier commands */
426 #define LTTNG_UST_CAPTURE _UST_CMD(0xB6)
428 /* Session and event notifier group commands */
429 #define LTTNG_UST_COUNTER \
430 _UST_CMDW(0xC0, struct lttng_ust_counter)
432 /* Counter commands */
433 #define LTTNG_UST_COUNTER_GLOBAL \
434 _UST_CMDW(0xD0, struct lttng_ust_counter_global)
435 #define LTTNG_UST_COUNTER_CPU \
436 _UST_CMDW(0xD1, struct lttng_ust_counter_cpu)
438 #define LTTNG_UST_ROOT_HANDLE 0
440 struct lttng_ust_obj
;
452 struct lttng_ust_field_iter entry
;
458 int event_notifier_notif_fd
;
459 } event_notifier_handle
;
468 struct lttng_ust_objd_ops
{
469 long (*cmd
)(int objd
, unsigned int cmd
, unsigned long arg
,
470 union ust_args
*args
, void *owner
);
471 int (*release
)(int objd
);
474 /* Create root handle. Always ID 0. */
475 int lttng_abi_create_root_handle(void);
477 const struct lttng_ust_objd_ops
*objd_ops(int id
);
478 int lttng_ust_objd_unref(int id
, int is_owner
);
480 void lttng_ust_abi_exit(void);
481 void lttng_ust_events_exit(void);
482 void lttng_ust_objd_table_owner_cleanup(void *owner
);
484 #endif /* _LTTNG_UST_ABI_H */