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