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; | |
f3f0db50 DG |
127 | /* Sequence number for filters so the tracer knows the ordering. */ |
128 | uint64_t filter_seq_num; | |
97ee3a89 DG |
129 | }; |
130 | ||
74d0b642 | 131 | #ifdef HAVE_LIBLTTNG_UST_CTL |
3bd1e081 | 132 | |
97ee3a89 DG |
133 | /* |
134 | * Lookup functions. NULL is returned if not found. | |
135 | */ | |
bec39940 | 136 | struct ltt_ust_event *trace_ust_find_event_by_name(struct lttng_ht *ht, |
f6a9efaa | 137 | char *name); |
bec39940 | 138 | struct ltt_ust_channel *trace_ust_find_channel_by_name(struct lttng_ht *ht, |
f6a9efaa | 139 | char *name); |
97ee3a89 DG |
140 | |
141 | /* | |
142 | * Create functions malloc() the data structure. | |
143 | */ | |
fc4705fe DG |
144 | struct ltt_ust_session *trace_ust_create_session(char *path, |
145 | unsigned int session_id, struct lttng_domain *domain); | |
44d3bd01 DG |
146 | struct ltt_ust_channel *trace_ust_create_channel(struct lttng_channel *attr, |
147 | char *path); | |
97ee3a89 DG |
148 | struct ltt_ust_event *trace_ust_create_event(struct lttng_event *ev); |
149 | struct ltt_ust_metadata *trace_ust_create_metadata(char *path); | |
55cc08a6 DG |
150 | struct ltt_ust_context *trace_ust_create_context( |
151 | struct lttng_event_context *ctx); | |
97ee3a89 DG |
152 | |
153 | /* | |
154 | * Destroy functions free() the data structure and remove from linked list if | |
155 | * it's applies. | |
156 | */ | |
157 | void trace_ust_destroy_session(struct ltt_ust_session *session); | |
158 | void trace_ust_destroy_metadata(struct ltt_ust_metadata *metadata); | |
159 | void trace_ust_destroy_channel(struct ltt_ust_channel *channel); | |
160 | void trace_ust_destroy_event(struct ltt_ust_event *event); | |
161 | ||
74d0b642 | 162 | #else /* HAVE_LIBLTTNG_UST_CTL */ |
3bd1e081 MD |
163 | |
164 | static inline | |
bec39940 | 165 | struct ltt_ust_event *trace_ust_find_event_by_name(struct lttng_ht *ht, |
f6a9efaa | 166 | char *name) |
3bd1e081 MD |
167 | { |
168 | return NULL; | |
169 | } | |
f6a9efaa | 170 | |
3bd1e081 | 171 | static inline |
bec39940 | 172 | struct ltt_ust_channel *trace_ust_find_channel_by_name(struct lttng_ht *ht, |
f6a9efaa | 173 | char *name) |
3bd1e081 MD |
174 | { |
175 | return NULL; | |
176 | } | |
f6a9efaa | 177 | |
3bd1e081 MD |
178 | static inline |
179 | struct ltt_ust_session *trace_ust_create_session(char *path, pid_t pid, | |
180 | struct lttng_domain *domain) | |
181 | { | |
182 | return NULL; | |
183 | } | |
184 | static inline | |
185 | struct ltt_ust_channel *trace_ust_create_channel(struct lttng_channel *attr, | |
186 | char *path) | |
187 | { | |
188 | return NULL; | |
189 | } | |
190 | static inline | |
191 | struct ltt_ust_event *trace_ust_create_event(struct lttng_event *ev) | |
192 | { | |
193 | return NULL; | |
194 | } | |
195 | static inline | |
196 | struct ltt_ust_metadata *trace_ust_create_metadata(char *path) | |
197 | { | |
198 | return NULL; | |
199 | } | |
200 | ||
201 | static inline | |
202 | void trace_ust_destroy_session(struct ltt_ust_session *session) | |
203 | { | |
204 | } | |
48842b30 | 205 | |
3bd1e081 MD |
206 | static inline |
207 | void trace_ust_destroy_metadata(struct ltt_ust_metadata *metadata) | |
208 | { | |
209 | } | |
48842b30 | 210 | |
3bd1e081 MD |
211 | static inline |
212 | void trace_ust_destroy_channel(struct ltt_ust_channel *channel) | |
213 | { | |
214 | } | |
48842b30 | 215 | |
3bd1e081 MD |
216 | static inline |
217 | void trace_ust_destroy_event(struct ltt_ust_event *event) | |
218 | { | |
219 | } | |
34378f76 DG |
220 | static inline |
221 | struct ltt_ust_context *trace_ust_create_context( | |
222 | struct lttng_event_context *ctx) | |
223 | { | |
224 | return NULL; | |
225 | } | |
3bd1e081 | 226 | |
74d0b642 | 227 | #endif /* HAVE_LIBLTTNG_UST_CTL */ |
3bd1e081 | 228 | |
97ee3a89 | 229 | #endif /* _LTT_TRACE_UST_H */ |