Commit | Line | Data |
---|---|---|
97ee3a89 DG |
1 | /* |
2 | * Copyright (C) 2011 - David Goulet <david.goulet@polymtl.ca> | |
3 | * | |
4 | * This program is free software; you can redistribute it and/or | |
5 | * modify it under the terms of the GNU General Public License | |
6 | * as published by the Free Software Foundation; only version 2 | |
7 | * of the License. | |
8 | * | |
9 | * This program is distributed in the hope that it will be useful, | |
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | * GNU General Public License for more details. | |
13 | * | |
14 | * You should have received a copy of the GNU General Public License | |
15 | * along with this program; if not, write to the Free Software | |
16 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |
17 | */ | |
18 | ||
19 | #ifndef _LTT_TRACE_UST_H | |
20 | #define _LTT_TRACE_UST_H | |
21 | ||
3bd1e081 | 22 | #include <config.h> |
97ee3a89 | 23 | #include <limits.h> |
f6a9efaa | 24 | #include <urcu.h> |
97ee3a89 | 25 | #include <urcu/list.h> |
97ee3a89 | 26 | #include <lttng/lttng.h> |
3bd1e081 | 27 | |
48842b30 | 28 | #include "ust-ctl.h" |
97ee3a89 | 29 | |
f6a9efaa | 30 | #include "../hashtable/rculfhash.h" |
0177d773 | 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; | |
41 | struct cds_lfht_node node; | |
97ee3a89 DG |
42 | }; |
43 | ||
44 | /* UST event */ | |
45 | struct ltt_ust_event { | |
f6a9efaa DG |
46 | struct lttng_ust_event attr; |
47 | struct cds_lfht *ctx; | |
48 | struct cds_lfht_node node; | |
2bdd86d4 MD |
49 | }; |
50 | ||
51 | /* UST stream */ | |
52 | struct ltt_ust_stream { | |
48842b30 DG |
53 | int handle; |
54 | char pathname[PATH_MAX]; | |
2bdd86d4 | 55 | struct object_data *obj; |
48842b30 | 56 | struct cds_lfht_node node; |
97ee3a89 DG |
57 | }; |
58 | ||
59 | /* UST channel */ | |
60 | struct ltt_ust_channel { | |
44d3bd01 | 61 | char name[LTTNG_UST_SYM_NAME_LEN]; |
48842b30 | 62 | char pathname[PATH_MAX]; |
f6a9efaa DG |
63 | struct lttng_ust_channel attr; |
64 | struct cds_lfht *ctx; | |
65 | struct cds_lfht *events; | |
66 | struct cds_lfht_node node; | |
97ee3a89 DG |
67 | }; |
68 | ||
69 | /* UST Metadata */ | |
70 | struct ltt_ust_metadata { | |
71 | int handle; | |
2bdd86d4 | 72 | struct object_data *obj; |
f6a9efaa | 73 | char pathname[PATH_MAX]; /* Trace file path name */ |
44d3bd01 | 74 | struct lttng_ust_channel attr; |
2bdd86d4 | 75 | struct object_data *stream_obj; |
97ee3a89 DG |
76 | }; |
77 | ||
f6a9efaa DG |
78 | /* UST domain global (LTTNG_DOMAIN_UST) */ |
79 | struct ltt_ust_domain_global { | |
80 | struct cds_lfht *channels; | |
81 | }; | |
82 | ||
83 | /* UST domain pid (LTTNG_DOMAIN_UST_PID) */ | |
84 | struct ltt_ust_domain_pid { | |
85 | pid_t pid; | |
86 | struct cds_lfht *channels; | |
87 | struct cds_lfht_node node; | |
88 | }; | |
89 | ||
90 | /* UST domain exec name (LTTNG_DOMAIN_UST_EXEC_NAME) */ | |
91 | struct ltt_ust_domain_exec { | |
92 | char exec_name[LTTNG_UST_SYM_NAME_LEN]; | |
93 | struct cds_lfht *channels; | |
94 | struct cds_lfht_node node; | |
95 | }; | |
96 | ||
97ee3a89 DG |
97 | /* UST session */ |
98 | struct ltt_ust_session { | |
48842b30 | 99 | int uid; /* Unique identifier of session */ |
3bd1e081 | 100 | int consumer_fds_sent; |
2bdd86d4 | 101 | int consumer_fd; |
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 DG |
108 | */ |
109 | struct cds_lfht *domain_pid; | |
110 | struct cds_lfht *domain_exec; | |
97ee3a89 DG |
111 | }; |
112 | ||
3bd1e081 MD |
113 | #ifdef CONFIG_LTTNG_TOOLS_HAVE_UST |
114 | ||
97ee3a89 DG |
115 | /* |
116 | * Lookup functions. NULL is returned if not found. | |
117 | */ | |
f6a9efaa DG |
118 | struct ltt_ust_event *trace_ust_find_event_by_name(struct cds_lfht *ht, |
119 | char *name); | |
120 | struct ltt_ust_channel *trace_ust_find_channel_by_name(struct cds_lfht *ht, | |
121 | char *name); | |
97ee3a89 DG |
122 | |
123 | /* | |
124 | * Create functions malloc() the data structure. | |
125 | */ | |
48842b30 | 126 | struct ltt_ust_session *trace_ust_create_session(char *path, unsigned int uid, |
44d3bd01 DG |
127 | struct lttng_domain *domain); |
128 | struct ltt_ust_channel *trace_ust_create_channel(struct lttng_channel *attr, | |
129 | char *path); | |
97ee3a89 DG |
130 | struct ltt_ust_event *trace_ust_create_event(struct lttng_event *ev); |
131 | struct ltt_ust_metadata *trace_ust_create_metadata(char *path); | |
132 | ||
133 | /* | |
134 | * Destroy functions free() the data structure and remove from linked list if | |
135 | * it's applies. | |
136 | */ | |
137 | void trace_ust_destroy_session(struct ltt_ust_session *session); | |
138 | void trace_ust_destroy_metadata(struct ltt_ust_metadata *metadata); | |
139 | void trace_ust_destroy_channel(struct ltt_ust_channel *channel); | |
140 | void trace_ust_destroy_event(struct ltt_ust_event *event); | |
141 | ||
3bd1e081 MD |
142 | #else |
143 | ||
144 | static inline | |
f6a9efaa DG |
145 | struct ltt_ust_event *trace_ust_find_event_by_name(struct cds_lfht *ht, |
146 | char *name) | |
3bd1e081 MD |
147 | { |
148 | return NULL; | |
149 | } | |
f6a9efaa | 150 | |
3bd1e081 | 151 | static inline |
f6a9efaa DG |
152 | struct ltt_ust_channel *trace_ust_find_channel_by_name(struct cds_lfht *ht, |
153 | char *name) | |
3bd1e081 MD |
154 | { |
155 | return NULL; | |
156 | } | |
f6a9efaa | 157 | |
3bd1e081 MD |
158 | static inline |
159 | struct ltt_ust_session *trace_ust_create_session(char *path, pid_t pid, | |
160 | struct lttng_domain *domain) | |
161 | { | |
162 | return NULL; | |
163 | } | |
164 | static inline | |
165 | struct ltt_ust_channel *trace_ust_create_channel(struct lttng_channel *attr, | |
166 | char *path) | |
167 | { | |
168 | return NULL; | |
169 | } | |
170 | static inline | |
171 | struct ltt_ust_event *trace_ust_create_event(struct lttng_event *ev) | |
172 | { | |
173 | return NULL; | |
174 | } | |
175 | static inline | |
176 | struct ltt_ust_metadata *trace_ust_create_metadata(char *path) | |
177 | { | |
178 | return NULL; | |
179 | } | |
180 | ||
181 | static inline | |
182 | void trace_ust_destroy_session(struct ltt_ust_session *session) | |
183 | { | |
184 | } | |
48842b30 | 185 | |
3bd1e081 MD |
186 | static inline |
187 | void trace_ust_destroy_metadata(struct ltt_ust_metadata *metadata) | |
188 | { | |
189 | } | |
48842b30 | 190 | |
3bd1e081 MD |
191 | static inline |
192 | void trace_ust_destroy_channel(struct ltt_ust_channel *channel) | |
193 | { | |
194 | } | |
48842b30 | 195 | |
3bd1e081 MD |
196 | static inline |
197 | void trace_ust_destroy_event(struct ltt_ust_event *event) | |
198 | { | |
199 | } | |
200 | ||
48842b30 | 201 | #endif /* CONFIG_CONFIG_LTTNG_TOOLS_HAVE_UST */ |
3bd1e081 | 202 | |
97ee3a89 | 203 | #endif /* _LTT_TRACE_UST_H */ |