Fix: return value signedness
[lttng-tools.git] / src / bin / lttng-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 modify
5 * it under the terms of the GNU General Public License, version 2 only,
6 * as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
16 */
17
18 #ifndef _LTT_TRACE_UST_H
19 #define _LTT_TRACE_UST_H
20
21 #include <config.h>
22 #include <limits.h>
23 #include <urcu/list.h>
24
25 #include <lttng/lttng.h>
26 #include <common/hashtable/hashtable.h>
27
28 #include "ust-ctl.h"
29
30 /* UST Stream list */
31 struct ltt_ust_stream_list {
32 unsigned int count;
33 struct cds_list_head head;
34 };
35
36 /* Context hash table nodes */
37 struct ltt_ust_context {
38 struct lttng_ust_context ctx;
39 struct lttng_ht_node_ulong node;
40 };
41
42 /* UST event */
43 struct ltt_ust_event {
44 unsigned int enabled;
45 struct lttng_ust_event attr;
46 struct lttng_ht *ctx;
47 struct lttng_ht_node_str node;
48 };
49
50 /* UST stream */
51 struct ltt_ust_stream {
52 int handle;
53 char pathname[PATH_MAX];
54 struct lttng_ust_object_data *obj;
55 /* Using a list of streams to keep order. */
56 struct cds_list_head list;
57 };
58
59 /* UST channel */
60 struct ltt_ust_channel {
61 unsigned int enabled;
62 char name[LTTNG_UST_SYM_NAME_LEN];
63 char pathname[PATH_MAX];
64 struct lttng_ust_channel attr;
65 struct lttng_ht *ctx;
66 struct lttng_ht *events;
67 struct lttng_ht_node_str node;
68 };
69
70 /* UST Metadata */
71 struct ltt_ust_metadata {
72 int handle;
73 struct lttng_ust_object_data *obj;
74 char pathname[PATH_MAX]; /* Trace file path name */
75 struct lttng_ust_channel attr;
76 struct lttng_ust_object_data *stream_obj;
77 };
78
79 /* UST domain global (LTTNG_DOMAIN_UST) */
80 struct ltt_ust_domain_global {
81 struct lttng_ht *channels;
82 };
83
84 /* UST domain pid (LTTNG_DOMAIN_UST_PID) */
85 struct ltt_ust_domain_pid {
86 pid_t pid;
87 struct lttng_ht *channels;
88 struct lttng_ht_node_ulong node;
89 };
90
91 /* UST domain exec name (LTTNG_DOMAIN_UST_EXEC_NAME) */
92 struct ltt_ust_domain_exec {
93 char exec_name[LTTNG_UST_SYM_NAME_LEN];
94 struct lttng_ht *channels;
95 struct lttng_ht_node_str node;
96 };
97
98 /* UST session */
99 struct ltt_ust_session {
100 int id; /* Unique identifier of session */
101 int start_trace;
102 char pathname[PATH_MAX];
103 struct ltt_ust_domain_global domain_global;
104 /*
105 * Those two hash tables contains data for a specific UST domain and each
106 * contains a HT of channels. See ltt_ust_domain_exec and
107 * ltt_ust_domain_pid data structures.
108 */
109 struct lttng_ht *domain_pid;
110 struct lttng_ht *domain_exec;
111 /* UID/GID of the user owning the session */
112 uid_t uid;
113 gid_t gid;
114 };
115
116 #ifdef HAVE_LIBLTTNG_UST_CTL
117
118 /*
119 * Lookup functions. NULL is returned if not found.
120 */
121 struct ltt_ust_event *trace_ust_find_event_by_name(struct lttng_ht *ht,
122 char *name);
123 struct ltt_ust_channel *trace_ust_find_channel_by_name(struct lttng_ht *ht,
124 char *name);
125
126 /*
127 * Create functions malloc() the data structure.
128 */
129 struct ltt_ust_session *trace_ust_create_session(char *path,
130 unsigned int session_id, struct lttng_domain *domain);
131 struct ltt_ust_channel *trace_ust_create_channel(struct lttng_channel *attr,
132 char *path);
133 struct ltt_ust_event *trace_ust_create_event(struct lttng_event *ev);
134 struct ltt_ust_metadata *trace_ust_create_metadata(char *path);
135 struct ltt_ust_context *trace_ust_create_context(
136 struct lttng_event_context *ctx);
137
138 /*
139 * Destroy functions free() the data structure and remove from linked list if
140 * it's applies.
141 */
142 void trace_ust_destroy_session(struct ltt_ust_session *session);
143 void trace_ust_destroy_metadata(struct ltt_ust_metadata *metadata);
144 void trace_ust_destroy_channel(struct ltt_ust_channel *channel);
145 void trace_ust_destroy_event(struct ltt_ust_event *event);
146
147 #else /* HAVE_LIBLTTNG_UST_CTL */
148
149 static inline
150 struct ltt_ust_event *trace_ust_find_event_by_name(struct lttng_ht *ht,
151 char *name)
152 {
153 return NULL;
154 }
155
156 static inline
157 struct ltt_ust_channel *trace_ust_find_channel_by_name(struct lttng_ht *ht,
158 char *name)
159 {
160 return NULL;
161 }
162
163 static inline
164 struct ltt_ust_session *trace_ust_create_session(char *path, pid_t pid,
165 struct lttng_domain *domain)
166 {
167 return NULL;
168 }
169 static inline
170 struct ltt_ust_channel *trace_ust_create_channel(struct lttng_channel *attr,
171 char *path)
172 {
173 return NULL;
174 }
175 static inline
176 struct ltt_ust_event *trace_ust_create_event(struct lttng_event *ev)
177 {
178 return NULL;
179 }
180 static inline
181 struct ltt_ust_metadata *trace_ust_create_metadata(char *path)
182 {
183 return NULL;
184 }
185
186 static inline
187 void trace_ust_destroy_session(struct ltt_ust_session *session)
188 {
189 }
190
191 static inline
192 void trace_ust_destroy_metadata(struct ltt_ust_metadata *metadata)
193 {
194 }
195
196 static inline
197 void trace_ust_destroy_channel(struct ltt_ust_channel *channel)
198 {
199 }
200
201 static inline
202 void trace_ust_destroy_event(struct ltt_ust_event *event)
203 {
204 }
205 static inline
206 struct ltt_ust_context *trace_ust_create_context(
207 struct lttng_event_context *ctx)
208 {
209 return NULL;
210 }
211
212 #endif /* HAVE_LIBLTTNG_UST_CTL */
213
214 #endif /* _LTT_TRACE_UST_H */
This page took 0.049322 seconds and 4 git commands to generate.