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 DG |
23 | #include <limits.h> |
24 | #include <urcu/list.h> | |
97ee3a89 | 25 | #include <lttng/lttng.h> |
3bd1e081 MD |
26 | |
27 | /* | |
28 | * FIXME: temporary workaround: we use a lttng-tools local version of | |
29 | * lttng-ust-abi.h if UST is not found. Eventually, we should use our | |
30 | * own internal structures within lttng-tools instead of relying on the | |
31 | * UST ABI. | |
32 | */ | |
33 | #ifdef CONFIG_CONFIG_LTTNG_TOOLS_HAVE_UST | |
34 | #include <ust/lttng-ust-abi.h> | |
35 | #else | |
36 | #include "lttng-ust-abi.h" | |
37 | #endif | |
97ee3a89 | 38 | |
0177d773 DG |
39 | /* |
40 | * UST session list. | |
41 | */ | |
42 | struct ltt_ust_session_list { | |
43 | unsigned int count; | |
44 | struct cds_list_head head; | |
45 | }; | |
46 | ||
97ee3a89 DG |
47 | /* UST event list */ |
48 | struct ltt_ust_event_list { | |
49 | unsigned int count; | |
50 | struct cds_list_head head; | |
51 | }; | |
52 | ||
53 | /* UST Channel list */ | |
54 | struct ltt_ust_channel_list { | |
55 | unsigned int count; | |
56 | struct cds_list_head head; | |
57 | }; | |
58 | ||
59 | /* UST event */ | |
60 | struct ltt_ust_event { | |
61 | int handle; | |
62 | int enabled; | |
44d3bd01 DG |
63 | struct lttng_ust_context ctx; |
64 | struct lttng_ust_event attr; | |
97ee3a89 DG |
65 | struct cds_list_head list; |
66 | }; | |
67 | ||
68 | /* UST channel */ | |
69 | struct ltt_ust_channel { | |
70 | int handle; | |
71 | int enabled; | |
44d3bd01 DG |
72 | char name[LTTNG_UST_SYM_NAME_LEN]; |
73 | char trace_path[PATH_MAX]; /* Trace file path name */ | |
74 | struct lttng_ust_context ctx; | |
75 | struct lttng_ust_channel attr; | |
97ee3a89 DG |
76 | struct ltt_ust_event_list events; |
77 | struct cds_list_head list; | |
78 | }; | |
79 | ||
80 | /* UST Metadata */ | |
81 | struct ltt_ust_metadata { | |
82 | int handle; | |
83 | char *trace_path; /* Trace file path name */ | |
44d3bd01 | 84 | struct lttng_ust_channel attr; |
97ee3a89 DG |
85 | }; |
86 | ||
87 | /* UST session */ | |
88 | struct ltt_ust_session { | |
89 | int handle; | |
90 | int enabled; | |
3bd1e081 | 91 | int consumer_fds_sent; |
44d3bd01 DG |
92 | char path[PATH_MAX]; |
93 | struct lttng_domain domain; | |
97ee3a89 DG |
94 | struct ltt_ust_metadata *metadata; |
95 | struct ltt_ust_channel_list channels; | |
0177d773 | 96 | struct cds_list_head list; |
97ee3a89 DG |
97 | }; |
98 | ||
3bd1e081 MD |
99 | #ifdef CONFIG_LTTNG_TOOLS_HAVE_UST |
100 | ||
97ee3a89 DG |
101 | /* |
102 | * Lookup functions. NULL is returned if not found. | |
103 | */ | |
104 | struct ltt_ust_event *trace_ust_get_event_by_name( | |
105 | char *name, struct ltt_ust_channel *channel); | |
106 | struct ltt_ust_channel *trace_ust_get_channel_by_name( | |
107 | char *name, struct ltt_ust_session *session); | |
44d3bd01 DG |
108 | struct ltt_ust_session *trace_ust_get_session_by_pid( |
109 | struct ltt_ust_session_list *session_list, pid_t pid); | |
97ee3a89 DG |
110 | |
111 | /* | |
112 | * Create functions malloc() the data structure. | |
113 | */ | |
44d3bd01 DG |
114 | struct ltt_ust_session *trace_ust_create_session(char *path, pid_t pid, |
115 | struct lttng_domain *domain); | |
116 | struct ltt_ust_channel *trace_ust_create_channel(struct lttng_channel *attr, | |
117 | char *path); | |
97ee3a89 DG |
118 | struct ltt_ust_event *trace_ust_create_event(struct lttng_event *ev); |
119 | struct ltt_ust_metadata *trace_ust_create_metadata(char *path); | |
120 | ||
121 | /* | |
122 | * Destroy functions free() the data structure and remove from linked list if | |
123 | * it's applies. | |
124 | */ | |
125 | void trace_ust_destroy_session(struct ltt_ust_session *session); | |
126 | void trace_ust_destroy_metadata(struct ltt_ust_metadata *metadata); | |
127 | void trace_ust_destroy_channel(struct ltt_ust_channel *channel); | |
128 | void trace_ust_destroy_event(struct ltt_ust_event *event); | |
129 | ||
3bd1e081 MD |
130 | #else |
131 | ||
132 | static inline | |
133 | struct ltt_ust_event *trace_ust_get_event_by_name( | |
134 | char *name, struct ltt_ust_channel *channel) | |
135 | { | |
136 | return NULL; | |
137 | } | |
138 | static inline | |
139 | struct ltt_ust_channel *trace_ust_get_channel_by_name( | |
140 | char *name, struct ltt_ust_session *session) | |
141 | { | |
142 | return NULL; | |
143 | } | |
144 | static inline | |
145 | struct ltt_ust_session *trace_ust_get_session_by_pid( | |
146 | struct ltt_ust_session_list *session_list, pid_t pid) | |
147 | { | |
148 | return NULL; | |
149 | } | |
150 | ||
151 | static inline | |
152 | struct ltt_ust_session *trace_ust_create_session(char *path, pid_t pid, | |
153 | struct lttng_domain *domain) | |
154 | { | |
155 | return NULL; | |
156 | } | |
157 | static inline | |
158 | struct ltt_ust_channel *trace_ust_create_channel(struct lttng_channel *attr, | |
159 | char *path) | |
160 | { | |
161 | return NULL; | |
162 | } | |
163 | static inline | |
164 | struct ltt_ust_event *trace_ust_create_event(struct lttng_event *ev) | |
165 | { | |
166 | return NULL; | |
167 | } | |
168 | static inline | |
169 | struct ltt_ust_metadata *trace_ust_create_metadata(char *path) | |
170 | { | |
171 | return NULL; | |
172 | } | |
173 | ||
174 | static inline | |
175 | void trace_ust_destroy_session(struct ltt_ust_session *session) | |
176 | { | |
177 | } | |
178 | static inline | |
179 | void trace_ust_destroy_metadata(struct ltt_ust_metadata *metadata) | |
180 | { | |
181 | } | |
182 | static inline | |
183 | void trace_ust_destroy_channel(struct ltt_ust_channel *channel) | |
184 | { | |
185 | } | |
186 | static inline | |
187 | void trace_ust_destroy_event(struct ltt_ust_event *event) | |
188 | { | |
189 | } | |
190 | ||
191 | #endif | |
192 | ||
97ee3a89 | 193 | #endif /* _LTT_TRACE_UST_H */ |