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