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