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