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