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