Commit | Line | Data |
---|---|---|
97ee3a89 DG |
1 | /* |
2 | * Copyright (C) 2011 - David Goulet <david.goulet@polymtl.ca> | |
3 | * | |
d14d33bf AM |
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. | |
97ee3a89 DG |
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 | * | |
d14d33bf AM |
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. | |
97ee3a89 DG |
16 | */ |
17 | ||
18 | #ifndef _LTT_TRACE_UST_H | |
19 | #define _LTT_TRACE_UST_H | |
20 | ||
3bd1e081 | 21 | #include <config.h> |
97ee3a89 DG |
22 | #include <limits.h> |
23 | #include <urcu/list.h> | |
bec39940 | 24 | |
97ee3a89 | 25 | #include <lttng/lttng.h> |
10a8a223 | 26 | #include <common/hashtable/hashtable.h> |
ce2a9e76 | 27 | #include <common/defaults.h> |
3bd1e081 | 28 | |
00e2e675 | 29 | #include "consumer.h" |
48842b30 | 30 | #include "ust-ctl.h" |
97ee3a89 | 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; | |
bec39940 | 41 | struct lttng_ht_node_ulong node; |
97ee3a89 DG |
42 | }; |
43 | ||
44 | /* UST event */ | |
45 | struct ltt_ust_event { | |
37357452 | 46 | unsigned int enabled; |
f6a9efaa | 47 | struct lttng_ust_event attr; |
bec39940 DG |
48 | struct lttng_ht *ctx; |
49 | struct lttng_ht_node_str node; | |
53a80697 | 50 | struct lttng_ust_filter_bytecode *filter; |
2bdd86d4 MD |
51 | }; |
52 | ||
53 | /* UST stream */ | |
54 | struct ltt_ust_stream { | |
48842b30 DG |
55 | int handle; |
56 | char pathname[PATH_MAX]; | |
00e2e675 | 57 | /* Format is %s_%d respectively channel name and CPU number. */ |
ce2a9e76 | 58 | char name[DEFAULT_STREAM_NAME_LEN]; |
13161846 | 59 | struct lttng_ust_object_data *obj; |
5af2f756 MD |
60 | /* Using a list of streams to keep order. */ |
61 | struct cds_list_head list; | |
97ee3a89 DG |
62 | }; |
63 | ||
64 | /* UST channel */ | |
65 | struct ltt_ust_channel { | |
37357452 | 66 | unsigned int enabled; |
44d3bd01 | 67 | char name[LTTNG_UST_SYM_NAME_LEN]; |
48842b30 | 68 | char pathname[PATH_MAX]; |
f6a9efaa | 69 | struct lttng_ust_channel attr; |
bec39940 DG |
70 | struct lttng_ht *ctx; |
71 | struct lttng_ht *events; | |
72 | struct lttng_ht_node_str node; | |
97ee3a89 DG |
73 | }; |
74 | ||
75 | /* UST Metadata */ | |
76 | struct ltt_ust_metadata { | |
77 | int handle; | |
13161846 | 78 | struct lttng_ust_object_data *obj; |
f6a9efaa | 79 | char pathname[PATH_MAX]; /* Trace file path name */ |
44d3bd01 | 80 | struct lttng_ust_channel attr; |
13161846 | 81 | struct lttng_ust_object_data *stream_obj; |
97ee3a89 DG |
82 | }; |
83 | ||
f6a9efaa DG |
84 | /* UST domain global (LTTNG_DOMAIN_UST) */ |
85 | struct ltt_ust_domain_global { | |
bec39940 | 86 | struct lttng_ht *channels; |
f6a9efaa DG |
87 | }; |
88 | ||
89 | /* UST domain pid (LTTNG_DOMAIN_UST_PID) */ | |
90 | struct ltt_ust_domain_pid { | |
91 | pid_t pid; | |
bec39940 DG |
92 | struct lttng_ht *channels; |
93 | struct lttng_ht_node_ulong node; | |
f6a9efaa DG |
94 | }; |
95 | ||
96 | /* UST domain exec name (LTTNG_DOMAIN_UST_EXEC_NAME) */ | |
97 | struct ltt_ust_domain_exec { | |
98 | char exec_name[LTTNG_UST_SYM_NAME_LEN]; | |
bec39940 DG |
99 | struct lttng_ht *channels; |
100 | struct lttng_ht_node_str node; | |
f6a9efaa DG |
101 | }; |
102 | ||
97ee3a89 DG |
103 | /* UST session */ |
104 | struct ltt_ust_session { | |
a991f516 | 105 | int id; /* Unique identifier of session */ |
36dc12cc | 106 | int start_trace; |
48842b30 | 107 | char pathname[PATH_MAX]; |
f6a9efaa DG |
108 | struct ltt_ust_domain_global domain_global; |
109 | /* | |
48842b30 DG |
110 | * Those two hash tables contains data for a specific UST domain and each |
111 | * contains a HT of channels. See ltt_ust_domain_exec and | |
112 | * ltt_ust_domain_pid data structures. | |
f6a9efaa | 113 | */ |
bec39940 DG |
114 | struct lttng_ht *domain_pid; |
115 | struct lttng_ht *domain_exec; | |
6df2e2c9 MD |
116 | /* UID/GID of the user owning the session */ |
117 | uid_t uid; | |
118 | gid_t gid; | |
00e2e675 DG |
119 | /* |
120 | * Two consumer_output object are needed where one is for the current | |
121 | * output object and the second one is the temporary object used to store | |
122 | * URI being set by the lttng_set_consumer_uri call. Once | |
123 | * lttng_enable_consumer is called, the two pointers are swapped. | |
124 | */ | |
125 | struct consumer_output *consumer; | |
126 | struct consumer_output *tmp_consumer; | |
97ee3a89 DG |
127 | }; |
128 | ||
74d0b642 | 129 | #ifdef HAVE_LIBLTTNG_UST_CTL |
3bd1e081 | 130 | |
97ee3a89 DG |
131 | /* |
132 | * Lookup functions. NULL is returned if not found. | |
133 | */ | |
bec39940 | 134 | struct ltt_ust_event *trace_ust_find_event_by_name(struct lttng_ht *ht, |
f6a9efaa | 135 | char *name); |
bec39940 | 136 | struct ltt_ust_channel *trace_ust_find_channel_by_name(struct lttng_ht *ht, |
f6a9efaa | 137 | char *name); |
97ee3a89 DG |
138 | |
139 | /* | |
140 | * Create functions malloc() the data structure. | |
141 | */ | |
fc4705fe DG |
142 | struct ltt_ust_session *trace_ust_create_session(char *path, |
143 | unsigned int session_id, struct lttng_domain *domain); | |
44d3bd01 DG |
144 | struct ltt_ust_channel *trace_ust_create_channel(struct lttng_channel *attr, |
145 | char *path); | |
97ee3a89 DG |
146 | struct ltt_ust_event *trace_ust_create_event(struct lttng_event *ev); |
147 | struct ltt_ust_metadata *trace_ust_create_metadata(char *path); | |
55cc08a6 DG |
148 | struct ltt_ust_context *trace_ust_create_context( |
149 | struct lttng_event_context *ctx); | |
97ee3a89 DG |
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 | ||
74d0b642 | 160 | #else /* HAVE_LIBLTTNG_UST_CTL */ |
3bd1e081 MD |
161 | |
162 | static inline | |
bec39940 | 163 | struct ltt_ust_event *trace_ust_find_event_by_name(struct lttng_ht *ht, |
f6a9efaa | 164 | char *name) |
3bd1e081 MD |
165 | { |
166 | return NULL; | |
167 | } | |
f6a9efaa | 168 | |
3bd1e081 | 169 | static inline |
bec39940 | 170 | struct ltt_ust_channel *trace_ust_find_channel_by_name(struct lttng_ht *ht, |
f6a9efaa | 171 | char *name) |
3bd1e081 MD |
172 | { |
173 | return NULL; | |
174 | } | |
f6a9efaa | 175 | |
3bd1e081 MD |
176 | static inline |
177 | struct ltt_ust_session *trace_ust_create_session(char *path, pid_t pid, | |
178 | struct lttng_domain *domain) | |
179 | { | |
180 | return NULL; | |
181 | } | |
182 | static inline | |
183 | struct ltt_ust_channel *trace_ust_create_channel(struct lttng_channel *attr, | |
184 | char *path) | |
185 | { | |
186 | return NULL; | |
187 | } | |
188 | static inline | |
189 | struct ltt_ust_event *trace_ust_create_event(struct lttng_event *ev) | |
190 | { | |
191 | return NULL; | |
192 | } | |
193 | static inline | |
194 | struct ltt_ust_metadata *trace_ust_create_metadata(char *path) | |
195 | { | |
196 | return NULL; | |
197 | } | |
198 | ||
199 | static inline | |
200 | void trace_ust_destroy_session(struct ltt_ust_session *session) | |
201 | { | |
202 | } | |
48842b30 | 203 | |
3bd1e081 MD |
204 | static inline |
205 | void trace_ust_destroy_metadata(struct ltt_ust_metadata *metadata) | |
206 | { | |
207 | } | |
48842b30 | 208 | |
3bd1e081 MD |
209 | static inline |
210 | void trace_ust_destroy_channel(struct ltt_ust_channel *channel) | |
211 | { | |
212 | } | |
48842b30 | 213 | |
3bd1e081 MD |
214 | static inline |
215 | void trace_ust_destroy_event(struct ltt_ust_event *event) | |
216 | { | |
217 | } | |
34378f76 DG |
218 | static inline |
219 | struct ltt_ust_context *trace_ust_create_context( | |
220 | struct lttng_event_context *ctx) | |
221 | { | |
222 | return NULL; | |
223 | } | |
3bd1e081 | 224 | |
74d0b642 | 225 | #endif /* HAVE_LIBLTTNG_UST_CTL */ |
3bd1e081 | 226 | |
97ee3a89 | 227 | #endif /* _LTT_TRACE_UST_H */ |