Commit | Line | Data |
---|---|---|
3bd1e081 MD |
1 | #ifndef _LTTNG_UST_ABI_H |
2 | #define _LTTNG_UST_ABI_H | |
3 | ||
4 | /* | |
9df8df5e | 5 | * lttng/ust-abi.h |
3bd1e081 | 6 | * |
3bd1e081 MD |
7 | * LTTng-UST ABI header |
8 | * | |
ab6a6569 | 9 | * Copyright 2010-2012 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com> |
3f3c65dc | 10 | * |
bf74a86d AM |
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. | |
bb719d46 DG |
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. | |
3bd1e081 MD |
28 | */ |
29 | ||
30 | #include <stdint.h> | |
bb719d46 | 31 | #include <common/macros.h> |
3bd1e081 | 32 | |
57ab7638 | 33 | #define LTTNG_UST_SYM_NAME_LEN 256 |
3bd1e081 | 34 | |
ab6a6569 | 35 | /* Version for comm protocol between sessiond and ust */ |
3f3c65dc | 36 | #define LTTNG_UST_COMM_VERSION_MAJOR 2 |
bb719d46 | 37 | #define LTTNG_UST_COMM_VERSION_MINOR 1 |
3bd1e081 | 38 | |
ab6a6569 DG |
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 | ||
3bd1e081 | 44 | enum lttng_ust_instrumentation { |
177f8533 MD |
45 | LTTNG_UST_TRACEPOINT = 0, |
46 | LTTNG_UST_PROBE = 1, | |
47 | LTTNG_UST_FUNCTION = 2, | |
0cda4f28 MD |
48 | }; |
49 | ||
50 | enum lttng_ust_loglevel_type { | |
8005f29a MD |
51 | LTTNG_UST_LOGLEVEL_ALL = 0, |
52 | LTTNG_UST_LOGLEVEL_RANGE = 1, | |
53 | LTTNG_UST_LOGLEVEL_SINGLE = 2, | |
3bd1e081 MD |
54 | }; |
55 | ||
56 | enum lttng_ust_output { | |
57 | LTTNG_UST_MMAP = 0, | |
58 | }; | |
59 | ||
60 | struct lttng_ust_tracer_version { | |
3f3c65dc MD |
61 | uint32_t major; |
62 | uint32_t minor; | |
3bd1e081 | 63 | uint32_t patchlevel; |
bb719d46 | 64 | } LTTNG_PACKED; |
3bd1e081 | 65 | |
3f3c65dc | 66 | #define LTTNG_UST_CHANNEL_PADDING LTTNG_UST_SYM_NAME_LEN + 32 |
3bd1e081 | 67 | struct lttng_ust_channel { |
3bd1e081 MD |
68 | uint64_t subbuf_size; /* in bytes */ |
69 | uint64_t num_subbuf; | |
6f30f9b8 | 70 | int overwrite; /* 1: overwrite, 0: discard */ |
3bd1e081 MD |
71 | unsigned int switch_timer_interval; /* usecs */ |
72 | unsigned int read_timer_interval; /* usecs */ | |
73 | enum lttng_ust_output output; /* output mode */ | |
3f3c65dc | 74 | char padding[LTTNG_UST_CHANNEL_PADDING]; |
bb719d46 | 75 | } LTTNG_PACKED; |
3f3c65dc MD |
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; | |
bb719d46 | 85 | } LTTNG_PACKED; |
3bd1e081 | 86 | |
3f3c65dc MD |
87 | #define LTTNG_UST_EVENT_PADDING1 16 |
88 | #define LTTNG_UST_EVENT_PADDING2 LTTNG_UST_SYM_NAME_LEN + 32 | |
3bd1e081 | 89 | struct lttng_ust_event { |
69892bbb | 90 | enum lttng_ust_instrumentation instrumentation; |
0cda4f28 MD |
91 | char name[LTTNG_UST_SYM_NAME_LEN]; /* event name */ |
92 | ||
93 | enum lttng_ust_loglevel_type loglevel_type; | |
8005f29a | 94 | int loglevel; /* value, -1: all */ |
3f3c65dc | 95 | char padding[LTTNG_UST_EVENT_PADDING1]; |
0cda4f28 | 96 | |
3bd1e081 MD |
97 | /* Per instrumentation type configuration */ |
98 | union { | |
3f3c65dc | 99 | char padding[LTTNG_UST_EVENT_PADDING2]; |
3bd1e081 | 100 | } u; |
bb719d46 | 101 | } LTTNG_PACKED; |
3bd1e081 | 102 | |
f214d69a MD |
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 | ||
ab6a6569 | 111 | #define LTTNG_UST_FIELD_ITER_PADDING LTTNG_UST_SYM_NAME_LEN + 28 |
f214d69a MD |
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 */ | |
590b9e3c | 117 | int nowrite; |
f214d69a | 118 | char padding[LTTNG_UST_FIELD_ITER_PADDING]; |
bb719d46 | 119 | } LTTNG_PACKED; |
f214d69a | 120 | |
3bd1e081 MD |
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 | ||
3f3c65dc MD |
128 | #define LTTNG_UST_CONTEXT_PADDING1 16 |
129 | #define LTTNG_UST_CONTEXT_PADDING2 LTTNG_UST_SYM_NAME_LEN + 32 | |
3bd1e081 MD |
130 | struct lttng_ust_context { |
131 | enum lttng_ust_context_type ctx; | |
3f3c65dc MD |
132 | char padding[LTTNG_UST_CONTEXT_PADDING1]; |
133 | ||
3bd1e081 | 134 | union { |
3f3c65dc | 135 | char padding[LTTNG_UST_CONTEXT_PADDING2]; |
3bd1e081 | 136 | } u; |
bb719d46 | 137 | } LTTNG_PACKED; |
3bd1e081 | 138 | |
13161846 DG |
139 | /* |
140 | * Tracer channel attributes. | |
141 | */ | |
3f3c65dc | 142 | #define LTTNG_UST_CHANNEL_ATTR_PADDING LTTNG_UST_SYM_NAME_LEN + 32 |
13161846 | 143 | struct lttng_ust_channel_attr { |
13161846 DG |
144 | uint64_t subbuf_size; /* bytes */ |
145 | uint64_t num_subbuf; /* power of 2 */ | |
6f30f9b8 | 146 | int overwrite; /* 1: overwrite, 0: discard */ |
13161846 DG |
147 | unsigned int switch_timer_interval; /* usec */ |
148 | unsigned int read_timer_interval; /* usec */ | |
149 | enum lttng_ust_output output; /* splice, mmap */ | |
3f3c65dc | 150 | char padding[LTTNG_UST_CHANNEL_ATTR_PADDING]; |
bb719d46 | 151 | } LTTNG_PACKED; |
13161846 | 152 | |
3f3c65dc | 153 | #define LTTNG_UST_TRACEPOINT_ITER_PADDING 16 |
177f8533 MD |
154 | struct lttng_ust_tracepoint_iter { |
155 | char name[LTTNG_UST_SYM_NAME_LEN]; /* provider:name */ | |
8005f29a | 156 | int loglevel; |
3f3c65dc | 157 | char padding[LTTNG_UST_TRACEPOINT_ITER_PADDING]; |
bb719d46 | 158 | } LTTNG_PACKED; |
177f8533 | 159 | |
3f3c65dc | 160 | #define LTTNG_UST_OBJECT_DATA_PADDING LTTNG_UST_SYM_NAME_LEN + 32 |
13161846 | 161 | struct lttng_ust_object_data { |
bb719d46 | 162 | uint64_t memory_map_size; |
13161846 DG |
163 | int handle; |
164 | int shm_fd; | |
165 | int wait_fd; | |
3f3c65dc | 166 | char padding[LTTNG_UST_OBJECT_DATA_PADDING]; |
bb719d46 | 167 | } LTTNG_PACKED; |
13161846 | 168 | |
f7e1a950 DG |
169 | enum lttng_ust_calibrate_type { |
170 | LTTNG_UST_CALIBRATE_TRACEPOINT, | |
171 | }; | |
172 | ||
3f3c65dc MD |
173 | #define LTTNG_UST_CALIBRATE_PADDING1 16 |
174 | #define LTTNG_UST_CALIBRATE_PADDING2 LTTNG_UST_SYM_NAME_LEN + 32 | |
f7e1a950 | 175 | struct lttng_ust_calibrate { |
3f3c65dc MD |
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; | |
bb719d46 | 182 | } LTTNG_PACKED; |
f7e1a950 | 183 | |
d93c4f1f | 184 | #define FILTER_BYTECODE_MAX_LEN 65536 |
b6bbed5f | 185 | #define LTTNG_UST_FILTER_PADDING 32 |
53a80697 | 186 | struct lttng_ust_filter_bytecode { |
d93c4f1f CB |
187 | uint32_t len; |
188 | uint32_t reloc_offset; | |
b6bbed5f DG |
189 | uint64_t seqnum; |
190 | char padding[LTTNG_UST_FILTER_PADDING]; | |
53a80697 | 191 | char data[0]; |
bb719d46 | 192 | } LTTNG_PACKED; |
53a80697 | 193 | |
3bd1e081 MD |
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) | |
f214d69a | 210 | #define LTTNG_UST_TRACEPOINT_FIELD_LIST _UST_CMD(0x45) |
3bd1e081 MD |
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) | |
2bdd86d4 MD |
228 | #define LTTNG_UST_FLUSH_BUFFER \ |
229 | _UST_CMD(0x71) | |
3bd1e081 MD |
230 | |
231 | /* Event, Channel and Session commands */ | |
232 | #define LTTNG_UST_ENABLE _UST_CMD(0x80) | |
233 | #define LTTNG_UST_DISABLE _UST_CMD(0x81) | |
234 | ||
8ec2d32a MD |
235 | /* Tracepoint list commands */ |
236 | #define LTTNG_UST_TRACEPOINT_LIST_GET _UST_CMD(0x90) | |
f214d69a | 237 | #define LTTNG_UST_TRACEPOINT_FIELD_LIST_GET _UST_CMD(0x91) |
8ec2d32a | 238 | |
ab6a6569 DG |
239 | /* Event FD commands */ |
240 | #define LTTNG_UST_FILTER _UST_CMD(0xA0) | |
241 | ||
3bd1e081 MD |
242 | #define LTTNG_UST_ROOT_HANDLE 0 |
243 | ||
9df8df5e | 244 | struct lttng_ust_obj; |
3bd1e081 | 245 | |
18cef803 MD |
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; | |
da0bdb87 MD |
257 | struct { |
258 | struct lttng_ust_field_iter entry; | |
259 | } field_list; | |
18cef803 MD |
260 | }; |
261 | ||
9df8df5e | 262 | struct lttng_ust_objd_ops { |
18cef803 | 263 | long (*cmd)(int objd, unsigned int cmd, unsigned long arg, |
bb719d46 | 264 | union ust_args *args, void *owner); |
3bd1e081 MD |
265 | int (*release)(int objd); |
266 | }; | |
267 | ||
268 | /* Create root handle. Always ID 0. */ | |
269 | int lttng_abi_create_root_handle(void); | |
270 | ||
9df8df5e DG |
271 | const struct lttng_ust_objd_ops *objd_ops(int id); |
272 | int lttng_ust_objd_unref(int id); | |
3bd1e081 MD |
273 | |
274 | void lttng_ust_abi_exit(void); | |
9df8df5e | 275 | void lttng_ust_events_exit(void); |
bb719d46 | 276 | void lttng_ust_objd_table_owner_cleanup(void *owner); |
3bd1e081 MD |
277 | |
278 | #endif /* _LTTNG_UST_ABI_H */ |