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