lttng-sessiond: keep track of UST consumer fd for all UST sessions.
[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_consumer_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 char name[16];
42 };
43
44 /*
45 * Global applications HT used by the session daemon.
46 */
47 struct cds_lfht *ust_app_ht;
48
49 struct cds_lfht *ust_app_sock_key_map;
50
51 struct ust_app_key {
52 pid_t pid;
53 int sock;
54 struct cds_lfht_node node;
55 };
56
57 struct ust_app_event {
58 int enabled;
59 int handle;
60 struct lttng_ust_object_data *obj;
61 struct lttng_ust_event attr;
62 char name[LTTNG_UST_SYM_NAME_LEN];
63 struct cds_lfht *ctx;
64 struct cds_lfht_node node;
65 };
66
67 struct ust_app_channel {
68 int enabled;
69 int handle;
70 char name[LTTNG_UST_SYM_NAME_LEN];
71 struct lttng_ust_channel attr;
72 struct lttng_ust_object_data *obj;
73 struct ltt_ust_stream_list streams;
74 struct cds_lfht *ctx;
75 struct cds_lfht *events;
76 struct cds_lfht_node node;
77 };
78
79 struct ust_app_session {
80 int enabled;
81 int handle; /* Used has unique identifier */
82 unsigned int uid;
83 struct ltt_ust_metadata *metadata;
84 struct lttng_ust_object_data *obj;
85 struct cds_lfht *channels; /* Registered channels */
86 struct cds_lfht_node node;
87 };
88
89 /*
90 * Registered traceable applications. Libust registers to the session daemon
91 * and a linked list is kept of all running traceable app.
92 */
93 struct ust_app {
94 pid_t ppid;
95 uid_t uid; /* User ID that owns the apps */
96 gid_t gid; /* Group ID that owns the apps */
97 uint32_t v_major; /* Verion major number */
98 uint32_t v_minor; /* Verion minor number */
99 char name[17]; /* Process name (short) */
100 struct cds_lfht *sessions;
101 struct cds_lfht_node node;
102 struct ust_app_key key;
103 int sock_closed;
104 };
105
106 #ifdef HAVE_LIBLTTNG_UST_CTL
107
108 int ust_app_register(struct ust_register_msg *msg, int sock);
109 void ust_app_unregister(int sock);
110 int ust_app_create_channel_all(struct ltt_ust_session *usess,
111 struct ltt_ust_channel *uchan);
112 int ust_app_create_event_all(struct ltt_ust_session *usess,
113 struct ltt_ust_channel *uchan, struct ltt_ust_event *uevent);
114 unsigned long ust_app_list_count(void);
115 int ust_app_start_trace(struct ltt_ust_session *usess, struct ust_app *app);
116 int ust_app_start_trace_all(struct ltt_ust_session *usess);
117 int ust_app_list_events(struct lttng_event **events);
118 void ust_app_global_update(struct ltt_ust_session *usess, int sock);
119
120 void ust_app_clean_list(void);
121 void ust_app_ht_alloc(void);
122 struct cds_lfht *ust_app_get_ht(void);
123 struct ust_app *ust_app_find_by_pid(pid_t pid);
124
125 #else /* HAVE_LIBLTTNG_UST_CTL */
126
127 static inline
128 int ust_app_start_trace(struct ltt_ust_session *usess, struct ust_app *app)
129 {
130 return 0;
131 }
132 static inline
133 int ust_app_start_trace_all(struct ltt_ust_session *usess)
134 {
135 return 0;
136 }
137 static inline
138 int ust_app_list_events(struct lttng_event **events)
139 {
140 return 0;
141 }
142 static inline
143 int ust_app_register(struct ust_register_msg *msg, int sock)
144 {
145 return -ENOSYS;
146 }
147 static inline
148 void ust_app_unregister(int sock)
149 {
150 }
151 static inline
152 unsigned int ust_app_list_count(void)
153 {
154 return 0;
155 }
156 static inline
157 void ust_app_lock_list(void)
158 {
159 }
160 static inline
161 void ust_app_unlock_list(void)
162 {
163 }
164 static inline
165 void ust_app_clean_list(void)
166 {
167 }
168 static inline
169 struct ust_app_list *ust_app_get_list(void)
170 {
171 return NULL;
172 }
173 static inline
174 struct ust_app *ust_app_get_by_pid(pid_t pid)
175 {
176 return NULL;
177 }
178 static inline
179 int ust_app_add_channel_all(struct ltt_ust_session *usess,
180 struct ltt_ust_channel *uchan)
181 {
182 return 0;
183 }
184 static inline
185 int ust_app_add_event_all(struct ltt_ust_session *usess,
186 struct ltt_ust_channel *uchan, struct ltt_ust_event *uevent)
187 {
188 return 0;
189 }
190 static inline
191 struct cds_lfht *ust_app_get_ht(void)
192 {
193 return NULL;
194 }
195 static inline
196 void ust_app_ht_alloc(void)
197 {
198 }
199 static inline
200 void ust_app_global_update(struct ltt_ust_session *usess, int sock)
201 {
202 }
203
204 #endif /* HAVE_LIBLTTNG_UST_CTL */
205
206 #endif /* _LTT_UST_APP_H */
This page took 0.055006 seconds and 5 git commands to generate.