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