906a6a209b1e63eca442e438fbb76497d1937775
[lttng-tools.git] / src / bin / lttng-sessiond / ust-app.h
1 /*
2 * Copyright (C) 2011 - David Goulet <david.goulet@polymtl.ca>
3 *
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.
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 *
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.
16 */
17
18 #ifndef _LTT_UST_APP_H
19 #define _LTT_UST_APP_H
20
21 #include <stdint.h>
22
23 #include "trace-ust.h"
24
25 /* lttng-ust supported version. */
26 #define LTTNG_UST_COMM_MAJOR 2 /* comm protocol major version */
27 #define UST_APP_MAJOR_VERSION 2 /* UST version supported */
28
29 #define UST_APP_EVENT_LIST_SIZE 32
30
31 extern int ust_consumerd64_fd, ust_consumerd32_fd;
32
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;
43 uint32_t bits_per_long;
44 char name[16];
45 };
46
47 /*
48 * Global applications HT used by the session daemon.
49 */
50 struct lttng_ht *ust_app_ht;
51
52 struct lttng_ht *ust_app_sock_key_map;
53
54 struct ust_app_key {
55 pid_t pid;
56 int sock;
57 struct lttng_ht_node_ulong node;
58 };
59
60 struct ust_app_ctx {
61 int handle;
62 struct lttng_ust_context ctx;
63 struct lttng_ust_object_data *obj;
64 struct lttng_ht_node_ulong node;
65 };
66
67 struct ust_app_event {
68 int enabled;
69 int handle;
70 struct lttng_ust_object_data *obj;
71 struct lttng_ust_event attr;
72 char name[LTTNG_UST_SYM_NAME_LEN];
73 struct lttng_ht *ctx;
74 struct lttng_ht_node_str node;
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;
82 struct lttng_ust_object_data *obj;
83 struct ltt_ust_stream_list streams;
84 struct lttng_ht *ctx;
85 struct lttng_ht *events;
86 struct lttng_ht_node_str node;
87 };
88
89 struct ust_app_session {
90 int enabled;
91 /* started: has the session been in started state at any time ? */
92 int started; /* allows detection of start vs restart. */
93 int handle; /* used has unique identifier for app session */
94 int id; /* session unique identifier */
95 struct ltt_ust_metadata *metadata;
96 struct lttng_ht *channels; /* Registered channels */
97 struct lttng_ht_node_ulong node;
98 char path[PATH_MAX];
99 /* UID/GID of the user owning the session */
100 uid_t uid;
101 gid_t gid;
102 };
103
104 /*
105 * Registered traceable applications. Libust registers to the session daemon
106 * and a linked list is kept of all running traceable app.
107 */
108 struct ust_app {
109 pid_t ppid;
110 uid_t uid; /* User ID that owns the apps */
111 gid_t gid; /* Group ID that owns the apps */
112 int bits_per_long;
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;
117 uint32_t v_major; /* Verion major number */
118 uint32_t v_minor; /* Verion minor number */
119 char name[17]; /* Process name (short) */
120 struct lttng_ht *sessions;
121 struct lttng_ht_node_ulong node;
122 struct ust_app_key key;
123 };
124
125 #ifdef HAVE_LIBLTTNG_UST_CTL
126
127 int ust_app_register(struct ust_register_msg *msg, int sock);
128 static inline
129 int ust_app_register_done(int sock)
130 {
131 return ustctl_register_done(sock);
132 }
133 void ust_app_unregister(int sock);
134 unsigned long ust_app_list_count(void);
135 int ust_app_start_trace(struct ltt_ust_session *usess, struct ust_app *app);
136 int ust_app_stop_trace(struct ltt_ust_session *usess, struct ust_app *app);
137 int ust_app_start_trace_all(struct ltt_ust_session *usess);
138 int ust_app_stop_trace_all(struct ltt_ust_session *usess);
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);
141 int ust_app_list_events(struct lttng_event **events);
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);
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);
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);
152 int ust_app_disable_channel_glb(struct ltt_ust_session *usess,
153 struct ltt_ust_channel *uchan);
154 int ust_app_enable_channel_glb(struct ltt_ust_session *usess,
155 struct ltt_ust_channel *uchan);
156 int ust_app_enable_event_glb(struct ltt_ust_session *usess,
157 struct ltt_ust_channel *uchan, struct ltt_ust_event *uevent);
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,
161 struct ltt_ust_channel *uchan);
162 int ust_app_disable_event_glb(struct ltt_ust_session *usess,
163 struct ltt_ust_channel *uchan, struct ltt_ust_event *uevent);
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);
169 void ust_app_global_update(struct ltt_ust_session *usess, int sock);
170
171 void ust_app_clean_list(void);
172 void ust_app_ht_alloc(void);
173 struct lttng_ht *ust_app_get_ht(void);
174 struct ust_app *ust_app_find_by_pid(pid_t pid);
175 int ust_app_validate_version(int sock);
176 int ust_app_calibrate_glb(struct lttng_ust_calibrate *calibrate);
177
178 #else /* HAVE_LIBLTTNG_UST_CTL */
179
180 static inline
181 int ust_app_destroy_trace_all(struct ltt_ust_session *usess)
182 {
183 return 0;
184 }
185 static inline
186 int ust_app_start_trace(struct ltt_ust_session *usess, struct ust_app *app)
187 {
188 return 0;
189 }
190 static inline
191 int ust_app_start_trace_all(struct ltt_ust_session *usess)
192 {
193 return 0;
194 }
195 static inline
196 int ust_app_stop_trace_all(struct ltt_ust_session *usess)
197 {
198 return 0;
199 }
200 static inline
201 int ust_app_list_events(struct lttng_event **events)
202 {
203 return 0;
204 }
205 static inline
206 int ust_app_register(struct ust_register_msg *msg, int sock)
207 {
208 return -ENOSYS;
209 }
210 static inline
211 int ust_app_register_done(int sock)
212 {
213 return -ENOSYS;
214 }
215 static inline
216 void ust_app_unregister(int sock)
217 {
218 }
219 static inline
220 unsigned int ust_app_list_count(void)
221 {
222 return 0;
223 }
224 static inline
225 void ust_app_lock_list(void)
226 {
227 }
228 static inline
229 void ust_app_unlock_list(void)
230 {
231 }
232 static inline
233 void ust_app_clean_list(void)
234 {
235 }
236 static inline
237 struct ust_app_list *ust_app_get_list(void)
238 {
239 return NULL;
240 }
241 static inline
242 struct ust_app *ust_app_get_by_pid(pid_t pid)
243 {
244 return NULL;
245 }
246 static inline
247 struct lttng_ht *ust_app_get_ht(void)
248 {
249 return NULL;
250 }
251 static inline
252 void ust_app_ht_alloc(void)
253 {}
254 static inline
255 void ust_app_global_update(struct ltt_ust_session *usess, int sock)
256 {}
257 static inline
258 int ust_app_disable_channel_glb(struct ltt_ust_session *usess,
259 struct ltt_ust_channel *uchan)
260 {
261 return 0;
262 }
263 static inline
264 int ust_app_enable_channel_glb(struct ltt_ust_session *usess,
265 struct ltt_ust_channel *uchan)
266 {
267 return 0;
268 }
269 static inline
270 int ust_app_create_channel_glb(struct ltt_ust_session *usess,
271 struct ltt_ust_channel *uchan)
272 {
273 return 0;
274 }
275 static inline
276 int ust_app_disable_all_event_glb(struct ltt_ust_session *usess,
277 struct ltt_ust_channel *uchan)
278 {
279 return 0;
280 }
281 static inline
282 int ust_app_enable_all_event_glb(struct ltt_ust_session *usess,
283 struct ltt_ust_channel *uchan)
284 {
285 return 0;
286 }
287 static inline
288 int ust_app_create_event_glb(struct ltt_ust_session *usess,
289 struct ltt_ust_channel *uchan, struct ltt_ust_event *uevent)
290 {
291 return 0;
292 }
293 static inline
294 int ust_app_disable_event_glb(struct ltt_ust_session *usess,
295 struct ltt_ust_channel *uchan, struct ltt_ust_event *uevent)
296 {
297 return 0;
298 }
299 static inline
300 int ust_app_enable_event_glb(struct ltt_ust_session *usess,
301 struct ltt_ust_channel *uchan, struct ltt_ust_event *uevent)
302 {
303 return 0;
304 }
305 static inline
306 int ust_app_add_ctx_event_glb(struct ltt_ust_session *usess,
307 struct ltt_ust_channel *uchan, struct ltt_ust_event *uevent,
308 struct ltt_ust_context *uctx)
309 {
310 return 0;
311 }
312 static inline
313 int ust_app_add_ctx_channel_glb(struct ltt_ust_session *usess,
314 struct ltt_ust_channel *uchan, struct ltt_ust_context *uctx)
315 {
316 return 0;
317 }
318 static inline
319 int ust_app_enable_event_pid(struct ltt_ust_session *usess,
320 struct ltt_ust_channel *uchan, struct ltt_ust_event *uevent,
321 pid_t pid)
322 {
323 return 0;
324 }
325 static inline
326 int ust_app_disable_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 }
332 static inline
333 int ust_app_validate_version(int sock)
334 {
335 return 0;
336 }
337 static inline
338 int ust_app_calibrate_glb(struct lttng_ust_calibrate *calibrate)
339 {
340 return 0;
341 }
342
343 #endif /* HAVE_LIBLTTNG_UST_CTL */
344
345 #endif /* _LTT_UST_APP_H */
This page took 0.05277 seconds and 3 git commands to generate.