Add target arch and paths to the configure output
[lttng-tools.git] / 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
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; only version 2
7 * of the License.
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
19 #ifndef _LTT_UST_APP_H
20 #define _LTT_UST_APP_H
21
22 #include <stdint.h>
23 #include <urcu/list.h>
24
25 #include "trace-ust.h"
26
27 #define UST_APP_EVENT_LIST_SIZE 32
28
29 extern int ust_consumerd64_fd, ust_consumerd32_fd;
30
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;
41 uint32_t bits_per_long;
42 char name[16];
43 };
44
45 /*
46 * Global applications HT used by the session daemon.
47 */
48 struct lttng_ht *ust_app_ht;
49
50 struct lttng_ht *ust_app_sock_key_map;
51
52 struct ust_app_key {
53 pid_t pid;
54 int sock;
55 struct lttng_ht_node_ulong node;
56 };
57
58 struct ust_app_ctx {
59 int handle;
60 struct lttng_ust_context ctx;
61 struct lttng_ust_object_data *obj;
62 struct lttng_ht_node_ulong node;
63 };
64
65 struct ust_app_event {
66 int enabled;
67 int handle;
68 struct lttng_ust_object_data *obj;
69 struct lttng_ust_event attr;
70 char name[LTTNG_UST_SYM_NAME_LEN];
71 struct lttng_ht *ctx;
72 struct lttng_ht_node_str node;
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;
80 struct lttng_ust_object_data *obj;
81 struct ltt_ust_stream_list streams;
82 struct lttng_ht *ctx;
83 struct lttng_ht *events;
84 struct lttng_ht_node_str node;
85 };
86
87 struct ust_app_session {
88 int enabled;
89 /* started: has the session been in started state at any time ? */
90 int started; /* allows detection of start vs restart. */
91 int handle; /* used has unique identifier for app session */
92 int id; /* session unique identifier */
93 struct ltt_ust_metadata *metadata;
94 struct lttng_ht *channels; /* Registered channels */
95 struct lttng_ht_node_ulong node;
96 char path[PATH_MAX];
97 /* UID/GID of the user owning the session */
98 uid_t uid;
99 gid_t gid;
100 };
101
102 /*
103 * Registered traceable applications. Libust registers to the session daemon
104 * and a linked list is kept of all running traceable app.
105 */
106 struct ust_app {
107 pid_t ppid;
108 uid_t uid; /* User ID that owns the apps */
109 gid_t gid; /* Group ID that owns the apps */
110 int bits_per_long;
111 uint32_t v_major; /* Verion major number */
112 uint32_t v_minor; /* Verion minor number */
113 char name[17]; /* Process name (short) */
114 struct lttng_ht *sessions;
115 struct lttng_ht_node_ulong node;
116 struct ust_app_key key;
117 };
118
119 #ifdef HAVE_LIBLTTNG_UST_CTL
120
121 int ust_app_register(struct ust_register_msg *msg, int sock);
122 static inline
123 int ust_app_register_done(int sock)
124 {
125 return ustctl_register_done(sock);
126 }
127 void ust_app_unregister(int sock);
128 unsigned long ust_app_list_count(void);
129 int ust_app_start_trace(struct ltt_ust_session *usess, struct ust_app *app);
130 int ust_app_stop_trace(struct ltt_ust_session *usess, struct ust_app *app);
131 int ust_app_start_trace_all(struct ltt_ust_session *usess);
132 int ust_app_stop_trace_all(struct ltt_ust_session *usess);
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);
135 int ust_app_list_events(struct lttng_event **events);
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);
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);
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);
146 int ust_app_disable_channel_glb(struct ltt_ust_session *usess,
147 struct ltt_ust_channel *uchan);
148 int ust_app_enable_channel_glb(struct ltt_ust_session *usess,
149 struct ltt_ust_channel *uchan);
150 int ust_app_enable_event_glb(struct ltt_ust_session *usess,
151 struct ltt_ust_channel *uchan, struct ltt_ust_event *uevent);
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,
155 struct ltt_ust_channel *uchan);
156 int ust_app_disable_event_glb(struct ltt_ust_session *usess,
157 struct ltt_ust_channel *uchan, struct ltt_ust_event *uevent);
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);
163 void ust_app_global_update(struct ltt_ust_session *usess, int sock);
164
165 void ust_app_clean_list(void);
166 void ust_app_ht_alloc(void);
167 struct lttng_ht *ust_app_get_ht(void);
168 struct ust_app *ust_app_find_by_pid(pid_t pid);
169
170 #else /* HAVE_LIBLTTNG_UST_CTL */
171
172 static inline
173 int ust_app_destroy_trace_all(struct ltt_ust_session *usess)
174 {
175 return 0;
176 }
177 static inline
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)
184 {
185 return 0;
186 }
187 static inline
188 int ust_app_stop_trace_all(struct ltt_ust_session *usess)
189 {
190 return 0;
191 }
192 static inline
193 int ust_app_list_events(struct lttng_event **events)
194 {
195 return 0;
196 }
197 static inline
198 int ust_app_register(struct ust_register_msg *msg, int sock)
199 {
200 return -ENOSYS;
201 }
202 static inline
203 int ust_app_register_done(int sock)
204 {
205 return -ENOSYS;
206 }
207 static inline
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 }
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 }
238 static inline
239 struct lttng_ht *ust_app_get_ht(void)
240 {
241 return NULL;
242 }
243 static inline
244 void ust_app_ht_alloc(void)
245 {}
246 static inline
247 void ust_app_global_update(struct ltt_ust_session *usess, int sock)
248 {}
249 static inline
250 int ust_app_disable_channel_glb(struct ltt_ust_session *usess,
251 struct ltt_ust_channel *uchan)
252 {
253 return 0;
254 }
255 static inline
256 int ust_app_enable_channel_glb(struct ltt_ust_session *usess,
257 struct ltt_ust_channel *uchan)
258 {
259 return 0;
260 }
261 static inline
262 int ust_app_create_channel_glb(struct ltt_ust_session *usess,
263 struct ltt_ust_channel *uchan)
264 {
265 return 0;
266 }
267 static inline
268 int ust_app_disable_all_event_glb(struct ltt_ust_session *usess,
269 struct ltt_ust_channel *uchan)
270 {
271 return 0;
272 }
273 static inline
274 int ust_app_enable_all_event_glb(struct ltt_ust_session *usess,
275 struct ltt_ust_channel *uchan)
276 {
277 return 0;
278 }
279 static inline
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,
287 struct ltt_ust_channel *uchan, struct ltt_ust_event *uevent)
288 {
289 return 0;
290 }
291 static inline
292 int ust_app_enable_event_glb(struct ltt_ust_session *usess,
293 struct ltt_ust_channel *uchan, struct ltt_ust_event *uevent)
294 {
295 return 0;
296 }
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 }
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 }
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 }
324
325 #endif /* HAVE_LIBLTTNG_UST_CTL */
326
327 #endif /* _LTT_UST_APP_H */
This page took 0.035016 seconds and 4 git commands to generate.