2b133e8c473239088eacddb637982266447a4df9
[lttng-tools.git] / ltt-sessiond / trace-ust.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_TRACE_UST_H
20 #define _LTT_TRACE_UST_H
21
22 #include <config.h>
23 #include <limits.h>
24 #include <urcu.h>
25 #include <urcu/list.h>
26 #include <lttng/lttng.h>
27
28 /*
29 * FIXME: temporary workaround: we use a lttng-tools local version of
30 * lttng-ust-abi.h if UST is not found. Eventually, we should use our
31 * own internal structures within lttng-tools instead of relying on the
32 * UST ABI.
33 */
34 #ifdef CONFIG_CONFIG_LTTNG_TOOLS_HAVE_UST
35 #include <ust/lttng-ust-abi.h>
36 #else
37 #include "lttng-ust-abi.h"
38 #endif
39
40 #include "../hashtable/rculfhash.h"
41
42
43 /* UST Stream list */
44 struct ltt_ust_stream_list {
45 unsigned int count;
46 struct cds_list_head head;
47 };
48
49 /* Context hash table nodes */
50 struct ltt_ust_context {
51 struct lttng_ust_context ctx;
52 struct cds_lfht_node node;
53 };
54
55 /* UST event */
56 struct ltt_ust_event {
57 int handle;
58 int enabled;
59 struct object_data *obj;
60 struct lttng_ust_event attr;
61 struct cds_lfht *ctx;
62 struct cds_lfht_node node;
63 };
64
65 /* UST stream */
66 struct ltt_ust_stream {
67 /* TODO hashtable */
68 struct object_data *obj;
69 struct cds_list_head list;
70 char *pathname;
71 };
72
73 /* UST channel */
74 struct ltt_ust_channel {
75 int handle;
76 int enabled;
77 char name[LTTNG_UST_SYM_NAME_LEN];
78 char trace_path[PATH_MAX]; /* Trace file path name */
79 struct object_data *obj;
80
81 unsigned int stream_count;
82 struct ltt_ust_stream_list stream_list;
83 struct lttng_ust_channel attr;
84 struct cds_lfht *ctx;
85 struct cds_lfht *events;
86 struct cds_lfht_node node;
87 };
88
89 /* UST Metadata */
90 struct ltt_ust_metadata {
91 int handle;
92 struct object_data *obj;
93 char pathname[PATH_MAX]; /* Trace file path name */
94 struct lttng_ust_channel attr;
95 struct object_data *stream_obj;
96 };
97
98 /* UST domain global (LTTNG_DOMAIN_UST) */
99 struct ltt_ust_domain_global {
100 struct cds_lfht *channels;
101 };
102
103 /* UST domain pid (LTTNG_DOMAIN_UST_PID) */
104 struct ltt_ust_domain_pid {
105 pid_t pid;
106 struct cds_lfht *channels;
107 struct cds_lfht_node node;
108 };
109
110 /* UST domain exec name (LTTNG_DOMAIN_UST_EXEC_NAME) */
111 struct ltt_ust_domain_exec {
112 char exec_name[LTTNG_UST_SYM_NAME_LEN];
113 struct cds_lfht *channels;
114 struct cds_lfht_node node;
115 };
116
117 /* UST session */
118 struct ltt_ust_session {
119 int sock; /* socket to send cmds to app */
120 int handle;
121 int enabled;
122 int consumer_fds_sent;
123 int consumer_fd;
124 char path[PATH_MAX];
125 struct ltt_ust_metadata *metadata;
126 struct object_data *obj;
127 struct ltt_ust_domain_global domain_global;
128 /*
129 * Those two hash tables contains data for a specific UST domain and a HT
130 * of channels for each. See ltt_ust_domain_exec and ltt_ust_domain_pid
131 * data structures.
132 */
133 struct cds_lfht *domain_pid;
134 struct cds_lfht *domain_exec;
135 };
136
137 #ifdef CONFIG_LTTNG_TOOLS_HAVE_UST
138
139 /*
140 * Lookup functions. NULL is returned if not found.
141 */
142 struct ltt_ust_event *trace_ust_find_event_by_name(struct cds_lfht *ht,
143 char *name);
144 struct ltt_ust_channel *trace_ust_find_channel_by_name(struct cds_lfht *ht,
145 char *name);
146
147 /*
148 * Create functions malloc() the data structure.
149 */
150 struct ltt_ust_session *trace_ust_create_session(char *path, pid_t pid,
151 struct lttng_domain *domain);
152 struct ltt_ust_channel *trace_ust_create_channel(struct lttng_channel *attr,
153 char *path);
154 struct ltt_ust_event *trace_ust_create_event(struct lttng_event *ev);
155 struct ltt_ust_metadata *trace_ust_create_metadata(char *path);
156
157 /*
158 * Destroy functions free() the data structure and remove from linked list if
159 * it's applies.
160 */
161 void trace_ust_destroy_session(struct ltt_ust_session *session);
162 void trace_ust_destroy_metadata(struct ltt_ust_metadata *metadata);
163 void trace_ust_destroy_channel(struct ltt_ust_channel *channel);
164 void trace_ust_destroy_event(struct ltt_ust_event *event);
165
166 #else
167
168 static inline
169 struct ltt_ust_event *trace_ust_find_event_by_name(struct cds_lfht *ht,
170 char *name)
171 {
172 return NULL;
173 }
174
175 static inline
176 struct ltt_ust_channel *trace_ust_find_channel_by_name(struct cds_lfht *ht,
177 char *name)
178 {
179 return NULL;
180 }
181
182 static inline
183 struct ltt_ust_session *trace_ust_get_session_by_pid(
184 struct ltt_ust_session_list *session_list, pid_t pid)
185 {
186 return NULL;
187 }
188
189 static inline
190 struct ltt_ust_session *trace_ust_create_session(char *path, pid_t pid,
191 struct lttng_domain *domain)
192 {
193 return NULL;
194 }
195 static inline
196 struct ltt_ust_channel *trace_ust_create_channel(struct lttng_channel *attr,
197 char *path)
198 {
199 return NULL;
200 }
201 static inline
202 struct ltt_ust_event *trace_ust_create_event(struct lttng_event *ev)
203 {
204 return NULL;
205 }
206 static inline
207 struct ltt_ust_metadata *trace_ust_create_metadata(char *path)
208 {
209 return NULL;
210 }
211
212 static inline
213 void trace_ust_destroy_session(struct ltt_ust_session *session)
214 {
215 }
216 static inline
217 void trace_ust_destroy_metadata(struct ltt_ust_metadata *metadata)
218 {
219 }
220 static inline
221 void trace_ust_destroy_channel(struct ltt_ust_channel *channel)
222 {
223 }
224 static inline
225 void trace_ust_destroy_event(struct ltt_ust_event *event)
226 {
227 }
228
229 #endif
230
231 #endif /* _LTT_TRACE_UST_H */
This page took 0.048949 seconds and 3 git commands to generate.