Commit | Line | Data |
---|---|---|
91d76f53 DG |
1 | /* |
2 | * Copyright (C) 2011 - David Goulet <david.goulet@polymtl.ca> | |
3 | * | |
d14d33bf AM |
4 | * This program is free software; you can redistribute it and/or modify |
5 | * it under the terms of the GNU General Public License, version 2 only, | |
6 | * as published by the Free Software Foundation. | |
91d76f53 DG |
7 | * |
8 | * This program is distributed in the hope that it will be useful, | |
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
11 | * GNU General Public License for more details. | |
12 | * | |
d14d33bf AM |
13 | * You should have received a copy of the GNU General Public License along |
14 | * with this program; if not, write to the Free Software Foundation, Inc., | |
15 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | |
91d76f53 DG |
16 | */ |
17 | ||
f6a9efaa DG |
18 | #ifndef _LTT_UST_APP_H |
19 | #define _LTT_UST_APP_H | |
91d76f53 | 20 | |
099e26bd | 21 | #include <stdint.h> |
1e307fab | 22 | |
ffe60014 | 23 | #include <common/compat/uuid.h> |
44d3bd01 DG |
24 | #include "trace-ust.h" |
25 | ||
e0c7ec2b | 26 | /* lttng-ust supported version. */ |
3f2c5fcc | 27 | #define LTTNG_UST_COMM_MAJOR 2 /* comm protocol major version */ |
68264071 | 28 | #define UST_APP_MAJOR_VERSION 3 /* Internal UST version supported */ |
e0c7ec2b | 29 | |
b551a063 DG |
30 | #define UST_APP_EVENT_LIST_SIZE 32 |
31 | ||
53a80697 MD |
32 | struct lttng_filter_bytecode; |
33 | struct lttng_ust_filter_bytecode; | |
34 | ||
7753dea8 | 35 | extern int ust_consumerd64_fd, ust_consumerd32_fd; |
ba5d816e | 36 | |
18eace3b DG |
37 | struct ust_app_ht_key { |
38 | const char *name; | |
39 | const struct lttng_ust_filter_bytecode *filter; | |
40 | enum lttng_ust_loglevel_type loglevel; | |
41 | }; | |
42 | ||
099e26bd DG |
43 | /* |
44 | * Application registration data structure. | |
45 | */ | |
46 | struct ust_register_msg { | |
47 | uint32_t major; | |
48 | uint32_t minor; | |
49 | pid_t pid; | |
50 | pid_t ppid; | |
51 | uid_t uid; | |
52 | gid_t gid; | |
0df502fd | 53 | uint32_t bits_per_long; |
099e26bd DG |
54 | char name[16]; |
55 | }; | |
56 | ||
48842b30 | 57 | /* |
852d0037 DG |
58 | * Global applications HT used by the session daemon. This table is indexed by |
59 | * PID using the pid_n node and pid value of an ust_app. | |
48842b30 | 60 | */ |
bec39940 | 61 | struct lttng_ht *ust_app_ht; |
f6a9efaa | 62 | |
852d0037 DG |
63 | /* |
64 | * Global applications HT used by the session daemon. This table is indexed by | |
65 | * socket using the sock_n node and sock value of an ust_app. | |
66 | */ | |
67 | struct lttng_ht *ust_app_ht_by_sock; | |
91d76f53 | 68 | |
030a66fa DG |
69 | /* Stream list containing ust_app_stream. */ |
70 | struct ust_app_stream_list { | |
71 | unsigned int count; | |
72 | struct cds_list_head head; | |
73 | }; | |
74 | ||
55cc08a6 DG |
75 | struct ust_app_ctx { |
76 | int handle; | |
77 | struct lttng_ust_context ctx; | |
78 | struct lttng_ust_object_data *obj; | |
bec39940 | 79 | struct lttng_ht_node_ulong node; |
55cc08a6 DG |
80 | }; |
81 | ||
48842b30 DG |
82 | struct ust_app_event { |
83 | int enabled; | |
84 | int handle; | |
13161846 | 85 | struct lttng_ust_object_data *obj; |
284d8f55 | 86 | struct lttng_ust_event attr; |
48842b30 | 87 | char name[LTTNG_UST_SYM_NAME_LEN]; |
bec39940 | 88 | struct lttng_ht_node_str node; |
53a80697 | 89 | struct lttng_ust_filter_bytecode *filter; |
48842b30 DG |
90 | }; |
91 | ||
030a66fa DG |
92 | struct ust_app_stream { |
93 | int handle; | |
94 | char pathname[PATH_MAX]; | |
95 | /* Format is %s_%d respectively channel name and CPU number. */ | |
96 | char name[DEFAULT_STREAM_NAME_LEN]; | |
97 | struct lttng_ust_object_data *obj; | |
98 | /* Using a list of streams to keep order. */ | |
99 | struct cds_list_head list; | |
ffe60014 | 100 | struct ustctl_consumer_stream *ustream; |
030a66fa DG |
101 | }; |
102 | ||
48842b30 DG |
103 | struct ust_app_channel { |
104 | int enabled; | |
105 | int handle; | |
ffe60014 DG |
106 | /* Channel and streams were sent to the UST tracer. */ |
107 | int is_sent; | |
108 | /* Unique key used to identify the channel on the consumer side. */ | |
109 | unsigned long key; | |
110 | /* Number of stream that this channel is expected to receive. */ | |
111 | unsigned int expected_stream_count; | |
48842b30 | 112 | char name[LTTNG_UST_SYM_NAME_LEN]; |
13161846 | 113 | struct lttng_ust_object_data *obj; |
ffe60014 DG |
114 | struct ustctl_consumer_channel_attr attr; |
115 | struct ustctl_consumer_channel *channel; | |
030a66fa | 116 | struct ust_app_stream_list streams; |
bec39940 DG |
117 | struct lttng_ht *ctx; |
118 | struct lttng_ht *events; | |
119 | struct lttng_ht_node_str node; | |
48842b30 DG |
120 | }; |
121 | ||
122 | struct ust_app_session { | |
123 | int enabled; | |
8be98f9a MD |
124 | /* started: has the session been in started state at any time ? */ |
125 | int started; /* allows detection of start vs restart. */ | |
a991f516 MD |
126 | int handle; /* used has unique identifier for app session */ |
127 | int id; /* session unique identifier */ | |
ffe60014 | 128 | struct ust_app_channel *metadata; |
bec39940 DG |
129 | struct lttng_ht *channels; /* Registered channels */ |
130 | struct lttng_ht_node_ulong node; | |
131 | char path[PATH_MAX]; | |
6df2e2c9 MD |
132 | /* UID/GID of the user owning the session */ |
133 | uid_t uid; | |
134 | gid_t gid; | |
d42f20df | 135 | struct cds_list_head teardown_node; |
ffe60014 DG |
136 | /* Universal unique identifier used by the tracer. */ |
137 | unsigned char uuid[UUID_STR_LEN]; | |
48842b30 DG |
138 | }; |
139 | ||
f6a9efaa DG |
140 | /* |
141 | * Registered traceable applications. Libust registers to the session daemon | |
050349bb | 142 | * and a linked list is kept of all running traceable app. |
91d76f53 | 143 | */ |
56fff090 | 144 | struct ust_app { |
852d0037 DG |
145 | int sock; |
146 | pid_t pid; | |
099e26bd DG |
147 | pid_t ppid; |
148 | uid_t uid; /* User ID that owns the apps */ | |
aea829b3 | 149 | gid_t gid; /* Group ID that owns the apps */ |
7753dea8 | 150 | int bits_per_long; |
e0c7ec2b DG |
151 | int compatible; /* If the lttng-ust tracer version does not match the |
152 | supported version of the session daemon, this flag is | |
153 | set to 0 (NOT compatible) else 1. */ | |
154 | struct lttng_ust_tracer_version version; | |
099e26bd DG |
155 | uint32_t v_major; /* Verion major number */ |
156 | uint32_t v_minor; /* Verion minor number */ | |
157 | char name[17]; /* Process name (short) */ | |
bec39940 | 158 | struct lttng_ht *sessions; |
852d0037 DG |
159 | struct lttng_ht_node_ulong pid_n; |
160 | struct lttng_ht_node_ulong sock_n; | |
d42f20df DG |
161 | /* |
162 | * This is a list of ust app session that, once the app is going into | |
163 | * teardown mode, in the RCU call, each node in this list is removed and | |
164 | * deleted. | |
165 | * | |
166 | * Element of the list are added when an application unregisters after each | |
167 | * ht_del of ust_app_session associated to this app. This list is NOT used | |
168 | * when a session is destroyed. | |
169 | */ | |
170 | struct cds_list_head teardown_head; | |
91d76f53 DG |
171 | }; |
172 | ||
74d0b642 | 173 | #ifdef HAVE_LIBLTTNG_UST_CTL |
3bd1e081 | 174 | |
56fff090 | 175 | int ust_app_register(struct ust_register_msg *msg, int sock); |
f2ca2e25 GF |
176 | static inline |
177 | int ust_app_register_done(int sock) | |
178 | { | |
179 | return ustctl_register_done(sock); | |
180 | } | |
56fff090 | 181 | void ust_app_unregister(int sock); |
f6a9efaa | 182 | unsigned long ust_app_list_count(void); |
421cb601 | 183 | int ust_app_start_trace(struct ltt_ust_session *usess, struct ust_app *app); |
8be98f9a | 184 | int ust_app_stop_trace(struct ltt_ust_session *usess, struct ust_app *app); |
421cb601 | 185 | int ust_app_start_trace_all(struct ltt_ust_session *usess); |
8be98f9a | 186 | int ust_app_stop_trace_all(struct ltt_ust_session *usess); |
84cd17c6 | 187 | int ust_app_destroy_trace_all(struct ltt_ust_session *usess); |
b551a063 | 188 | int ust_app_list_events(struct lttng_event **events); |
f37d259d | 189 | int ust_app_list_event_fields(struct lttng_event_field **fields); |
35a9059d DG |
190 | int ust_app_create_channel_glb(struct ltt_ust_session *usess, |
191 | struct ltt_ust_channel *uchan); | |
192 | int ust_app_create_event_glb(struct ltt_ust_session *usess, | |
193 | struct ltt_ust_channel *uchan, struct ltt_ust_event *uevent); | |
7f79d3a1 DG |
194 | int ust_app_disable_event_pid(struct ltt_ust_session *usess, |
195 | struct ltt_ust_channel *uchan, struct ltt_ust_event *uevent, | |
196 | pid_t pid); | |
76d45b40 DG |
197 | int ust_app_enable_event_pid(struct ltt_ust_session *usess, |
198 | struct ltt_ust_channel *uchan, struct ltt_ust_event *uevent, | |
199 | pid_t pid); | |
35a9059d | 200 | int ust_app_disable_channel_glb(struct ltt_ust_session *usess, |
78f0bacd | 201 | struct ltt_ust_channel *uchan); |
35a9059d | 202 | int ust_app_enable_channel_glb(struct ltt_ust_session *usess, |
78f0bacd | 203 | struct ltt_ust_channel *uchan); |
35a9059d | 204 | int ust_app_enable_event_glb(struct ltt_ust_session *usess, |
edb67388 | 205 | struct ltt_ust_channel *uchan, struct ltt_ust_event *uevent); |
35a9059d DG |
206 | int ust_app_disable_all_event_glb(struct ltt_ust_session *usess, |
207 | struct ltt_ust_channel *uchan); | |
208 | int ust_app_enable_all_event_glb(struct ltt_ust_session *usess, | |
9730260e | 209 | struct ltt_ust_channel *uchan); |
35a9059d DG |
210 | int ust_app_disable_event_glb(struct ltt_ust_session *usess, |
211 | struct ltt_ust_channel *uchan, struct ltt_ust_event *uevent); | |
55cc08a6 DG |
212 | int ust_app_add_ctx_channel_glb(struct ltt_ust_session *usess, |
213 | struct ltt_ust_channel *uchan, struct ltt_ust_context *uctx); | |
487cf67c | 214 | void ust_app_global_update(struct ltt_ust_session *usess, int sock); |
91d76f53 | 215 | |
56fff090 | 216 | void ust_app_clean_list(void); |
f6a9efaa | 217 | void ust_app_ht_alloc(void); |
bec39940 | 218 | struct lttng_ht *ust_app_get_ht(void); |
f6a9efaa | 219 | struct ust_app *ust_app_find_by_pid(pid_t pid); |
e0c7ec2b | 220 | int ust_app_validate_version(int sock); |
4466912f | 221 | int ust_app_calibrate_glb(struct lttng_ust_calibrate *calibrate); |
ffe60014 | 222 | struct ust_app_stream *ust_app_alloc_stream(void); |
44d3bd01 | 223 | |
74d0b642 | 224 | #else /* HAVE_LIBLTTNG_UST_CTL */ |
3bd1e081 | 225 | |
cc920def DG |
226 | static inline |
227 | int ust_app_destroy_trace_all(struct ltt_ust_session *usess) | |
228 | { | |
229 | return 0; | |
230 | } | |
d974f197 | 231 | static inline |
421cb601 DG |
232 | int ust_app_start_trace(struct ltt_ust_session *usess, struct ust_app *app) |
233 | { | |
234 | return 0; | |
235 | } | |
236 | static inline | |
237 | int ust_app_start_trace_all(struct ltt_ust_session *usess) | |
d974f197 | 238 | { |
5cf5d0e7 | 239 | return 0; |
d974f197 | 240 | } |
3bd1e081 | 241 | static inline |
cc920def DG |
242 | int ust_app_stop_trace_all(struct ltt_ust_session *usess) |
243 | { | |
244 | return 0; | |
245 | } | |
246 | static inline | |
b551a063 DG |
247 | int ust_app_list_events(struct lttng_event **events) |
248 | { | |
db7c0497 | 249 | return -ENOSYS; |
b551a063 DG |
250 | } |
251 | static inline | |
da0bdb87 MD |
252 | int ust_app_list_event_fields(struct lttng_event_field **fields) |
253 | { | |
254 | return -ENOSYS; | |
255 | } | |
256 | static inline | |
3bd1e081 MD |
257 | int ust_app_register(struct ust_register_msg *msg, int sock) |
258 | { | |
259 | return -ENOSYS; | |
260 | } | |
261 | static inline | |
f2ca2e25 GF |
262 | int ust_app_register_done(int sock) |
263 | { | |
264 | return -ENOSYS; | |
265 | } | |
266 | static inline | |
3bd1e081 MD |
267 | void ust_app_unregister(int sock) |
268 | { | |
269 | } | |
270 | static inline | |
271 | unsigned int ust_app_list_count(void) | |
272 | { | |
273 | return 0; | |
274 | } | |
3bd1e081 MD |
275 | static inline |
276 | void ust_app_lock_list(void) | |
277 | { | |
278 | } | |
279 | static inline | |
280 | void ust_app_unlock_list(void) | |
281 | { | |
282 | } | |
283 | static inline | |
284 | void ust_app_clean_list(void) | |
285 | { | |
286 | } | |
287 | static inline | |
288 | struct ust_app_list *ust_app_get_list(void) | |
289 | { | |
290 | return NULL; | |
291 | } | |
292 | static inline | |
293 | struct ust_app *ust_app_get_by_pid(pid_t pid) | |
294 | { | |
295 | return NULL; | |
296 | } | |
48842b30 | 297 | static inline |
bec39940 | 298 | struct lttng_ht *ust_app_get_ht(void) |
d974f197 DG |
299 | { |
300 | return NULL; | |
301 | } | |
302 | static inline | |
303 | void ust_app_ht_alloc(void) | |
cc920def DG |
304 | {} |
305 | static inline | |
306 | void ust_app_global_update(struct ltt_ust_session *usess, int sock) | |
307 | {} | |
308 | static inline | |
35a9059d | 309 | int ust_app_disable_channel_glb(struct ltt_ust_session *usess, |
cc920def | 310 | struct ltt_ust_channel *uchan) |
d974f197 | 311 | { |
cc920def | 312 | return 0; |
d974f197 | 313 | } |
487cf67c | 314 | static inline |
35a9059d | 315 | int ust_app_enable_channel_glb(struct ltt_ust_session *usess, |
cc920def | 316 | struct ltt_ust_channel *uchan) |
487cf67c | 317 | { |
cc920def DG |
318 | return 0; |
319 | } | |
320 | static inline | |
35a9059d | 321 | int ust_app_create_channel_glb(struct ltt_ust_session *usess, |
cc920def DG |
322 | struct ltt_ust_channel *uchan) |
323 | { | |
324 | return 0; | |
325 | } | |
326 | static inline | |
35a9059d DG |
327 | int ust_app_disable_all_event_glb(struct ltt_ust_session *usess, |
328 | struct ltt_ust_channel *uchan) | |
cc920def DG |
329 | { |
330 | return 0; | |
331 | } | |
332 | static inline | |
35a9059d | 333 | int ust_app_enable_all_event_glb(struct ltt_ust_session *usess, |
cc920def DG |
334 | struct ltt_ust_channel *uchan) |
335 | { | |
336 | return 0; | |
337 | } | |
338 | static inline | |
35a9059d DG |
339 | int ust_app_create_event_glb(struct ltt_ust_session *usess, |
340 | struct ltt_ust_channel *uchan, struct ltt_ust_event *uevent) | |
341 | { | |
342 | return 0; | |
343 | } | |
344 | static inline | |
345 | int ust_app_disable_event_glb(struct ltt_ust_session *usess, | |
cc920def DG |
346 | struct ltt_ust_channel *uchan, struct ltt_ust_event *uevent) |
347 | { | |
348 | return 0; | |
487cf67c | 349 | } |
edb67388 | 350 | static inline |
35a9059d | 351 | int ust_app_enable_event_glb(struct ltt_ust_session *usess, |
edb67388 DG |
352 | struct ltt_ust_channel *uchan, struct ltt_ust_event *uevent) |
353 | { | |
354 | return 0; | |
355 | } | |
55cc08a6 | 356 | static inline |
55cc08a6 DG |
357 | int ust_app_add_ctx_channel_glb(struct ltt_ust_session *usess, |
358 | struct ltt_ust_channel *uchan, struct ltt_ust_context *uctx) | |
359 | { | |
360 | return 0; | |
361 | } | |
76d45b40 DG |
362 | static inline |
363 | int ust_app_enable_event_pid(struct ltt_ust_session *usess, | |
364 | struct ltt_ust_channel *uchan, struct ltt_ust_event *uevent, | |
365 | pid_t pid) | |
366 | { | |
367 | return 0; | |
368 | } | |
7f79d3a1 DG |
369 | static inline |
370 | int ust_app_disable_event_pid(struct ltt_ust_session *usess, | |
371 | struct ltt_ust_channel *uchan, struct ltt_ust_event *uevent, | |
372 | pid_t pid) | |
373 | { | |
374 | return 0; | |
375 | } | |
e0c7ec2b DG |
376 | static inline |
377 | int ust_app_validate_version(int sock) | |
378 | { | |
379 | return 0; | |
380 | } | |
4466912f DG |
381 | static inline |
382 | int ust_app_calibrate_glb(struct lttng_ust_calibrate *calibrate) | |
383 | { | |
384 | return 0; | |
385 | } | |
48842b30 | 386 | |
74d0b642 | 387 | #endif /* HAVE_LIBLTTNG_UST_CTL */ |
3bd1e081 | 388 | |
f6a9efaa | 389 | #endif /* _LTT_UST_APP_H */ |