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