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