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