Fix: Conditionally disable test requiring shared libs
[lttng-tools.git] / src / bin / lttng-sessiond / ust-app.h
CommitLineData
91d76f53
DG
1/*
2 * Copyright (C) 2011 - David Goulet <david.goulet@polymtl.ca>
3 *
d14d33bf
AM
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.
91d76f53
DG
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 *
d14d33bf
AM
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.
91d76f53
DG
16 */
17
f6a9efaa
DG
18#ifndef _LTT_UST_APP_H
19#define _LTT_UST_APP_H
91d76f53 20
099e26bd 21#include <stdint.h>
1e307fab 22
44d3bd01
DG
23#include "trace-ust.h"
24
e0c7ec2b 25/* lttng-ust supported version. */
3f2c5fcc 26#define LTTNG_UST_COMM_MAJOR 2 /* comm protocol major version */
68264071 27#define UST_APP_MAJOR_VERSION 3 /* Internal UST version supported */
e0c7ec2b 28
b551a063
DG
29#define UST_APP_EVENT_LIST_SIZE 32
30
53a80697
MD
31struct lttng_filter_bytecode;
32struct lttng_ust_filter_bytecode;
33
7753dea8 34extern int ust_consumerd64_fd, ust_consumerd32_fd;
ba5d816e 35
18eace3b
DG
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
099e26bd
DG
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;
0df502fd 52 uint32_t bits_per_long;
099e26bd
DG
53 char name[16];
54};
55
48842b30 56/*
852d0037
DG
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.
48842b30 59 */
bec39940 60struct lttng_ht *ust_app_ht;
f6a9efaa 61
852d0037
DG
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;
91d76f53 67
030a66fa
DG
68/* Stream list containing ust_app_stream. */
69struct ust_app_stream_list {
70 unsigned int count;
71 struct cds_list_head head;
72};
73
55cc08a6
DG
74struct ust_app_ctx {
75 int handle;
76 struct lttng_ust_context ctx;
77 struct lttng_ust_object_data *obj;
bec39940 78 struct lttng_ht_node_ulong node;
55cc08a6
DG
79};
80
48842b30
DG
81struct ust_app_event {
82 int enabled;
83 int handle;
13161846 84 struct lttng_ust_object_data *obj;
284d8f55 85 struct lttng_ust_event attr;
48842b30 86 char name[LTTNG_UST_SYM_NAME_LEN];
bec39940 87 struct lttng_ht_node_str node;
53a80697 88 struct lttng_ust_filter_bytecode *filter;
48842b30
DG
89};
90
030a66fa
DG
91struct ust_app_stream {
92 int handle;
93 char pathname[PATH_MAX];
94 /* Format is %s_%d respectively channel name and CPU number. */
95 char name[DEFAULT_STREAM_NAME_LEN];
96 struct lttng_ust_object_data *obj;
97 /* Using a list of streams to keep order. */
98 struct cds_list_head list;
99};
100
48842b30
DG
101struct ust_app_channel {
102 int enabled;
103 int handle;
104 char name[LTTNG_UST_SYM_NAME_LEN];
2fe6e7f5 105 struct lttng_ust_channel_attr attr;
13161846 106 struct lttng_ust_object_data *obj;
030a66fa 107 struct ust_app_stream_list streams;
bec39940
DG
108 struct lttng_ht *ctx;
109 struct lttng_ht *events;
110 struct lttng_ht_node_str node;
48842b30
DG
111};
112
113struct ust_app_session {
114 int enabled;
8be98f9a
MD
115 /* started: has the session been in started state at any time ? */
116 int started; /* allows detection of start vs restart. */
a991f516
MD
117 int handle; /* used has unique identifier for app session */
118 int id; /* session unique identifier */
48842b30 119 struct ltt_ust_metadata *metadata;
bec39940
DG
120 struct lttng_ht *channels; /* Registered channels */
121 struct lttng_ht_node_ulong node;
122 char path[PATH_MAX];
6df2e2c9
MD
123 /* UID/GID of the user owning the session */
124 uid_t uid;
125 gid_t gid;
d42f20df 126 struct cds_list_head teardown_node;
48842b30
DG
127};
128
f6a9efaa
DG
129/*
130 * Registered traceable applications. Libust registers to the session daemon
050349bb 131 * and a linked list is kept of all running traceable app.
91d76f53 132 */
56fff090 133struct ust_app {
852d0037
DG
134 int sock;
135 pid_t pid;
099e26bd
DG
136 pid_t ppid;
137 uid_t uid; /* User ID that owns the apps */
aea829b3 138 gid_t gid; /* Group ID that owns the apps */
7753dea8 139 int bits_per_long;
e0c7ec2b
DG
140 int compatible; /* If the lttng-ust tracer version does not match the
141 supported version of the session daemon, this flag is
142 set to 0 (NOT compatible) else 1. */
143 struct lttng_ust_tracer_version version;
099e26bd
DG
144 uint32_t v_major; /* Verion major number */
145 uint32_t v_minor; /* Verion minor number */
146 char name[17]; /* Process name (short) */
bec39940 147 struct lttng_ht *sessions;
852d0037
DG
148 struct lttng_ht_node_ulong pid_n;
149 struct lttng_ht_node_ulong sock_n;
d42f20df
DG
150 /*
151 * This is a list of ust app session that, once the app is going into
152 * teardown mode, in the RCU call, each node in this list is removed and
153 * deleted.
154 *
155 * Element of the list are added when an application unregisters after each
156 * ht_del of ust_app_session associated to this app. This list is NOT used
157 * when a session is destroyed.
158 */
159 struct cds_list_head teardown_head;
91d76f53
DG
160};
161
74d0b642 162#ifdef HAVE_LIBLTTNG_UST_CTL
3bd1e081 163
56fff090 164int ust_app_register(struct ust_register_msg *msg, int sock);
f2ca2e25
GF
165static inline
166int ust_app_register_done(int sock)
167{
168 return ustctl_register_done(sock);
169}
56fff090 170void ust_app_unregister(int sock);
f6a9efaa 171unsigned long ust_app_list_count(void);
421cb601 172int ust_app_start_trace(struct ltt_ust_session *usess, struct ust_app *app);
8be98f9a 173int ust_app_stop_trace(struct ltt_ust_session *usess, struct ust_app *app);
421cb601 174int ust_app_start_trace_all(struct ltt_ust_session *usess);
8be98f9a 175int ust_app_stop_trace_all(struct ltt_ust_session *usess);
84cd17c6 176int ust_app_destroy_trace_all(struct ltt_ust_session *usess);
b551a063 177int ust_app_list_events(struct lttng_event **events);
f37d259d 178int ust_app_list_event_fields(struct lttng_event_field **fields);
35a9059d
DG
179int ust_app_create_channel_glb(struct ltt_ust_session *usess,
180 struct ltt_ust_channel *uchan);
181int ust_app_create_event_glb(struct ltt_ust_session *usess,
182 struct ltt_ust_channel *uchan, struct ltt_ust_event *uevent);
7f79d3a1
DG
183int ust_app_disable_event_pid(struct ltt_ust_session *usess,
184 struct ltt_ust_channel *uchan, struct ltt_ust_event *uevent,
185 pid_t pid);
76d45b40
DG
186int ust_app_enable_event_pid(struct ltt_ust_session *usess,
187 struct ltt_ust_channel *uchan, struct ltt_ust_event *uevent,
188 pid_t pid);
35a9059d 189int ust_app_disable_channel_glb(struct ltt_ust_session *usess,
78f0bacd 190 struct ltt_ust_channel *uchan);
35a9059d 191int ust_app_enable_channel_glb(struct ltt_ust_session *usess,
78f0bacd 192 struct ltt_ust_channel *uchan);
35a9059d 193int ust_app_enable_event_glb(struct ltt_ust_session *usess,
edb67388 194 struct ltt_ust_channel *uchan, struct ltt_ust_event *uevent);
35a9059d
DG
195int ust_app_disable_all_event_glb(struct ltt_ust_session *usess,
196 struct ltt_ust_channel *uchan);
197int ust_app_enable_all_event_glb(struct ltt_ust_session *usess,
9730260e 198 struct ltt_ust_channel *uchan);
35a9059d
DG
199int ust_app_disable_event_glb(struct ltt_ust_session *usess,
200 struct ltt_ust_channel *uchan, struct ltt_ust_event *uevent);
55cc08a6
DG
201int ust_app_add_ctx_channel_glb(struct ltt_ust_session *usess,
202 struct ltt_ust_channel *uchan, struct ltt_ust_context *uctx);
487cf67c 203void ust_app_global_update(struct ltt_ust_session *usess, int sock);
91d76f53 204
56fff090 205void ust_app_clean_list(void);
f6a9efaa 206void ust_app_ht_alloc(void);
bec39940 207struct lttng_ht *ust_app_get_ht(void);
f6a9efaa 208struct ust_app *ust_app_find_by_pid(pid_t pid);
e0c7ec2b 209int ust_app_validate_version(int sock);
4466912f 210int ust_app_calibrate_glb(struct lttng_ust_calibrate *calibrate);
44d3bd01 211
74d0b642 212#else /* HAVE_LIBLTTNG_UST_CTL */
3bd1e081 213
cc920def
DG
214static inline
215int ust_app_destroy_trace_all(struct ltt_ust_session *usess)
216{
217 return 0;
218}
d974f197 219static inline
421cb601
DG
220int ust_app_start_trace(struct ltt_ust_session *usess, struct ust_app *app)
221{
222 return 0;
223}
224static inline
225int ust_app_start_trace_all(struct ltt_ust_session *usess)
d974f197 226{
5cf5d0e7 227 return 0;
d974f197 228}
3bd1e081 229static inline
cc920def
DG
230int ust_app_stop_trace_all(struct ltt_ust_session *usess)
231{
232 return 0;
233}
234static inline
b551a063
DG
235int ust_app_list_events(struct lttng_event **events)
236{
db7c0497 237 return -ENOSYS;
b551a063
DG
238}
239static inline
da0bdb87
MD
240int ust_app_list_event_fields(struct lttng_event_field **fields)
241{
242 return -ENOSYS;
243}
244static inline
3bd1e081
MD
245int ust_app_register(struct ust_register_msg *msg, int sock)
246{
247 return -ENOSYS;
248}
249static inline
f2ca2e25
GF
250int ust_app_register_done(int sock)
251{
252 return -ENOSYS;
253}
254static inline
3bd1e081
MD
255void ust_app_unregister(int sock)
256{
257}
258static inline
259unsigned int ust_app_list_count(void)
260{
261 return 0;
262}
3bd1e081
MD
263static inline
264void ust_app_lock_list(void)
265{
266}
267static inline
268void ust_app_unlock_list(void)
269{
270}
271static inline
272void ust_app_clean_list(void)
273{
274}
275static inline
276struct ust_app_list *ust_app_get_list(void)
277{
278 return NULL;
279}
280static inline
281struct ust_app *ust_app_get_by_pid(pid_t pid)
282{
283 return NULL;
284}
48842b30 285static inline
bec39940 286struct lttng_ht *ust_app_get_ht(void)
d974f197
DG
287{
288 return NULL;
289}
290static inline
291void ust_app_ht_alloc(void)
cc920def
DG
292{}
293static inline
294void ust_app_global_update(struct ltt_ust_session *usess, int sock)
295{}
296static inline
35a9059d 297int ust_app_disable_channel_glb(struct ltt_ust_session *usess,
cc920def 298 struct ltt_ust_channel *uchan)
d974f197 299{
cc920def 300 return 0;
d974f197 301}
487cf67c 302static inline
35a9059d 303int ust_app_enable_channel_glb(struct ltt_ust_session *usess,
cc920def 304 struct ltt_ust_channel *uchan)
487cf67c 305{
cc920def
DG
306 return 0;
307}
308static inline
35a9059d 309int ust_app_create_channel_glb(struct ltt_ust_session *usess,
cc920def
DG
310 struct ltt_ust_channel *uchan)
311{
312 return 0;
313}
314static inline
35a9059d
DG
315int ust_app_disable_all_event_glb(struct ltt_ust_session *usess,
316 struct ltt_ust_channel *uchan)
cc920def
DG
317{
318 return 0;
319}
320static inline
35a9059d 321int ust_app_enable_all_event_glb(struct ltt_ust_session *usess,
cc920def
DG
322 struct ltt_ust_channel *uchan)
323{
324 return 0;
325}
326static inline
35a9059d
DG
327int ust_app_create_event_glb(struct ltt_ust_session *usess,
328 struct ltt_ust_channel *uchan, struct ltt_ust_event *uevent)
329{
330 return 0;
331}
332static inline
333int ust_app_disable_event_glb(struct ltt_ust_session *usess,
cc920def
DG
334 struct ltt_ust_channel *uchan, struct ltt_ust_event *uevent)
335{
336 return 0;
487cf67c 337}
edb67388 338static inline
35a9059d 339int ust_app_enable_event_glb(struct ltt_ust_session *usess,
edb67388
DG
340 struct ltt_ust_channel *uchan, struct ltt_ust_event *uevent)
341{
342 return 0;
343}
55cc08a6 344static inline
55cc08a6
DG
345int ust_app_add_ctx_channel_glb(struct ltt_ust_session *usess,
346 struct ltt_ust_channel *uchan, struct ltt_ust_context *uctx)
347{
348 return 0;
349}
76d45b40
DG
350static inline
351int ust_app_enable_event_pid(struct ltt_ust_session *usess,
352 struct ltt_ust_channel *uchan, struct ltt_ust_event *uevent,
353 pid_t pid)
354{
355 return 0;
356}
7f79d3a1
DG
357static inline
358int ust_app_disable_event_pid(struct ltt_ust_session *usess,
359 struct ltt_ust_channel *uchan, struct ltt_ust_event *uevent,
360 pid_t pid)
361{
362 return 0;
363}
e0c7ec2b
DG
364static inline
365int ust_app_validate_version(int sock)
366{
367 return 0;
368}
4466912f
DG
369static inline
370int ust_app_calibrate_glb(struct lttng_ust_calibrate *calibrate)
371{
372 return 0;
373}
48842b30 374
74d0b642 375#endif /* HAVE_LIBLTTNG_UST_CTL */
3bd1e081 376
f6a9efaa 377#endif /* _LTT_UST_APP_H */
This page took 0.056394 seconds and 5 git commands to generate.