Commit | Line | Data |
---|---|---|
91d76f53 DG |
1 | /* |
2 | * Copyright (C) 2011 - David Goulet <david.goulet@polymtl.ca> | |
3 | * | |
4 | * This program is free software; you can redistribute it and/or | |
5 | * modify it under the terms of the GNU General Public License | |
82a3637f DG |
6 | * as published by the Free Software Foundation; only version 2 |
7 | * of the License. | |
91d76f53 DG |
8 | * |
9 | * This program is distributed in the hope that it will be useful, | |
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | * GNU General Public License for more details. | |
13 | * | |
14 | * You should have received a copy of the GNU General Public License | |
15 | * along with this program; if not, write to the Free Software | |
16 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |
17 | */ | |
18 | ||
f6a9efaa DG |
19 | #ifndef _LTT_UST_APP_H |
20 | #define _LTT_UST_APP_H | |
91d76f53 | 21 | |
099e26bd | 22 | #include <stdint.h> |
1e307fab | 23 | |
44d3bd01 DG |
24 | #include "trace-ust.h" |
25 | ||
e0c7ec2b DG |
26 | /* lttng-ust supported version. */ |
27 | #define UST_APP_MAJOR_VERSION 1 | |
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 DG |
47 | /* |
48 | * Global applications HT used by the session daemon. | |
49 | */ | |
bec39940 | 50 | struct lttng_ht *ust_app_ht; |
f6a9efaa | 51 | |
bec39940 | 52 | struct lttng_ht *ust_app_sock_key_map; |
f6a9efaa DG |
53 | |
54 | struct ust_app_key { | |
55 | pid_t pid; | |
56 | int sock; | |
bec39940 | 57 | struct lttng_ht_node_ulong node; |
91d76f53 DG |
58 | }; |
59 | ||
55cc08a6 DG |
60 | struct ust_app_ctx { |
61 | int handle; | |
62 | struct lttng_ust_context ctx; | |
63 | struct lttng_ust_object_data *obj; | |
bec39940 | 64 | struct lttng_ht_node_ulong node; |
55cc08a6 DG |
65 | }; |
66 | ||
48842b30 DG |
67 | struct ust_app_event { |
68 | int enabled; | |
69 | int handle; | |
13161846 | 70 | struct lttng_ust_object_data *obj; |
284d8f55 | 71 | struct lttng_ust_event attr; |
48842b30 | 72 | char name[LTTNG_UST_SYM_NAME_LEN]; |
bec39940 DG |
73 | struct lttng_ht *ctx; |
74 | struct lttng_ht_node_str node; | |
48842b30 DG |
75 | }; |
76 | ||
77 | struct ust_app_channel { | |
78 | int enabled; | |
79 | int handle; | |
80 | char name[LTTNG_UST_SYM_NAME_LEN]; | |
81 | struct lttng_ust_channel attr; | |
13161846 | 82 | struct lttng_ust_object_data *obj; |
5af2f756 | 83 | struct ltt_ust_stream_list streams; |
bec39940 DG |
84 | struct lttng_ht *ctx; |
85 | struct lttng_ht *events; | |
86 | struct lttng_ht_node_str node; | |
48842b30 DG |
87 | }; |
88 | ||
89 | struct ust_app_session { | |
90 | int enabled; | |
8be98f9a MD |
91 | /* started: has the session been in started state at any time ? */ |
92 | int started; /* allows detection of start vs restart. */ | |
a991f516 MD |
93 | int handle; /* used has unique identifier for app session */ |
94 | int id; /* session unique identifier */ | |
48842b30 | 95 | struct ltt_ust_metadata *metadata; |
bec39940 DG |
96 | struct lttng_ht *channels; /* Registered channels */ |
97 | struct lttng_ht_node_ulong node; | |
98 | char path[PATH_MAX]; | |
6df2e2c9 MD |
99 | /* UID/GID of the user owning the session */ |
100 | uid_t uid; | |
101 | gid_t gid; | |
48842b30 DG |
102 | }; |
103 | ||
f6a9efaa DG |
104 | /* |
105 | * Registered traceable applications. Libust registers to the session daemon | |
050349bb | 106 | * and a linked list is kept of all running traceable app. |
91d76f53 | 107 | */ |
56fff090 | 108 | struct ust_app { |
099e26bd DG |
109 | pid_t ppid; |
110 | uid_t uid; /* User ID that owns the apps */ | |
aea829b3 | 111 | gid_t gid; /* Group ID that owns the apps */ |
7753dea8 | 112 | int bits_per_long; |
e0c7ec2b DG |
113 | int compatible; /* If the lttng-ust tracer version does not match the |
114 | supported version of the session daemon, this flag is | |
115 | set to 0 (NOT compatible) else 1. */ | |
116 | struct lttng_ust_tracer_version version; | |
099e26bd DG |
117 | uint32_t v_major; /* Verion major number */ |
118 | uint32_t v_minor; /* Verion minor number */ | |
119 | char name[17]; /* Process name (short) */ | |
bec39940 DG |
120 | struct lttng_ht *sessions; |
121 | struct lttng_ht_node_ulong node; | |
f6a9efaa | 122 | struct ust_app_key key; |
91d76f53 DG |
123 | }; |
124 | ||
74d0b642 | 125 | #ifdef HAVE_LIBLTTNG_UST_CTL |
3bd1e081 | 126 | |
56fff090 | 127 | int ust_app_register(struct ust_register_msg *msg, int sock); |
f2ca2e25 GF |
128 | static inline |
129 | int ust_app_register_done(int sock) | |
130 | { | |
131 | return ustctl_register_done(sock); | |
132 | } | |
56fff090 | 133 | void ust_app_unregister(int sock); |
f6a9efaa | 134 | unsigned long ust_app_list_count(void); |
421cb601 | 135 | int ust_app_start_trace(struct ltt_ust_session *usess, struct ust_app *app); |
8be98f9a | 136 | int ust_app_stop_trace(struct ltt_ust_session *usess, struct ust_app *app); |
421cb601 | 137 | int ust_app_start_trace_all(struct ltt_ust_session *usess); |
8be98f9a | 138 | int ust_app_stop_trace_all(struct ltt_ust_session *usess); |
84cd17c6 MD |
139 | int ust_app_destroy_trace(struct ltt_ust_session *usess, struct ust_app *app); |
140 | int ust_app_destroy_trace_all(struct ltt_ust_session *usess); | |
b551a063 | 141 | int ust_app_list_events(struct lttng_event **events); |
35a9059d DG |
142 | int ust_app_create_channel_glb(struct ltt_ust_session *usess, |
143 | struct ltt_ust_channel *uchan); | |
144 | int ust_app_create_event_glb(struct ltt_ust_session *usess, | |
145 | struct ltt_ust_channel *uchan, struct ltt_ust_event *uevent); | |
7f79d3a1 DG |
146 | int ust_app_disable_event_pid(struct ltt_ust_session *usess, |
147 | struct ltt_ust_channel *uchan, struct ltt_ust_event *uevent, | |
148 | pid_t pid); | |
76d45b40 DG |
149 | int ust_app_enable_event_pid(struct ltt_ust_session *usess, |
150 | struct ltt_ust_channel *uchan, struct ltt_ust_event *uevent, | |
151 | pid_t pid); | |
35a9059d | 152 | int ust_app_disable_channel_glb(struct ltt_ust_session *usess, |
78f0bacd | 153 | struct ltt_ust_channel *uchan); |
35a9059d | 154 | int ust_app_enable_channel_glb(struct ltt_ust_session *usess, |
78f0bacd | 155 | struct ltt_ust_channel *uchan); |
35a9059d | 156 | int ust_app_enable_event_glb(struct ltt_ust_session *usess, |
edb67388 | 157 | struct ltt_ust_channel *uchan, struct ltt_ust_event *uevent); |
35a9059d DG |
158 | int ust_app_disable_all_event_glb(struct ltt_ust_session *usess, |
159 | struct ltt_ust_channel *uchan); | |
160 | int ust_app_enable_all_event_glb(struct ltt_ust_session *usess, | |
9730260e | 161 | struct ltt_ust_channel *uchan); |
35a9059d DG |
162 | int ust_app_disable_event_glb(struct ltt_ust_session *usess, |
163 | struct ltt_ust_channel *uchan, struct ltt_ust_event *uevent); | |
55cc08a6 DG |
164 | int ust_app_add_ctx_event_glb(struct ltt_ust_session *usess, |
165 | struct ltt_ust_channel *uchan, struct ltt_ust_event *uevent, | |
166 | struct ltt_ust_context *uctx); | |
167 | int ust_app_add_ctx_channel_glb(struct ltt_ust_session *usess, | |
168 | struct ltt_ust_channel *uchan, struct ltt_ust_context *uctx); | |
487cf67c | 169 | void ust_app_global_update(struct ltt_ust_session *usess, int sock); |
91d76f53 | 170 | |
56fff090 | 171 | void ust_app_clean_list(void); |
f6a9efaa | 172 | void ust_app_ht_alloc(void); |
bec39940 | 173 | struct lttng_ht *ust_app_get_ht(void); |
f6a9efaa | 174 | struct ust_app *ust_app_find_by_pid(pid_t pid); |
e0c7ec2b | 175 | int ust_app_validate_version(int sock); |
44d3bd01 | 176 | |
74d0b642 | 177 | #else /* HAVE_LIBLTTNG_UST_CTL */ |
3bd1e081 | 178 | |
cc920def DG |
179 | static inline |
180 | int ust_app_destroy_trace_all(struct ltt_ust_session *usess) | |
181 | { | |
182 | return 0; | |
183 | } | |
d974f197 | 184 | static inline |
421cb601 DG |
185 | int ust_app_start_trace(struct ltt_ust_session *usess, struct ust_app *app) |
186 | { | |
187 | return 0; | |
188 | } | |
189 | static inline | |
190 | int ust_app_start_trace_all(struct ltt_ust_session *usess) | |
d974f197 | 191 | { |
5cf5d0e7 | 192 | return 0; |
d974f197 | 193 | } |
3bd1e081 | 194 | static inline |
cc920def DG |
195 | int ust_app_stop_trace_all(struct ltt_ust_session *usess) |
196 | { | |
197 | return 0; | |
198 | } | |
199 | static inline | |
b551a063 DG |
200 | int ust_app_list_events(struct lttng_event **events) |
201 | { | |
202 | return 0; | |
203 | } | |
204 | static inline | |
3bd1e081 MD |
205 | int ust_app_register(struct ust_register_msg *msg, int sock) |
206 | { | |
207 | return -ENOSYS; | |
208 | } | |
209 | static inline | |
f2ca2e25 GF |
210 | int ust_app_register_done(int sock) |
211 | { | |
212 | return -ENOSYS; | |
213 | } | |
214 | static inline | |
3bd1e081 MD |
215 | void ust_app_unregister(int sock) |
216 | { | |
217 | } | |
218 | static inline | |
219 | unsigned int ust_app_list_count(void) | |
220 | { | |
221 | return 0; | |
222 | } | |
3bd1e081 MD |
223 | static inline |
224 | void ust_app_lock_list(void) | |
225 | { | |
226 | } | |
227 | static inline | |
228 | void ust_app_unlock_list(void) | |
229 | { | |
230 | } | |
231 | static inline | |
232 | void ust_app_clean_list(void) | |
233 | { | |
234 | } | |
235 | static inline | |
236 | struct ust_app_list *ust_app_get_list(void) | |
237 | { | |
238 | return NULL; | |
239 | } | |
240 | static inline | |
241 | struct ust_app *ust_app_get_by_pid(pid_t pid) | |
242 | { | |
243 | return NULL; | |
244 | } | |
48842b30 | 245 | static inline |
bec39940 | 246 | struct lttng_ht *ust_app_get_ht(void) |
d974f197 DG |
247 | { |
248 | return NULL; | |
249 | } | |
250 | static inline | |
251 | void ust_app_ht_alloc(void) | |
cc920def DG |
252 | {} |
253 | static inline | |
254 | void ust_app_global_update(struct ltt_ust_session *usess, int sock) | |
255 | {} | |
256 | static inline | |
35a9059d | 257 | int ust_app_disable_channel_glb(struct ltt_ust_session *usess, |
cc920def | 258 | struct ltt_ust_channel *uchan) |
d974f197 | 259 | { |
cc920def | 260 | return 0; |
d974f197 | 261 | } |
487cf67c | 262 | static inline |
35a9059d | 263 | int ust_app_enable_channel_glb(struct ltt_ust_session *usess, |
cc920def | 264 | struct ltt_ust_channel *uchan) |
487cf67c | 265 | { |
cc920def DG |
266 | return 0; |
267 | } | |
268 | static inline | |
35a9059d | 269 | int ust_app_create_channel_glb(struct ltt_ust_session *usess, |
cc920def DG |
270 | struct ltt_ust_channel *uchan) |
271 | { | |
272 | return 0; | |
273 | } | |
274 | static inline | |
35a9059d DG |
275 | int ust_app_disable_all_event_glb(struct ltt_ust_session *usess, |
276 | struct ltt_ust_channel *uchan) | |
cc920def DG |
277 | { |
278 | return 0; | |
279 | } | |
280 | static inline | |
35a9059d | 281 | int ust_app_enable_all_event_glb(struct ltt_ust_session *usess, |
cc920def DG |
282 | struct ltt_ust_channel *uchan) |
283 | { | |
284 | return 0; | |
285 | } | |
286 | static inline | |
35a9059d DG |
287 | int ust_app_create_event_glb(struct ltt_ust_session *usess, |
288 | struct ltt_ust_channel *uchan, struct ltt_ust_event *uevent) | |
289 | { | |
290 | return 0; | |
291 | } | |
292 | static inline | |
293 | int ust_app_disable_event_glb(struct ltt_ust_session *usess, | |
cc920def DG |
294 | struct ltt_ust_channel *uchan, struct ltt_ust_event *uevent) |
295 | { | |
296 | return 0; | |
487cf67c | 297 | } |
edb67388 | 298 | static inline |
35a9059d | 299 | int ust_app_enable_event_glb(struct ltt_ust_session *usess, |
edb67388 DG |
300 | struct ltt_ust_channel *uchan, struct ltt_ust_event *uevent) |
301 | { | |
302 | return 0; | |
303 | } | |
55cc08a6 DG |
304 | static inline |
305 | int ust_app_add_ctx_event_glb(struct ltt_ust_session *usess, | |
306 | struct ltt_ust_channel *uchan, struct ltt_ust_event *uevent, | |
307 | struct ltt_ust_context *uctx) | |
308 | { | |
309 | return 0; | |
310 | } | |
311 | static inline | |
312 | int ust_app_add_ctx_channel_glb(struct ltt_ust_session *usess, | |
313 | struct ltt_ust_channel *uchan, struct ltt_ust_context *uctx) | |
314 | { | |
315 | return 0; | |
316 | } | |
76d45b40 DG |
317 | static inline |
318 | int ust_app_enable_event_pid(struct ltt_ust_session *usess, | |
319 | struct ltt_ust_channel *uchan, struct ltt_ust_event *uevent, | |
320 | pid_t pid) | |
321 | { | |
322 | return 0; | |
323 | } | |
7f79d3a1 DG |
324 | static inline |
325 | int ust_app_disable_event_pid(struct ltt_ust_session *usess, | |
326 | struct ltt_ust_channel *uchan, struct ltt_ust_event *uevent, | |
327 | pid_t pid) | |
328 | { | |
329 | return 0; | |
330 | } | |
e0c7ec2b DG |
331 | static inline |
332 | int ust_app_validate_version(int sock) | |
333 | { | |
334 | return 0; | |
335 | } | |
48842b30 | 336 | |
74d0b642 | 337 | #endif /* HAVE_LIBLTTNG_UST_CTL */ |
3bd1e081 | 338 | |
f6a9efaa | 339 | #endif /* _LTT_UST_APP_H */ |