2 * Copyright (C) 2011 - David Goulet <david.goulet@polymtl.ca>
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.
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.
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.
18 #ifndef _LTT_UST_APP_H
19 #define _LTT_UST_APP_H
23 #include "trace-ust.h"
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 */
29 #define UST_APP_EVENT_LIST_SIZE 32
31 struct lttng_filter_bytecode
;
32 struct lttng_ust_filter_bytecode
;
34 extern int ust_consumerd64_fd
, ust_consumerd32_fd
;
36 struct ust_app_ht_key
{
38 const struct lttng_ust_filter_bytecode
*filter
;
39 enum lttng_ust_loglevel_type loglevel
;
43 * Application registration data structure.
45 struct ust_register_msg
{
52 uint32_t bits_per_long
;
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.
60 struct lttng_ht
*ust_app_ht
;
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.
66 struct lttng_ht
*ust_app_ht_by_sock
;
68 /* Stream list containing ust_app_stream. */
69 struct ust_app_stream_list
{
71 struct cds_list_head head
;
76 struct lttng_ust_context ctx
;
77 struct lttng_ust_object_data
*obj
;
78 struct lttng_ht_node_ulong node
;
81 struct ust_app_event
{
84 struct lttng_ust_object_data
*obj
;
85 struct lttng_ust_event attr
;
86 char name
[LTTNG_UST_SYM_NAME_LEN
];
87 struct lttng_ht_node_str node
;
88 struct lttng_ust_filter_bytecode
*filter
;
91 struct ust_app_stream
{
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
;
101 struct ust_app_channel
{
104 char name
[LTTNG_UST_SYM_NAME_LEN
];
105 struct lttng_ust_channel attr
;
106 struct lttng_ust_object_data
*obj
;
107 struct ust_app_stream_list streams
;
108 struct lttng_ht
*ctx
;
109 struct lttng_ht
*events
;
110 struct lttng_ht_node_str node
;
113 struct ust_app_session
{
115 /* started: has the session been in started state at any time ? */
116 int started
; /* allows detection of start vs restart. */
117 int handle
; /* used has unique identifier for app session */
118 int id
; /* session unique identifier */
119 struct ltt_ust_metadata
*metadata
;
120 struct lttng_ht
*channels
; /* Registered channels */
121 struct lttng_ht_node_ulong node
;
123 /* UID/GID of the user owning the session */
126 struct cds_list_head teardown_node
;
130 * Registered traceable applications. Libust registers to the session daemon
131 * and a linked list is kept of all running traceable app.
137 uid_t uid
; /* User ID that owns the apps */
138 gid_t gid
; /* Group ID that owns the apps */
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
;
144 uint32_t v_major
; /* Verion major number */
145 uint32_t v_minor
; /* Verion minor number */
146 char name
[17]; /* Process name (short) */
147 struct lttng_ht
*sessions
;
148 struct lttng_ht_node_ulong pid_n
;
149 struct lttng_ht_node_ulong sock_n
;
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
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.
159 struct cds_list_head teardown_head
;
162 #ifdef HAVE_LIBLTTNG_UST_CTL
164 int ust_app_register(struct ust_register_msg
*msg
, int sock
);
166 int ust_app_register_done(int sock
)
168 return ustctl_register_done(sock
);
170 void ust_app_unregister(int sock
);
171 unsigned long ust_app_list_count(void);
172 int ust_app_start_trace(struct ltt_ust_session
*usess
, struct ust_app
*app
);
173 int ust_app_stop_trace(struct ltt_ust_session
*usess
, struct ust_app
*app
);
174 int ust_app_start_trace_all(struct ltt_ust_session
*usess
);
175 int ust_app_stop_trace_all(struct ltt_ust_session
*usess
);
176 int ust_app_destroy_trace_all(struct ltt_ust_session
*usess
);
177 int ust_app_list_events(struct lttng_event
**events
);
178 int ust_app_list_event_fields(struct lttng_event_field
**fields
);
179 int ust_app_create_channel_glb(struct ltt_ust_session
*usess
,
180 struct ltt_ust_channel
*uchan
);
181 int ust_app_create_event_glb(struct ltt_ust_session
*usess
,
182 struct ltt_ust_channel
*uchan
, struct ltt_ust_event
*uevent
);
183 int ust_app_disable_event_pid(struct ltt_ust_session
*usess
,
184 struct ltt_ust_channel
*uchan
, struct ltt_ust_event
*uevent
,
186 int ust_app_enable_event_pid(struct ltt_ust_session
*usess
,
187 struct ltt_ust_channel
*uchan
, struct ltt_ust_event
*uevent
,
189 int ust_app_disable_channel_glb(struct ltt_ust_session
*usess
,
190 struct ltt_ust_channel
*uchan
);
191 int ust_app_enable_channel_glb(struct ltt_ust_session
*usess
,
192 struct ltt_ust_channel
*uchan
);
193 int ust_app_enable_event_glb(struct ltt_ust_session
*usess
,
194 struct ltt_ust_channel
*uchan
, struct ltt_ust_event
*uevent
);
195 int ust_app_disable_all_event_glb(struct ltt_ust_session
*usess
,
196 struct ltt_ust_channel
*uchan
);
197 int ust_app_enable_all_event_glb(struct ltt_ust_session
*usess
,
198 struct ltt_ust_channel
*uchan
);
199 int ust_app_disable_event_glb(struct ltt_ust_session
*usess
,
200 struct ltt_ust_channel
*uchan
, struct ltt_ust_event
*uevent
);
201 int ust_app_add_ctx_channel_glb(struct ltt_ust_session
*usess
,
202 struct ltt_ust_channel
*uchan
, struct ltt_ust_context
*uctx
);
203 void ust_app_global_update(struct ltt_ust_session
*usess
, int sock
);
205 void ust_app_clean_list(void);
206 void ust_app_ht_alloc(void);
207 struct lttng_ht
*ust_app_get_ht(void);
208 struct ust_app
*ust_app_find_by_pid(pid_t pid
);
209 int ust_app_validate_version(int sock
);
210 int ust_app_calibrate_glb(struct lttng_ust_calibrate
*calibrate
);
212 #else /* HAVE_LIBLTTNG_UST_CTL */
215 int ust_app_destroy_trace_all(struct ltt_ust_session
*usess
)
220 int ust_app_start_trace(struct ltt_ust_session
*usess
, struct ust_app
*app
)
225 int ust_app_start_trace_all(struct ltt_ust_session
*usess
)
230 int ust_app_stop_trace_all(struct ltt_ust_session
*usess
)
235 int ust_app_list_events(struct lttng_event
**events
)
240 int ust_app_list_event_fields(struct lttng_event_field
**fields
)
245 int ust_app_register(struct ust_register_msg
*msg
, int sock
)
250 int ust_app_register_done(int sock
)
255 void ust_app_unregister(int sock
)
259 unsigned int ust_app_list_count(void)
264 void ust_app_lock_list(void)
268 void ust_app_unlock_list(void)
272 void ust_app_clean_list(void)
276 struct ust_app_list
*ust_app_get_list(void)
281 struct ust_app
*ust_app_get_by_pid(pid_t pid
)
286 struct lttng_ht
*ust_app_get_ht(void)
291 void ust_app_ht_alloc(void)
294 void ust_app_global_update(struct ltt_ust_session
*usess
, int sock
)
297 int ust_app_disable_channel_glb(struct ltt_ust_session
*usess
,
298 struct ltt_ust_channel
*uchan
)
303 int ust_app_enable_channel_glb(struct ltt_ust_session
*usess
,
304 struct ltt_ust_channel
*uchan
)
309 int ust_app_create_channel_glb(struct ltt_ust_session
*usess
,
310 struct ltt_ust_channel
*uchan
)
315 int ust_app_disable_all_event_glb(struct ltt_ust_session
*usess
,
316 struct ltt_ust_channel
*uchan
)
321 int ust_app_enable_all_event_glb(struct ltt_ust_session
*usess
,
322 struct ltt_ust_channel
*uchan
)
327 int ust_app_create_event_glb(struct ltt_ust_session
*usess
,
328 struct ltt_ust_channel
*uchan
, struct ltt_ust_event
*uevent
)
333 int ust_app_disable_event_glb(struct ltt_ust_session
*usess
,
334 struct ltt_ust_channel
*uchan
, struct ltt_ust_event
*uevent
)
339 int ust_app_enable_event_glb(struct ltt_ust_session
*usess
,
340 struct ltt_ust_channel
*uchan
, struct ltt_ust_event
*uevent
)
345 int ust_app_add_ctx_channel_glb(struct ltt_ust_session
*usess
,
346 struct ltt_ust_channel
*uchan
, struct ltt_ust_context
*uctx
)
351 int ust_app_enable_event_pid(struct ltt_ust_session
*usess
,
352 struct ltt_ust_channel
*uchan
, struct ltt_ust_event
*uevent
,
358 int ust_app_disable_event_pid(struct ltt_ust_session
*usess
,
359 struct ltt_ust_channel
*uchan
, struct ltt_ust_event
*uevent
,
365 int ust_app_validate_version(int sock
)
370 int ust_app_calibrate_glb(struct lttng_ust_calibrate
*calibrate
)
375 #endif /* HAVE_LIBLTTNG_UST_CTL */
377 #endif /* _LTT_UST_APP_H */