Implement filter bytecode support in lttng-session, and parse filter string
[lttng-tools.git] / src / bin / lttng-sessiond / ust-app.h
... / ...
CommitLineData
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_UST_APP_H
19#define _LTT_UST_APP_H
20
21#include <stdint.h>
22
23#include "trace-ust.h"
24
25/* lttng-ust supported version. */
26#define LTTNG_UST_COMM_MAJOR 2 /* comm protocol major version */
27#define UST_APP_MAJOR_VERSION 2 /* UST version supported */
28
29#define UST_APP_EVENT_LIST_SIZE 32
30
31struct lttng_filter_bytecode;
32struct lttng_ust_filter_bytecode;
33
34extern int ust_consumerd64_fd, ust_consumerd32_fd;
35
36/*
37 * Application registration data structure.
38 */
39struct ust_register_msg {
40 uint32_t major;
41 uint32_t minor;
42 pid_t pid;
43 pid_t ppid;
44 uid_t uid;
45 gid_t gid;
46 uint32_t bits_per_long;
47 char name[16];
48};
49
50/*
51 * Global applications HT used by the session daemon. This table is indexed by
52 * PID using the pid_n node and pid value of an ust_app.
53 */
54struct lttng_ht *ust_app_ht;
55
56/*
57 * Global applications HT used by the session daemon. This table is indexed by
58 * socket using the sock_n node and sock value of an ust_app.
59 */
60struct lttng_ht *ust_app_ht_by_sock;
61
62struct ust_app_ctx {
63 int handle;
64 struct lttng_ust_context ctx;
65 struct lttng_ust_object_data *obj;
66 struct lttng_ht_node_ulong node;
67};
68
69struct ust_app_event {
70 int enabled;
71 int handle;
72 struct lttng_ust_object_data *obj;
73 struct lttng_ust_event attr;
74 char name[LTTNG_UST_SYM_NAME_LEN];
75 struct lttng_ht *ctx;
76 struct lttng_ht_node_str node;
77 struct lttng_ust_filter_bytecode *filter;
78};
79
80struct ust_app_channel {
81 int enabled;
82 int handle;
83 char name[LTTNG_UST_SYM_NAME_LEN];
84 struct lttng_ust_channel attr;
85 struct lttng_ust_object_data *obj;
86 struct ltt_ust_stream_list streams;
87 struct lttng_ht *ctx;
88 struct lttng_ht *events;
89 struct lttng_ht_node_str node;
90};
91
92struct ust_app_session {
93 int enabled;
94 /* started: has the session been in started state at any time ? */
95 int started; /* allows detection of start vs restart. */
96 int handle; /* used has unique identifier for app session */
97 int id; /* session unique identifier */
98 struct ltt_ust_metadata *metadata;
99 struct lttng_ht *channels; /* Registered channels */
100 struct lttng_ht_node_ulong node;
101 char path[PATH_MAX];
102 /* UID/GID of the user owning the session */
103 uid_t uid;
104 gid_t gid;
105};
106
107/*
108 * Registered traceable applications. Libust registers to the session daemon
109 * and a linked list is kept of all running traceable app.
110 */
111struct ust_app {
112 int sock;
113 pid_t pid;
114 pid_t ppid;
115 uid_t uid; /* User ID that owns the apps */
116 gid_t gid; /* Group ID that owns the apps */
117 int bits_per_long;
118 int compatible; /* If the lttng-ust tracer version does not match the
119 supported version of the session daemon, this flag is
120 set to 0 (NOT compatible) else 1. */
121 struct lttng_ust_tracer_version version;
122 uint32_t v_major; /* Verion major number */
123 uint32_t v_minor; /* Verion minor number */
124 char name[17]; /* Process name (short) */
125 struct lttng_ht *sessions;
126 struct lttng_ht_node_ulong pid_n;
127 struct lttng_ht_node_ulong sock_n;
128};
129
130#ifdef HAVE_LIBLTTNG_UST_CTL
131
132int ust_app_register(struct ust_register_msg *msg, int sock);
133static inline
134int ust_app_register_done(int sock)
135{
136 return ustctl_register_done(sock);
137}
138void ust_app_unregister(int sock);
139unsigned long ust_app_list_count(void);
140int ust_app_start_trace(struct ltt_ust_session *usess, struct ust_app *app);
141int ust_app_stop_trace(struct ltt_ust_session *usess, struct ust_app *app);
142int ust_app_start_trace_all(struct ltt_ust_session *usess);
143int ust_app_stop_trace_all(struct ltt_ust_session *usess);
144int ust_app_destroy_trace(struct ltt_ust_session *usess, struct ust_app *app);
145int ust_app_destroy_trace_all(struct ltt_ust_session *usess);
146int ust_app_list_events(struct lttng_event **events);
147int ust_app_list_event_fields(struct lttng_event_field **fields);
148int ust_app_create_channel_glb(struct ltt_ust_session *usess,
149 struct ltt_ust_channel *uchan);
150int ust_app_create_event_glb(struct ltt_ust_session *usess,
151 struct ltt_ust_channel *uchan, struct ltt_ust_event *uevent);
152int ust_app_disable_event_pid(struct ltt_ust_session *usess,
153 struct ltt_ust_channel *uchan, struct ltt_ust_event *uevent,
154 pid_t pid);
155int ust_app_enable_event_pid(struct ltt_ust_session *usess,
156 struct ltt_ust_channel *uchan, struct ltt_ust_event *uevent,
157 pid_t pid);
158int ust_app_disable_channel_glb(struct ltt_ust_session *usess,
159 struct ltt_ust_channel *uchan);
160int ust_app_enable_channel_glb(struct ltt_ust_session *usess,
161 struct ltt_ust_channel *uchan);
162int ust_app_enable_event_glb(struct ltt_ust_session *usess,
163 struct ltt_ust_channel *uchan, struct ltt_ust_event *uevent);
164int ust_app_disable_all_event_glb(struct ltt_ust_session *usess,
165 struct ltt_ust_channel *uchan);
166int ust_app_enable_all_event_glb(struct ltt_ust_session *usess,
167 struct ltt_ust_channel *uchan);
168int ust_app_disable_event_glb(struct ltt_ust_session *usess,
169 struct ltt_ust_channel *uchan, struct ltt_ust_event *uevent);
170int ust_app_add_ctx_event_glb(struct ltt_ust_session *usess,
171 struct ltt_ust_channel *uchan, struct ltt_ust_event *uevent,
172 struct ltt_ust_context *uctx);
173int ust_app_add_ctx_channel_glb(struct ltt_ust_session *usess,
174 struct ltt_ust_channel *uchan, struct ltt_ust_context *uctx);
175int ust_app_set_filter_event_glb(struct ltt_ust_session *usess,
176 struct ltt_ust_channel *uchan, struct ltt_ust_event *uevent,
177 struct lttng_filter_bytecode *bytecode);
178void ust_app_global_update(struct ltt_ust_session *usess, int sock);
179
180void ust_app_clean_list(void);
181void ust_app_ht_alloc(void);
182struct lttng_ht *ust_app_get_ht(void);
183struct ust_app *ust_app_find_by_pid(pid_t pid);
184int ust_app_validate_version(int sock);
185int ust_app_calibrate_glb(struct lttng_ust_calibrate *calibrate);
186
187#else /* HAVE_LIBLTTNG_UST_CTL */
188
189static inline
190int ust_app_destroy_trace_all(struct ltt_ust_session *usess)
191{
192 return 0;
193}
194static inline
195int ust_app_start_trace(struct ltt_ust_session *usess, struct ust_app *app)
196{
197 return 0;
198}
199static inline
200int ust_app_start_trace_all(struct ltt_ust_session *usess)
201{
202 return 0;
203}
204static inline
205int ust_app_stop_trace_all(struct ltt_ust_session *usess)
206{
207 return 0;
208}
209static inline
210int ust_app_list_events(struct lttng_event **events)
211{
212 return -ENOSYS;
213}
214static inline
215int ust_app_list_event_fields(struct lttng_event_field **fields)
216{
217 return -ENOSYS;
218}
219static inline
220int ust_app_register(struct ust_register_msg *msg, int sock)
221{
222 return -ENOSYS;
223}
224static inline
225int ust_app_register_done(int sock)
226{
227 return -ENOSYS;
228}
229static inline
230void ust_app_unregister(int sock)
231{
232}
233static inline
234unsigned int ust_app_list_count(void)
235{
236 return 0;
237}
238static inline
239void ust_app_lock_list(void)
240{
241}
242static inline
243void ust_app_unlock_list(void)
244{
245}
246static inline
247void ust_app_clean_list(void)
248{
249}
250static inline
251struct ust_app_list *ust_app_get_list(void)
252{
253 return NULL;
254}
255static inline
256struct ust_app *ust_app_get_by_pid(pid_t pid)
257{
258 return NULL;
259}
260static inline
261struct lttng_ht *ust_app_get_ht(void)
262{
263 return NULL;
264}
265static inline
266void ust_app_ht_alloc(void)
267{}
268static inline
269void ust_app_global_update(struct ltt_ust_session *usess, int sock)
270{}
271static inline
272int ust_app_disable_channel_glb(struct ltt_ust_session *usess,
273 struct ltt_ust_channel *uchan)
274{
275 return 0;
276}
277static inline
278int ust_app_enable_channel_glb(struct ltt_ust_session *usess,
279 struct ltt_ust_channel *uchan)
280{
281 return 0;
282}
283static inline
284int ust_app_create_channel_glb(struct ltt_ust_session *usess,
285 struct ltt_ust_channel *uchan)
286{
287 return 0;
288}
289static inline
290int ust_app_disable_all_event_glb(struct ltt_ust_session *usess,
291 struct ltt_ust_channel *uchan)
292{
293 return 0;
294}
295static inline
296int ust_app_enable_all_event_glb(struct ltt_ust_session *usess,
297 struct ltt_ust_channel *uchan)
298{
299 return 0;
300}
301static inline
302int ust_app_create_event_glb(struct ltt_ust_session *usess,
303 struct ltt_ust_channel *uchan, struct ltt_ust_event *uevent)
304{
305 return 0;
306}
307static inline
308int ust_app_disable_event_glb(struct ltt_ust_session *usess,
309 struct ltt_ust_channel *uchan, struct ltt_ust_event *uevent)
310{
311 return 0;
312}
313static inline
314int ust_app_enable_event_glb(struct ltt_ust_session *usess,
315 struct ltt_ust_channel *uchan, struct ltt_ust_event *uevent)
316{
317 return 0;
318}
319static inline
320int ust_app_add_ctx_event_glb(struct ltt_ust_session *usess,
321 struct ltt_ust_channel *uchan, struct ltt_ust_event *uevent,
322 struct ltt_ust_context *uctx)
323{
324 return 0;
325}
326static inline
327int ust_app_add_ctx_channel_glb(struct ltt_ust_session *usess,
328 struct ltt_ust_channel *uchan, struct ltt_ust_context *uctx)
329{
330 return 0;
331}
332static inline
333int ust_app_enable_event_pid(struct ltt_ust_session *usess,
334 struct ltt_ust_channel *uchan, struct ltt_ust_event *uevent,
335 pid_t pid)
336{
337 return 0;
338}
339static inline
340int ust_app_disable_event_pid(struct ltt_ust_session *usess,
341 struct ltt_ust_channel *uchan, struct ltt_ust_event *uevent,
342 pid_t pid)
343{
344 return 0;
345}
346static inline
347int ust_app_validate_version(int sock)
348{
349 return 0;
350}
351static inline
352int ust_app_calibrate_glb(struct lttng_ust_calibrate *calibrate)
353{
354 return 0;
355}
356
357#endif /* HAVE_LIBLTTNG_UST_CTL */
358
359#endif /* _LTT_UST_APP_H */
This page took 0.02344 seconds and 4 git commands to generate.