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 | |
44d3bd01 DG |
23 | #include "trace-ust.h" |
24 | ||
e0c7ec2b | 25 | /* lttng-ust supported version. */ |
3f2c5fcc | 26 | #define LTTNG_UST_COMM_MAJOR 2 /* comm protocol major version */ |
68264071 | 27 | #define UST_APP_MAJOR_VERSION 3 /* Internal UST version supported */ |
e0c7ec2b | 28 | |
b551a063 DG |
29 | #define UST_APP_EVENT_LIST_SIZE 32 |
30 | ||
53a80697 MD |
31 | struct lttng_filter_bytecode; |
32 | struct lttng_ust_filter_bytecode; | |
33 | ||
7753dea8 | 34 | extern int ust_consumerd64_fd, ust_consumerd32_fd; |
ba5d816e | 35 | |
18eace3b DG |
36 | struct ust_app_ht_key { |
37 | const char *name; | |
38 | const struct lttng_ust_filter_bytecode *filter; | |
39 | enum lttng_ust_loglevel_type loglevel; | |
40 | }; | |
41 | ||
099e26bd DG |
42 | /* |
43 | * Application registration data structure. | |
44 | */ | |
45 | struct ust_register_msg { | |
46 | uint32_t major; | |
47 | uint32_t minor; | |
48 | pid_t pid; | |
49 | pid_t ppid; | |
50 | uid_t uid; | |
51 | gid_t gid; | |
0df502fd | 52 | uint32_t bits_per_long; |
099e26bd DG |
53 | char name[16]; |
54 | }; | |
55 | ||
48842b30 | 56 | /* |
852d0037 DG |
57 | * Global applications HT used by the session daemon. This table is indexed by |
58 | * PID using the pid_n node and pid value of an ust_app. | |
48842b30 | 59 | */ |
bec39940 | 60 | struct lttng_ht *ust_app_ht; |
f6a9efaa | 61 | |
852d0037 DG |
62 | /* |
63 | * Global applications HT used by the session daemon. This table is indexed by | |
64 | * socket using the sock_n node and sock value of an ust_app. | |
65 | */ | |
66 | struct lttng_ht *ust_app_ht_by_sock; | |
91d76f53 | 67 | |
55cc08a6 DG |
68 | struct ust_app_ctx { |
69 | int handle; | |
70 | struct lttng_ust_context ctx; | |
71 | struct lttng_ust_object_data *obj; | |
bec39940 | 72 | struct lttng_ht_node_ulong node; |
55cc08a6 DG |
73 | }; |
74 | ||
48842b30 DG |
75 | struct ust_app_event { |
76 | int enabled; | |
77 | int handle; | |
13161846 | 78 | struct lttng_ust_object_data *obj; |
284d8f55 | 79 | struct lttng_ust_event attr; |
48842b30 | 80 | char name[LTTNG_UST_SYM_NAME_LEN]; |
bec39940 | 81 | struct lttng_ht_node_str node; |
53a80697 | 82 | struct lttng_ust_filter_bytecode *filter; |
48842b30 DG |
83 | }; |
84 | ||
85 | struct ust_app_channel { | |
86 | int enabled; | |
87 | int handle; | |
88 | char name[LTTNG_UST_SYM_NAME_LEN]; | |
89 | struct lttng_ust_channel attr; | |
13161846 | 90 | struct lttng_ust_object_data *obj; |
5af2f756 | 91 | struct ltt_ust_stream_list streams; |
bec39940 DG |
92 | struct lttng_ht *ctx; |
93 | struct lttng_ht *events; | |
94 | struct lttng_ht_node_str node; | |
48842b30 DG |
95 | }; |
96 | ||
97 | struct ust_app_session { | |
98 | int enabled; | |
8be98f9a MD |
99 | /* started: has the session been in started state at any time ? */ |
100 | int started; /* allows detection of start vs restart. */ | |
a991f516 MD |
101 | int handle; /* used has unique identifier for app session */ |
102 | int id; /* session unique identifier */ | |
48842b30 | 103 | struct ltt_ust_metadata *metadata; |
bec39940 DG |
104 | struct lttng_ht *channels; /* Registered channels */ |
105 | struct lttng_ht_node_ulong node; | |
106 | char path[PATH_MAX]; | |
6df2e2c9 MD |
107 | /* UID/GID of the user owning the session */ |
108 | uid_t uid; | |
109 | gid_t gid; | |
48842b30 DG |
110 | }; |
111 | ||
f6a9efaa DG |
112 | /* |
113 | * Registered traceable applications. Libust registers to the session daemon | |
050349bb | 114 | * and a linked list is kept of all running traceable app. |
91d76f53 | 115 | */ |
56fff090 | 116 | struct ust_app { |
852d0037 DG |
117 | int sock; |
118 | pid_t pid; | |
099e26bd DG |
119 | pid_t ppid; |
120 | uid_t uid; /* User ID that owns the apps */ | |
aea829b3 | 121 | gid_t gid; /* Group ID that owns the apps */ |
7753dea8 | 122 | int bits_per_long; |
e0c7ec2b DG |
123 | int compatible; /* If the lttng-ust tracer version does not match the |
124 | supported version of the session daemon, this flag is | |
125 | set to 0 (NOT compatible) else 1. */ | |
126 | struct lttng_ust_tracer_version version; | |
099e26bd DG |
127 | uint32_t v_major; /* Verion major number */ |
128 | uint32_t v_minor; /* Verion minor number */ | |
129 | char name[17]; /* Process name (short) */ | |
bec39940 | 130 | struct lttng_ht *sessions; |
852d0037 DG |
131 | struct lttng_ht_node_ulong pid_n; |
132 | struct lttng_ht_node_ulong sock_n; | |
91d76f53 DG |
133 | }; |
134 | ||
74d0b642 | 135 | #ifdef HAVE_LIBLTTNG_UST_CTL |
3bd1e081 | 136 | |
56fff090 | 137 | int ust_app_register(struct ust_register_msg *msg, int sock); |
f2ca2e25 GF |
138 | static inline |
139 | int ust_app_register_done(int sock) | |
140 | { | |
141 | return ustctl_register_done(sock); | |
142 | } | |
56fff090 | 143 | void ust_app_unregister(int sock); |
f6a9efaa | 144 | unsigned long ust_app_list_count(void); |
421cb601 | 145 | int ust_app_start_trace(struct ltt_ust_session *usess, struct ust_app *app); |
8be98f9a | 146 | int ust_app_stop_trace(struct ltt_ust_session *usess, struct ust_app *app); |
421cb601 | 147 | int ust_app_start_trace_all(struct ltt_ust_session *usess); |
8be98f9a | 148 | int ust_app_stop_trace_all(struct ltt_ust_session *usess); |
84cd17c6 MD |
149 | int ust_app_destroy_trace(struct ltt_ust_session *usess, struct ust_app *app); |
150 | int ust_app_destroy_trace_all(struct ltt_ust_session *usess); | |
b551a063 | 151 | int ust_app_list_events(struct lttng_event **events); |
f37d259d | 152 | int ust_app_list_event_fields(struct lttng_event_field **fields); |
35a9059d DG |
153 | int ust_app_create_channel_glb(struct ltt_ust_session *usess, |
154 | struct ltt_ust_channel *uchan); | |
155 | int ust_app_create_event_glb(struct ltt_ust_session *usess, | |
156 | struct ltt_ust_channel *uchan, struct ltt_ust_event *uevent); | |
7f79d3a1 DG |
157 | int ust_app_disable_event_pid(struct ltt_ust_session *usess, |
158 | struct ltt_ust_channel *uchan, struct ltt_ust_event *uevent, | |
159 | pid_t pid); | |
76d45b40 DG |
160 | int ust_app_enable_event_pid(struct ltt_ust_session *usess, |
161 | struct ltt_ust_channel *uchan, struct ltt_ust_event *uevent, | |
162 | pid_t pid); | |
35a9059d | 163 | int ust_app_disable_channel_glb(struct ltt_ust_session *usess, |
78f0bacd | 164 | struct ltt_ust_channel *uchan); |
35a9059d | 165 | int ust_app_enable_channel_glb(struct ltt_ust_session *usess, |
78f0bacd | 166 | struct ltt_ust_channel *uchan); |
35a9059d | 167 | int ust_app_enable_event_glb(struct ltt_ust_session *usess, |
edb67388 | 168 | struct ltt_ust_channel *uchan, struct ltt_ust_event *uevent); |
35a9059d DG |
169 | int ust_app_disable_all_event_glb(struct ltt_ust_session *usess, |
170 | struct ltt_ust_channel *uchan); | |
171 | int ust_app_enable_all_event_glb(struct ltt_ust_session *usess, | |
9730260e | 172 | struct ltt_ust_channel *uchan); |
35a9059d DG |
173 | int ust_app_disable_event_glb(struct ltt_ust_session *usess, |
174 | struct ltt_ust_channel *uchan, struct ltt_ust_event *uevent); | |
55cc08a6 DG |
175 | int ust_app_add_ctx_channel_glb(struct ltt_ust_session *usess, |
176 | struct ltt_ust_channel *uchan, struct ltt_ust_context *uctx); | |
53a80697 MD |
177 | int ust_app_set_filter_event_glb(struct ltt_ust_session *usess, |
178 | struct ltt_ust_channel *uchan, struct ltt_ust_event *uevent, | |
179 | struct lttng_filter_bytecode *bytecode); | |
487cf67c | 180 | void ust_app_global_update(struct ltt_ust_session *usess, int sock); |
91d76f53 | 181 | |
56fff090 | 182 | void ust_app_clean_list(void); |
f6a9efaa | 183 | void ust_app_ht_alloc(void); |
bec39940 | 184 | struct lttng_ht *ust_app_get_ht(void); |
f6a9efaa | 185 | struct ust_app *ust_app_find_by_pid(pid_t pid); |
e0c7ec2b | 186 | int ust_app_validate_version(int sock); |
4466912f | 187 | int ust_app_calibrate_glb(struct lttng_ust_calibrate *calibrate); |
44d3bd01 | 188 | |
74d0b642 | 189 | #else /* HAVE_LIBLTTNG_UST_CTL */ |
3bd1e081 | 190 | |
cc920def DG |
191 | static inline |
192 | int ust_app_destroy_trace_all(struct ltt_ust_session *usess) | |
193 | { | |
194 | return 0; | |
195 | } | |
d974f197 | 196 | static inline |
421cb601 DG |
197 | int ust_app_start_trace(struct ltt_ust_session *usess, struct ust_app *app) |
198 | { | |
199 | return 0; | |
200 | } | |
201 | static inline | |
202 | int ust_app_start_trace_all(struct ltt_ust_session *usess) | |
d974f197 | 203 | { |
5cf5d0e7 | 204 | return 0; |
d974f197 | 205 | } |
3bd1e081 | 206 | static inline |
cc920def DG |
207 | int ust_app_stop_trace_all(struct ltt_ust_session *usess) |
208 | { | |
209 | return 0; | |
210 | } | |
211 | static inline | |
b551a063 DG |
212 | int ust_app_list_events(struct lttng_event **events) |
213 | { | |
db7c0497 | 214 | return -ENOSYS; |
b551a063 DG |
215 | } |
216 | static inline | |
da0bdb87 MD |
217 | int ust_app_list_event_fields(struct lttng_event_field **fields) |
218 | { | |
219 | return -ENOSYS; | |
220 | } | |
221 | static inline | |
3bd1e081 MD |
222 | int ust_app_register(struct ust_register_msg *msg, int sock) |
223 | { | |
224 | return -ENOSYS; | |
225 | } | |
226 | static inline | |
f2ca2e25 GF |
227 | int ust_app_register_done(int sock) |
228 | { | |
229 | return -ENOSYS; | |
230 | } | |
231 | static inline | |
3bd1e081 MD |
232 | void ust_app_unregister(int sock) |
233 | { | |
234 | } | |
235 | static inline | |
236 | unsigned int ust_app_list_count(void) | |
237 | { | |
238 | return 0; | |
239 | } | |
3bd1e081 MD |
240 | static inline |
241 | void ust_app_lock_list(void) | |
242 | { | |
243 | } | |
244 | static inline | |
245 | void ust_app_unlock_list(void) | |
246 | { | |
247 | } | |
248 | static inline | |
249 | void ust_app_clean_list(void) | |
250 | { | |
251 | } | |
252 | static inline | |
253 | struct ust_app_list *ust_app_get_list(void) | |
254 | { | |
255 | return NULL; | |
256 | } | |
257 | static inline | |
258 | struct ust_app *ust_app_get_by_pid(pid_t pid) | |
259 | { | |
260 | return NULL; | |
261 | } | |
48842b30 | 262 | static inline |
bec39940 | 263 | struct lttng_ht *ust_app_get_ht(void) |
d974f197 DG |
264 | { |
265 | return NULL; | |
266 | } | |
267 | static inline | |
268 | void ust_app_ht_alloc(void) | |
cc920def DG |
269 | {} |
270 | static inline | |
271 | void ust_app_global_update(struct ltt_ust_session *usess, int sock) | |
272 | {} | |
273 | static inline | |
35a9059d | 274 | int ust_app_disable_channel_glb(struct ltt_ust_session *usess, |
cc920def | 275 | struct ltt_ust_channel *uchan) |
d974f197 | 276 | { |
cc920def | 277 | return 0; |
d974f197 | 278 | } |
487cf67c | 279 | static inline |
35a9059d | 280 | int ust_app_enable_channel_glb(struct ltt_ust_session *usess, |
cc920def | 281 | struct ltt_ust_channel *uchan) |
487cf67c | 282 | { |
cc920def DG |
283 | return 0; |
284 | } | |
285 | static inline | |
35a9059d | 286 | int ust_app_create_channel_glb(struct ltt_ust_session *usess, |
cc920def DG |
287 | struct ltt_ust_channel *uchan) |
288 | { | |
289 | return 0; | |
290 | } | |
291 | static inline | |
35a9059d DG |
292 | int ust_app_disable_all_event_glb(struct ltt_ust_session *usess, |
293 | struct ltt_ust_channel *uchan) | |
cc920def DG |
294 | { |
295 | return 0; | |
296 | } | |
297 | static inline | |
35a9059d | 298 | int ust_app_enable_all_event_glb(struct ltt_ust_session *usess, |
cc920def DG |
299 | struct ltt_ust_channel *uchan) |
300 | { | |
301 | return 0; | |
302 | } | |
303 | static inline | |
35a9059d DG |
304 | int ust_app_create_event_glb(struct ltt_ust_session *usess, |
305 | struct ltt_ust_channel *uchan, struct ltt_ust_event *uevent) | |
306 | { | |
307 | return 0; | |
308 | } | |
309 | static inline | |
310 | int ust_app_disable_event_glb(struct ltt_ust_session *usess, | |
cc920def DG |
311 | struct ltt_ust_channel *uchan, struct ltt_ust_event *uevent) |
312 | { | |
313 | return 0; | |
487cf67c | 314 | } |
edb67388 | 315 | static inline |
35a9059d | 316 | int ust_app_enable_event_glb(struct ltt_ust_session *usess, |
edb67388 DG |
317 | struct ltt_ust_channel *uchan, struct ltt_ust_event *uevent) |
318 | { | |
319 | return 0; | |
320 | } | |
55cc08a6 | 321 | static inline |
55cc08a6 DG |
322 | int ust_app_add_ctx_channel_glb(struct ltt_ust_session *usess, |
323 | struct ltt_ust_channel *uchan, struct ltt_ust_context *uctx) | |
324 | { | |
325 | return 0; | |
326 | } | |
76d45b40 DG |
327 | static inline |
328 | int ust_app_enable_event_pid(struct ltt_ust_session *usess, | |
329 | struct ltt_ust_channel *uchan, struct ltt_ust_event *uevent, | |
330 | pid_t pid) | |
331 | { | |
332 | return 0; | |
333 | } | |
7f79d3a1 DG |
334 | static inline |
335 | int ust_app_disable_event_pid(struct ltt_ust_session *usess, | |
336 | struct ltt_ust_channel *uchan, struct ltt_ust_event *uevent, | |
337 | pid_t pid) | |
338 | { | |
339 | return 0; | |
340 | } | |
e0c7ec2b DG |
341 | static inline |
342 | int ust_app_validate_version(int sock) | |
343 | { | |
344 | return 0; | |
345 | } | |
4466912f DG |
346 | static inline |
347 | int ust_app_calibrate_glb(struct lttng_ust_calibrate *calibrate) | |
348 | { | |
349 | return 0; | |
350 | } | |
cc04e512 DG |
351 | static inline |
352 | int ust_app_set_filter_event_glb(struct ltt_ust_session *usess, | |
353 | struct ltt_ust_channel *uchan, struct ltt_ust_event *uevent, | |
354 | struct lttng_filter_bytecode *bytecode) | |
355 | { | |
356 | return 0; | |
357 | } | |
48842b30 | 358 | |
74d0b642 | 359 | #endif /* HAVE_LIBLTTNG_UST_CTL */ |
3bd1e081 | 360 | |
f6a9efaa | 361 | #endif /* _LTT_UST_APP_H */ |