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