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 | |
18eace3b DG |
32 | struct ltt_ust_ht_key { |
33 | const char *name; | |
34 | const struct lttng_filter_bytecode *filter; | |
35 | enum lttng_ust_loglevel_type loglevel; | |
36 | }; | |
37 | ||
2bdd86d4 MD |
38 | /* UST Stream list */ |
39 | struct ltt_ust_stream_list { | |
40 | unsigned int count; | |
41 | struct cds_list_head head; | |
42 | }; | |
43 | ||
f6a9efaa DG |
44 | /* Context hash table nodes */ |
45 | struct ltt_ust_context { | |
46 | struct lttng_ust_context ctx; | |
bec39940 | 47 | struct lttng_ht_node_ulong node; |
97ee3a89 DG |
48 | }; |
49 | ||
50 | /* UST event */ | |
51 | struct ltt_ust_event { | |
37357452 | 52 | unsigned int enabled; |
f6a9efaa | 53 | struct lttng_ust_event attr; |
bec39940 | 54 | struct lttng_ht_node_str node; |
53a80697 | 55 | struct lttng_ust_filter_bytecode *filter; |
2bdd86d4 MD |
56 | }; |
57 | ||
58 | /* UST stream */ | |
59 | struct ltt_ust_stream { | |
48842b30 DG |
60 | int handle; |
61 | char pathname[PATH_MAX]; | |
00e2e675 | 62 | /* Format is %s_%d respectively channel name and CPU number. */ |
ce2a9e76 | 63 | char name[DEFAULT_STREAM_NAME_LEN]; |
13161846 | 64 | struct lttng_ust_object_data *obj; |
5af2f756 MD |
65 | /* Using a list of streams to keep order. */ |
66 | struct cds_list_head list; | |
97ee3a89 DG |
67 | }; |
68 | ||
69 | /* UST channel */ | |
70 | struct ltt_ust_channel { | |
37357452 | 71 | unsigned int enabled; |
44d3bd01 | 72 | char name[LTTNG_UST_SYM_NAME_LEN]; |
48842b30 | 73 | char pathname[PATH_MAX]; |
f6a9efaa | 74 | struct lttng_ust_channel attr; |
bec39940 DG |
75 | struct lttng_ht *ctx; |
76 | struct lttng_ht *events; | |
77 | struct lttng_ht_node_str node; | |
97ee3a89 DG |
78 | }; |
79 | ||
80 | /* UST Metadata */ | |
81 | struct ltt_ust_metadata { | |
82 | int handle; | |
13161846 | 83 | struct lttng_ust_object_data *obj; |
f6a9efaa | 84 | char pathname[PATH_MAX]; /* Trace file path name */ |
44d3bd01 | 85 | struct lttng_ust_channel attr; |
13161846 | 86 | struct lttng_ust_object_data *stream_obj; |
97ee3a89 DG |
87 | }; |
88 | ||
f6a9efaa DG |
89 | /* UST domain global (LTTNG_DOMAIN_UST) */ |
90 | struct ltt_ust_domain_global { | |
bec39940 | 91 | struct lttng_ht *channels; |
f6a9efaa DG |
92 | }; |
93 | ||
94 | /* UST domain pid (LTTNG_DOMAIN_UST_PID) */ | |
95 | struct ltt_ust_domain_pid { | |
96 | pid_t pid; | |
bec39940 DG |
97 | struct lttng_ht *channels; |
98 | struct lttng_ht_node_ulong node; | |
f6a9efaa DG |
99 | }; |
100 | ||
101 | /* UST domain exec name (LTTNG_DOMAIN_UST_EXEC_NAME) */ | |
102 | struct ltt_ust_domain_exec { | |
103 | char exec_name[LTTNG_UST_SYM_NAME_LEN]; | |
bec39940 DG |
104 | struct lttng_ht *channels; |
105 | struct lttng_ht_node_str node; | |
f6a9efaa DG |
106 | }; |
107 | ||
97ee3a89 DG |
108 | /* UST session */ |
109 | struct ltt_ust_session { | |
a991f516 | 110 | int id; /* Unique identifier of session */ |
36dc12cc | 111 | int start_trace; |
48842b30 | 112 | char pathname[PATH_MAX]; |
f6a9efaa DG |
113 | struct ltt_ust_domain_global domain_global; |
114 | /* | |
48842b30 DG |
115 | * Those two hash tables contains data for a specific UST domain and each |
116 | * contains a HT of channels. See ltt_ust_domain_exec and | |
117 | * ltt_ust_domain_pid data structures. | |
f6a9efaa | 118 | */ |
bec39940 DG |
119 | struct lttng_ht *domain_pid; |
120 | struct lttng_ht *domain_exec; | |
6df2e2c9 MD |
121 | /* UID/GID of the user owning the session */ |
122 | uid_t uid; | |
123 | gid_t gid; | |
00e2e675 DG |
124 | /* |
125 | * Two consumer_output object are needed where one is for the current | |
126 | * output object and the second one is the temporary object used to store | |
127 | * URI being set by the lttng_set_consumer_uri call. Once | |
128 | * lttng_enable_consumer is called, the two pointers are swapped. | |
129 | */ | |
130 | struct consumer_output *consumer; | |
131 | struct consumer_output *tmp_consumer; | |
f3f0db50 DG |
132 | /* Sequence number for filters so the tracer knows the ordering. */ |
133 | uint64_t filter_seq_num; | |
97ee3a89 DG |
134 | }; |
135 | ||
74d0b642 | 136 | #ifdef HAVE_LIBLTTNG_UST_CTL |
3bd1e081 | 137 | |
18eace3b DG |
138 | int trace_ust_ht_match_event(struct cds_lfht_node *node, const void *_key); |
139 | int trace_ust_ht_match_event_by_name(struct cds_lfht_node *node, | |
140 | const void *_key); | |
141 | ||
97ee3a89 DG |
142 | /* |
143 | * Lookup functions. NULL is returned if not found. | |
144 | */ | |
18eace3b DG |
145 | struct ltt_ust_event *trace_ust_find_event(struct lttng_ht *ht, |
146 | char *name, struct lttng_filter_bytecode *filter, int loglevel); | |
bec39940 | 147 | struct ltt_ust_channel *trace_ust_find_channel_by_name(struct lttng_ht *ht, |
f6a9efaa | 148 | char *name); |
97ee3a89 DG |
149 | |
150 | /* | |
151 | * Create functions malloc() the data structure. | |
152 | */ | |
fc4705fe DG |
153 | struct ltt_ust_session *trace_ust_create_session(char *path, |
154 | unsigned int session_id, struct lttng_domain *domain); | |
44d3bd01 DG |
155 | struct ltt_ust_channel *trace_ust_create_channel(struct lttng_channel *attr, |
156 | char *path); | |
025faf73 DG |
157 | struct ltt_ust_event *trace_ust_create_event(struct lttng_event *ev, |
158 | struct lttng_filter_bytecode *filter); | |
97ee3a89 | 159 | struct ltt_ust_metadata *trace_ust_create_metadata(char *path); |
55cc08a6 DG |
160 | struct ltt_ust_context *trace_ust_create_context( |
161 | struct lttng_event_context *ctx); | |
97ee3a89 DG |
162 | |
163 | /* | |
164 | * Destroy functions free() the data structure and remove from linked list if | |
165 | * it's applies. | |
166 | */ | |
167 | void trace_ust_destroy_session(struct ltt_ust_session *session); | |
168 | void trace_ust_destroy_metadata(struct ltt_ust_metadata *metadata); | |
169 | void trace_ust_destroy_channel(struct ltt_ust_channel *channel); | |
170 | void trace_ust_destroy_event(struct ltt_ust_event *event); | |
171 | ||
74d0b642 | 172 | #else /* HAVE_LIBLTTNG_UST_CTL */ |
3bd1e081 | 173 | |
37a86c61 DG |
174 | static inline int trace_ust_ht_match_event(struct cds_lfht_node *node, |
175 | const void *_key) | |
176 | { | |
177 | return 0; | |
178 | } | |
179 | static inline int trace_ust_ht_match_event_by_name(struct cds_lfht_node *node, | |
180 | const void *_key) | |
181 | { | |
182 | return 0; | |
183 | } | |
3bd1e081 | 184 | static inline |
bec39940 | 185 | struct ltt_ust_channel *trace_ust_find_channel_by_name(struct lttng_ht *ht, |
f6a9efaa | 186 | char *name) |
3bd1e081 MD |
187 | { |
188 | return NULL; | |
189 | } | |
f6a9efaa | 190 | |
3bd1e081 MD |
191 | static inline |
192 | struct ltt_ust_session *trace_ust_create_session(char *path, pid_t pid, | |
193 | struct lttng_domain *domain) | |
194 | { | |
195 | return NULL; | |
196 | } | |
197 | static inline | |
198 | struct ltt_ust_channel *trace_ust_create_channel(struct lttng_channel *attr, | |
199 | char *path) | |
200 | { | |
201 | return NULL; | |
202 | } | |
203 | static inline | |
025faf73 DG |
204 | struct ltt_ust_event *trace_ust_create_event(struct lttng_event *ev, |
205 | struct lttng_filter_bytecode *filter) | |
3bd1e081 MD |
206 | { |
207 | return NULL; | |
208 | } | |
209 | static inline | |
210 | struct ltt_ust_metadata *trace_ust_create_metadata(char *path) | |
211 | { | |
212 | return NULL; | |
213 | } | |
214 | ||
215 | static inline | |
216 | void trace_ust_destroy_session(struct ltt_ust_session *session) | |
217 | { | |
218 | } | |
48842b30 | 219 | |
3bd1e081 MD |
220 | static inline |
221 | void trace_ust_destroy_metadata(struct ltt_ust_metadata *metadata) | |
222 | { | |
223 | } | |
48842b30 | 224 | |
3bd1e081 MD |
225 | static inline |
226 | void trace_ust_destroy_channel(struct ltt_ust_channel *channel) | |
227 | { | |
228 | } | |
48842b30 | 229 | |
3bd1e081 MD |
230 | static inline |
231 | void trace_ust_destroy_event(struct ltt_ust_event *event) | |
232 | { | |
233 | } | |
34378f76 DG |
234 | static inline |
235 | struct ltt_ust_context *trace_ust_create_context( | |
236 | struct lttng_event_context *ctx) | |
237 | { | |
238 | return NULL; | |
239 | } | |
37a86c61 DG |
240 | static inline struct ltt_ust_event *trace_ust_find_event(struct lttng_ht *ht, |
241 | char *name, struct lttng_filter_bytecode *filter, int loglevel) | |
242 | { | |
243 | return NULL; | |
244 | } | |
3bd1e081 | 245 | |
74d0b642 | 246 | #endif /* HAVE_LIBLTTNG_UST_CTL */ |
3bd1e081 | 247 | |
97ee3a89 | 248 | #endif /* _LTT_TRACE_UST_H */ |