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