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