Commit | Line | Data |
---|---|---|
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 | 23 | #include <limits.h> |
f6a9efaa | 24 | #include <urcu.h> |
97ee3a89 | 25 | #include <urcu/list.h> |
97ee3a89 | 26 | #include <lttng/lttng.h> |
3bd1e081 | 27 | |
48842b30 | 28 | #include "ust-ctl.h" |
97ee3a89 | 29 | |
f6a9efaa | 30 | #include "../hashtable/rculfhash.h" |
0177d773 | 31 | |
2bdd86d4 MD |
32 | /* UST Stream list */ |
33 | struct ltt_ust_stream_list { | |
34 | unsigned int count; | |
35 | struct cds_list_head head; | |
36 | }; | |
37 | ||
f6a9efaa DG |
38 | /* Context hash table nodes */ |
39 | struct ltt_ust_context { | |
40 | struct lttng_ust_context ctx; | |
41 | struct cds_lfht_node node; | |
97ee3a89 DG |
42 | }; |
43 | ||
44 | /* UST event */ | |
45 | struct ltt_ust_event { | |
f6a9efaa DG |
46 | struct lttng_ust_event attr; |
47 | struct cds_lfht *ctx; | |
48 | struct cds_lfht_node node; | |
2bdd86d4 MD |
49 | }; |
50 | ||
51 | /* UST stream */ | |
52 | struct ltt_ust_stream { | |
48842b30 DG |
53 | int handle; |
54 | char pathname[PATH_MAX]; | |
13161846 | 55 | struct lttng_ust_object_data *obj; |
5af2f756 MD |
56 | /* Using a list of streams to keep order. */ |
57 | struct cds_list_head list; | |
97ee3a89 DG |
58 | }; |
59 | ||
60 | /* UST channel */ | |
61 | struct ltt_ust_channel { | |
44d3bd01 | 62 | char name[LTTNG_UST_SYM_NAME_LEN]; |
48842b30 | 63 | char pathname[PATH_MAX]; |
f6a9efaa DG |
64 | struct lttng_ust_channel attr; |
65 | struct cds_lfht *ctx; | |
66 | struct cds_lfht *events; | |
67 | struct cds_lfht_node node; | |
97ee3a89 DG |
68 | }; |
69 | ||
70 | /* UST Metadata */ | |
71 | struct ltt_ust_metadata { | |
72 | int handle; | |
13161846 | 73 | struct lttng_ust_object_data *obj; |
f6a9efaa | 74 | char pathname[PATH_MAX]; /* Trace file path name */ |
44d3bd01 | 75 | struct lttng_ust_channel attr; |
13161846 | 76 | struct lttng_ust_object_data *stream_obj; |
97ee3a89 DG |
77 | }; |
78 | ||
f6a9efaa DG |
79 | /* UST domain global (LTTNG_DOMAIN_UST) */ |
80 | struct ltt_ust_domain_global { | |
81 | struct cds_lfht *channels; | |
82 | }; | |
83 | ||
84 | /* UST domain pid (LTTNG_DOMAIN_UST_PID) */ | |
85 | struct ltt_ust_domain_pid { | |
86 | pid_t pid; | |
87 | struct cds_lfht *channels; | |
88 | struct cds_lfht_node 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 cds_lfht *channels; | |
95 | struct cds_lfht_node node; | |
96 | }; | |
97 | ||
97ee3a89 DG |
98 | /* UST session */ |
99 | struct ltt_ust_session { | |
48842b30 | 100 | int uid; /* Unique identifier of session */ |
3bd1e081 | 101 | int consumer_fds_sent; |
2bdd86d4 | 102 | int consumer_fd; |
48842b30 | 103 | char pathname[PATH_MAX]; |
f6a9efaa DG |
104 | struct ltt_ust_domain_global domain_global; |
105 | /* | |
48842b30 DG |
106 | * Those two hash tables contains data for a specific UST domain and each |
107 | * contains a HT of channels. See ltt_ust_domain_exec and | |
108 | * ltt_ust_domain_pid data structures. | |
f6a9efaa DG |
109 | */ |
110 | struct cds_lfht *domain_pid; | |
111 | struct cds_lfht *domain_exec; | |
97ee3a89 DG |
112 | }; |
113 | ||
74d0b642 | 114 | #ifdef HAVE_LIBLTTNG_UST_CTL |
3bd1e081 | 115 | |
97ee3a89 DG |
116 | /* |
117 | * Lookup functions. NULL is returned if not found. | |
118 | */ | |
f6a9efaa DG |
119 | struct ltt_ust_event *trace_ust_find_event_by_name(struct cds_lfht *ht, |
120 | char *name); | |
121 | struct ltt_ust_channel *trace_ust_find_channel_by_name(struct cds_lfht *ht, | |
122 | char *name); | |
97ee3a89 DG |
123 | |
124 | /* | |
125 | * Create functions malloc() the data structure. | |
126 | */ | |
48842b30 | 127 | struct ltt_ust_session *trace_ust_create_session(char *path, unsigned int uid, |
44d3bd01 DG |
128 | struct lttng_domain *domain); |
129 | struct ltt_ust_channel *trace_ust_create_channel(struct lttng_channel *attr, | |
130 | char *path); | |
97ee3a89 DG |
131 | struct ltt_ust_event *trace_ust_create_event(struct lttng_event *ev); |
132 | struct ltt_ust_metadata *trace_ust_create_metadata(char *path); | |
133 | ||
134 | /* | |
135 | * Destroy functions free() the data structure and remove from linked list if | |
136 | * it's applies. | |
137 | */ | |
138 | void trace_ust_destroy_session(struct ltt_ust_session *session); | |
139 | void trace_ust_destroy_metadata(struct ltt_ust_metadata *metadata); | |
140 | void trace_ust_destroy_channel(struct ltt_ust_channel *channel); | |
141 | void trace_ust_destroy_event(struct ltt_ust_event *event); | |
142 | ||
74d0b642 | 143 | #else /* HAVE_LIBLTTNG_UST_CTL */ |
3bd1e081 MD |
144 | |
145 | static inline | |
f6a9efaa DG |
146 | struct ltt_ust_event *trace_ust_find_event_by_name(struct cds_lfht *ht, |
147 | char *name) | |
3bd1e081 MD |
148 | { |
149 | return NULL; | |
150 | } | |
f6a9efaa | 151 | |
3bd1e081 | 152 | static inline |
f6a9efaa DG |
153 | struct ltt_ust_channel *trace_ust_find_channel_by_name(struct cds_lfht *ht, |
154 | char *name) | |
3bd1e081 MD |
155 | { |
156 | return NULL; | |
157 | } | |
f6a9efaa | 158 | |
3bd1e081 MD |
159 | static inline |
160 | struct ltt_ust_session *trace_ust_create_session(char *path, pid_t pid, | |
161 | struct lttng_domain *domain) | |
162 | { | |
163 | return NULL; | |
164 | } | |
165 | static inline | |
166 | struct ltt_ust_channel *trace_ust_create_channel(struct lttng_channel *attr, | |
167 | char *path) | |
168 | { | |
169 | return NULL; | |
170 | } | |
171 | static inline | |
172 | struct ltt_ust_event *trace_ust_create_event(struct lttng_event *ev) | |
173 | { | |
174 | return NULL; | |
175 | } | |
176 | static inline | |
177 | struct ltt_ust_metadata *trace_ust_create_metadata(char *path) | |
178 | { | |
179 | return NULL; | |
180 | } | |
181 | ||
182 | static inline | |
183 | void trace_ust_destroy_session(struct ltt_ust_session *session) | |
184 | { | |
185 | } | |
48842b30 | 186 | |
3bd1e081 MD |
187 | static inline |
188 | void trace_ust_destroy_metadata(struct ltt_ust_metadata *metadata) | |
189 | { | |
190 | } | |
48842b30 | 191 | |
3bd1e081 MD |
192 | static inline |
193 | void trace_ust_destroy_channel(struct ltt_ust_channel *channel) | |
194 | { | |
195 | } | |
48842b30 | 196 | |
3bd1e081 MD |
197 | static inline |
198 | void trace_ust_destroy_event(struct ltt_ust_event *event) | |
199 | { | |
200 | } | |
201 | ||
74d0b642 | 202 | #endif /* HAVE_LIBLTTNG_UST_CTL */ |
3bd1e081 | 203 | |
97ee3a89 | 204 | #endif /* _LTT_TRACE_UST_H */ |