Fix: update to latest UST abi
[lttng-tools.git] / src / bin / lttng-sessiond / lttng-ust-abi.h
1 #ifndef _LTTNG_UST_ABI_H
2 #define _LTTNG_UST_ABI_H
3
4 /*
5 * lttng/ust-abi.h
6 *
7 * LTTng-UST ABI header
8 *
9 * Copyright 2010-2012 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
10 *
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:
17 *
18 * The above copyright notice and this permission notice shall be included in
19 * all copies or substantial portions of the Software.
20 *
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
27 * SOFTWARE.
28 */
29
30 #include <stdint.h>
31 #include <common/macros.h>
32
33 #define LTTNG_UST_SYM_NAME_LEN 256
34
35 /* Version for comm protocol between sessiond and ust */
36 #define LTTNG_UST_COMM_VERSION_MAJOR 2
37 #define LTTNG_UST_COMM_VERSION_MINOR 1
38
39 /* Version for ABI between liblttng-ust, sessiond, consumerd */
40 #define LTTNG_UST_INTERNAL_MAJOR_VERSION 3
41 #define LTTNG_UST_INTERNAL_MINOR_VERSION 0
42 #define LTTNG_UST_INTERNAL_PATCHLEVEL_VERSION 0
43
44 enum lttng_ust_instrumentation {
45 LTTNG_UST_TRACEPOINT = 0,
46 LTTNG_UST_PROBE = 1,
47 LTTNG_UST_FUNCTION = 2,
48 };
49
50 enum lttng_ust_loglevel_type {
51 LTTNG_UST_LOGLEVEL_ALL = 0,
52 LTTNG_UST_LOGLEVEL_RANGE = 1,
53 LTTNG_UST_LOGLEVEL_SINGLE = 2,
54 };
55
56 enum lttng_ust_output {
57 LTTNG_UST_MMAP = 0,
58 };
59
60 struct lttng_ust_tracer_version {
61 uint32_t major;
62 uint32_t minor;
63 uint32_t patchlevel;
64 } LTTNG_PACKED;
65
66 #define LTTNG_UST_CHANNEL_PADDING LTTNG_UST_SYM_NAME_LEN + 32
67 struct lttng_ust_channel {
68 uint64_t subbuf_size; /* in bytes */
69 uint64_t num_subbuf;
70 int overwrite; /* 1: overwrite, 0: discard */
71 unsigned int switch_timer_interval; /* usecs */
72 unsigned int read_timer_interval; /* usecs */
73 enum lttng_ust_output output; /* output mode */
74 char padding[LTTNG_UST_CHANNEL_PADDING];
75 } LTTNG_PACKED;
76
77 #define LTTNG_UST_STREAM_PADDING1 16
78 #define LTTNG_UST_STREAM_PADDING2 LTTNG_UST_SYM_NAME_LEN + 32
79 struct lttng_ust_stream {
80 char padding[LTTNG_UST_STREAM_PADDING1];
81
82 union {
83 char padding[LTTNG_UST_STREAM_PADDING2];
84 } u;
85 } LTTNG_PACKED;
86
87 #define LTTNG_UST_EVENT_PADDING1 16
88 #define LTTNG_UST_EVENT_PADDING2 LTTNG_UST_SYM_NAME_LEN + 32
89 struct lttng_ust_event {
90 enum lttng_ust_instrumentation instrumentation;
91 char name[LTTNG_UST_SYM_NAME_LEN]; /* event name */
92
93 enum lttng_ust_loglevel_type loglevel_type;
94 int loglevel; /* value, -1: all */
95 char padding[LTTNG_UST_EVENT_PADDING1];
96
97 /* Per instrumentation type configuration */
98 union {
99 char padding[LTTNG_UST_EVENT_PADDING2];
100 } u;
101 } LTTNG_PACKED;
102
103 enum lttng_ust_field_type {
104 LTTNG_UST_FIELD_OTHER = 0,
105 LTTNG_UST_FIELD_INTEGER = 1,
106 LTTNG_UST_FIELD_ENUM = 2,
107 LTTNG_UST_FIELD_FLOAT = 3,
108 LTTNG_UST_FIELD_STRING = 4,
109 };
110
111 #define LTTNG_UST_FIELD_ITER_PADDING LTTNG_UST_SYM_NAME_LEN + 28
112 struct lttng_ust_field_iter {
113 char event_name[LTTNG_UST_SYM_NAME_LEN];
114 char field_name[LTTNG_UST_SYM_NAME_LEN];
115 enum lttng_ust_field_type type;
116 int loglevel; /* event loglevel */
117 int nowrite;
118 char padding[LTTNG_UST_FIELD_ITER_PADDING];
119 } LTTNG_PACKED;
120
121 enum lttng_ust_context_type {
122 LTTNG_UST_CONTEXT_VTID = 0,
123 LTTNG_UST_CONTEXT_VPID = 1,
124 LTTNG_UST_CONTEXT_PTHREAD_ID = 2,
125 LTTNG_UST_CONTEXT_PROCNAME = 3,
126 };
127
128 #define LTTNG_UST_CONTEXT_PADDING1 16
129 #define LTTNG_UST_CONTEXT_PADDING2 LTTNG_UST_SYM_NAME_LEN + 32
130 struct lttng_ust_context {
131 enum lttng_ust_context_type ctx;
132 char padding[LTTNG_UST_CONTEXT_PADDING1];
133
134 union {
135 char padding[LTTNG_UST_CONTEXT_PADDING2];
136 } u;
137 } LTTNG_PACKED;
138
139 /*
140 * Tracer channel attributes.
141 */
142 #define LTTNG_UST_CHANNEL_ATTR_PADDING LTTNG_UST_SYM_NAME_LEN + 32
143 struct lttng_ust_channel_attr {
144 uint64_t subbuf_size; /* bytes */
145 uint64_t num_subbuf; /* power of 2 */
146 int overwrite; /* 1: overwrite, 0: discard */
147 unsigned int switch_timer_interval; /* usec */
148 unsigned int read_timer_interval; /* usec */
149 enum lttng_ust_output output; /* splice, mmap */
150 char padding[LTTNG_UST_CHANNEL_ATTR_PADDING];
151 } LTTNG_PACKED;
152
153 #define LTTNG_UST_TRACEPOINT_ITER_PADDING 16
154 struct lttng_ust_tracepoint_iter {
155 char name[LTTNG_UST_SYM_NAME_LEN]; /* provider:name */
156 int loglevel;
157 char padding[LTTNG_UST_TRACEPOINT_ITER_PADDING];
158 } LTTNG_PACKED;
159
160 #define LTTNG_UST_OBJECT_DATA_PADDING LTTNG_UST_SYM_NAME_LEN + 32
161 struct lttng_ust_object_data {
162 uint64_t memory_map_size;
163 int handle;
164 int shm_fd;
165 int wait_fd;
166 char padding[LTTNG_UST_OBJECT_DATA_PADDING];
167 } LTTNG_PACKED;
168
169 enum lttng_ust_calibrate_type {
170 LTTNG_UST_CALIBRATE_TRACEPOINT,
171 };
172
173 #define LTTNG_UST_CALIBRATE_PADDING1 16
174 #define LTTNG_UST_CALIBRATE_PADDING2 LTTNG_UST_SYM_NAME_LEN + 32
175 struct lttng_ust_calibrate {
176 enum lttng_ust_calibrate_type type; /* type (input) */
177 char padding[LTTNG_UST_CALIBRATE_PADDING1];
178
179 union {
180 char padding[LTTNG_UST_CALIBRATE_PADDING2];
181 } u;
182 } LTTNG_PACKED;
183
184 #define FILTER_BYTECODE_MAX_LEN 65536
185 #define LTTNG_UST_FILTER_PADDING 32
186 struct lttng_ust_filter_bytecode {
187 uint32_t len;
188 uint32_t reloc_offset;
189 uint64_t seqnum;
190 char padding[LTTNG_UST_FILTER_PADDING];
191 char data[0];
192 } LTTNG_PACKED;
193
194 #define _UST_CMD(minor) (minor)
195 #define _UST_CMDR(minor, type) (minor)
196 #define _UST_CMDW(minor, type) (minor)
197
198 /* Handled by object descriptor */
199 #define LTTNG_UST_RELEASE _UST_CMD(0x1)
200
201 /* Handled by object cmd */
202
203 /* LTTng-UST commands */
204 #define LTTNG_UST_SESSION _UST_CMD(0x40)
205 #define LTTNG_UST_TRACER_VERSION \
206 _UST_CMDR(0x41, struct lttng_ust_tracer_version)
207 #define LTTNG_UST_TRACEPOINT_LIST _UST_CMD(0x42)
208 #define LTTNG_UST_WAIT_QUIESCENT _UST_CMD(0x43)
209 #define LTTNG_UST_REGISTER_DONE _UST_CMD(0x44)
210 #define LTTNG_UST_TRACEPOINT_FIELD_LIST _UST_CMD(0x45)
211
212 /* Session FD commands */
213 #define LTTNG_UST_METADATA \
214 _UST_CMDW(0x50, struct lttng_ust_channel)
215 #define LTTNG_UST_CHANNEL \
216 _UST_CMDW(0x51, struct lttng_ust_channel)
217 #define LTTNG_UST_SESSION_START _UST_CMD(0x52)
218 #define LTTNG_UST_SESSION_STOP _UST_CMD(0x53)
219
220 /* Channel FD commands */
221 #define LTTNG_UST_STREAM _UST_CMD(0x60)
222 #define LTTNG_UST_EVENT \
223 _UST_CMDW(0x61, struct lttng_ust_event)
224
225 /* Event and Channel FD commands */
226 #define LTTNG_UST_CONTEXT \
227 _UST_CMDW(0x70, struct lttng_ust_context)
228 #define LTTNG_UST_FLUSH_BUFFER \
229 _UST_CMD(0x71)
230
231 /* Event, Channel and Session commands */
232 #define LTTNG_UST_ENABLE _UST_CMD(0x80)
233 #define LTTNG_UST_DISABLE _UST_CMD(0x81)
234
235 /* Tracepoint list commands */
236 #define LTTNG_UST_TRACEPOINT_LIST_GET _UST_CMD(0x90)
237 #define LTTNG_UST_TRACEPOINT_FIELD_LIST_GET _UST_CMD(0x91)
238
239 /* Event FD commands */
240 #define LTTNG_UST_FILTER _UST_CMD(0xA0)
241
242 #define LTTNG_UST_ROOT_HANDLE 0
243
244 struct lttng_ust_obj;
245
246 union ust_args {
247 struct {
248 int *shm_fd;
249 int *wait_fd;
250 uint64_t *memory_map_size;
251 } channel;
252 struct {
253 int *shm_fd;
254 int *wait_fd;
255 uint64_t *memory_map_size;
256 } stream;
257 struct {
258 struct lttng_ust_field_iter entry;
259 } field_list;
260 };
261
262 struct lttng_ust_objd_ops {
263 long (*cmd)(int objd, unsigned int cmd, unsigned long arg,
264 union ust_args *args, void *owner);
265 int (*release)(int objd);
266 };
267
268 /* Create root handle. Always ID 0. */
269 int lttng_abi_create_root_handle(void);
270
271 const struct lttng_ust_objd_ops *objd_ops(int id);
272 int lttng_ust_objd_unref(int id);
273
274 void lttng_ust_abi_exit(void);
275 void lttng_ust_events_exit(void);
276 void lttng_ust_objd_table_owner_cleanup(void *owner);
277
278 #endif /* _LTTNG_UST_ABI_H */
This page took 0.054439 seconds and 4 git commands to generate.