2 * Copyright (C) 2011 - David Goulet <david.goulet@polymtl.ca>
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; only version 2
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 #ifndef _LTT_UST_APP_H
20 #define _LTT_UST_APP_H
24 #include "trace-ust.h"
26 /* lttng-ust supported version. */
27 #define LTTNG_UST_COMM_MAJOR 2 /* comm protocol major version */
28 #define UST_APP_MAJOR_VERSION 2 /* UST version supported */
30 #define UST_APP_EVENT_LIST_SIZE 32
32 extern int ust_consumerd64_fd
, ust_consumerd32_fd
;
35 * Application registration data structure.
37 struct ust_register_msg
{
44 uint32_t bits_per_long
;
49 * Global applications HT used by the session daemon.
51 struct lttng_ht
*ust_app_ht
;
53 struct lttng_ht
*ust_app_sock_key_map
;
58 struct lttng_ht_node_ulong node
;
63 struct lttng_ust_context ctx
;
64 struct lttng_ust_object_data
*obj
;
65 struct lttng_ht_node_ulong node
;
68 struct ust_app_event
{
71 struct lttng_ust_object_data
*obj
;
72 struct lttng_ust_event attr
;
73 char name
[LTTNG_UST_SYM_NAME_LEN
];
75 struct lttng_ht_node_str node
;
78 struct ust_app_channel
{
81 char name
[LTTNG_UST_SYM_NAME_LEN
];
82 struct lttng_ust_channel attr
;
83 struct lttng_ust_object_data
*obj
;
84 struct ltt_ust_stream_list streams
;
86 struct lttng_ht
*events
;
87 struct lttng_ht_node_str node
;
90 struct ust_app_session
{
92 /* started: has the session been in started state at any time ? */
93 int started
; /* allows detection of start vs restart. */
94 int handle
; /* used has unique identifier for app session */
95 int id
; /* session unique identifier */
96 struct ltt_ust_metadata
*metadata
;
97 struct lttng_ht
*channels
; /* Registered channels */
98 struct lttng_ht_node_ulong node
;
100 /* UID/GID of the user owning the session */
106 * Registered traceable applications. Libust registers to the session daemon
107 * and a linked list is kept of all running traceable app.
111 uid_t uid
; /* User ID that owns the apps */
112 gid_t gid
; /* Group ID that owns the apps */
114 int compatible
; /* If the lttng-ust tracer version does not match the
115 supported version of the session daemon, this flag is
116 set to 0 (NOT compatible) else 1. */
117 struct lttng_ust_tracer_version version
;
118 uint32_t v_major
; /* Verion major number */
119 uint32_t v_minor
; /* Verion minor number */
120 char name
[17]; /* Process name (short) */
121 struct lttng_ht
*sessions
;
122 struct lttng_ht_node_ulong node
;
123 struct ust_app_key key
;
126 #ifdef HAVE_LIBLTTNG_UST_CTL
128 int ust_app_register(struct ust_register_msg
*msg
, int sock
);
130 int ust_app_register_done(int sock
)
132 return ustctl_register_done(sock
);
134 void ust_app_unregister(int sock
);
135 unsigned long ust_app_list_count(void);
136 int ust_app_start_trace(struct ltt_ust_session
*usess
, struct ust_app
*app
);
137 int ust_app_stop_trace(struct ltt_ust_session
*usess
, struct ust_app
*app
);
138 int ust_app_start_trace_all(struct ltt_ust_session
*usess
);
139 int ust_app_stop_trace_all(struct ltt_ust_session
*usess
);
140 int ust_app_destroy_trace(struct ltt_ust_session
*usess
, struct ust_app
*app
);
141 int ust_app_destroy_trace_all(struct ltt_ust_session
*usess
);
142 int ust_app_list_events(struct lttng_event
**events
);
143 int ust_app_create_channel_glb(struct ltt_ust_session
*usess
,
144 struct ltt_ust_channel
*uchan
);
145 int ust_app_create_event_glb(struct ltt_ust_session
*usess
,
146 struct ltt_ust_channel
*uchan
, struct ltt_ust_event
*uevent
);
147 int ust_app_disable_event_pid(struct ltt_ust_session
*usess
,
148 struct ltt_ust_channel
*uchan
, struct ltt_ust_event
*uevent
,
150 int ust_app_enable_event_pid(struct ltt_ust_session
*usess
,
151 struct ltt_ust_channel
*uchan
, struct ltt_ust_event
*uevent
,
153 int ust_app_disable_channel_glb(struct ltt_ust_session
*usess
,
154 struct ltt_ust_channel
*uchan
);
155 int ust_app_enable_channel_glb(struct ltt_ust_session
*usess
,
156 struct ltt_ust_channel
*uchan
);
157 int ust_app_enable_event_glb(struct ltt_ust_session
*usess
,
158 struct ltt_ust_channel
*uchan
, struct ltt_ust_event
*uevent
);
159 int ust_app_disable_all_event_glb(struct ltt_ust_session
*usess
,
160 struct ltt_ust_channel
*uchan
);
161 int ust_app_enable_all_event_glb(struct ltt_ust_session
*usess
,
162 struct ltt_ust_channel
*uchan
);
163 int ust_app_disable_event_glb(struct ltt_ust_session
*usess
,
164 struct ltt_ust_channel
*uchan
, struct ltt_ust_event
*uevent
);
165 int ust_app_add_ctx_event_glb(struct ltt_ust_session
*usess
,
166 struct ltt_ust_channel
*uchan
, struct ltt_ust_event
*uevent
,
167 struct ltt_ust_context
*uctx
);
168 int ust_app_add_ctx_channel_glb(struct ltt_ust_session
*usess
,
169 struct ltt_ust_channel
*uchan
, struct ltt_ust_context
*uctx
);
170 void ust_app_global_update(struct ltt_ust_session
*usess
, int sock
);
172 void ust_app_clean_list(void);
173 void ust_app_ht_alloc(void);
174 struct lttng_ht
*ust_app_get_ht(void);
175 struct ust_app
*ust_app_find_by_pid(pid_t pid
);
176 int ust_app_validate_version(int sock
);
177 int ust_app_calibrate_glb(struct lttng_ust_calibrate
*calibrate
);
179 #else /* HAVE_LIBLTTNG_UST_CTL */
182 int ust_app_destroy_trace_all(struct ltt_ust_session
*usess
)
187 int ust_app_start_trace(struct ltt_ust_session
*usess
, struct ust_app
*app
)
192 int ust_app_start_trace_all(struct ltt_ust_session
*usess
)
197 int ust_app_stop_trace_all(struct ltt_ust_session
*usess
)
202 int ust_app_list_events(struct lttng_event
**events
)
207 int ust_app_register(struct ust_register_msg
*msg
, int sock
)
212 int ust_app_register_done(int sock
)
217 void ust_app_unregister(int sock
)
221 unsigned int ust_app_list_count(void)
226 void ust_app_lock_list(void)
230 void ust_app_unlock_list(void)
234 void ust_app_clean_list(void)
238 struct ust_app_list
*ust_app_get_list(void)
243 struct ust_app
*ust_app_get_by_pid(pid_t pid
)
248 struct lttng_ht
*ust_app_get_ht(void)
253 void ust_app_ht_alloc(void)
256 void ust_app_global_update(struct ltt_ust_session
*usess
, int sock
)
259 int ust_app_disable_channel_glb(struct ltt_ust_session
*usess
,
260 struct ltt_ust_channel
*uchan
)
265 int ust_app_enable_channel_glb(struct ltt_ust_session
*usess
,
266 struct ltt_ust_channel
*uchan
)
271 int ust_app_create_channel_glb(struct ltt_ust_session
*usess
,
272 struct ltt_ust_channel
*uchan
)
277 int ust_app_disable_all_event_glb(struct ltt_ust_session
*usess
,
278 struct ltt_ust_channel
*uchan
)
283 int ust_app_enable_all_event_glb(struct ltt_ust_session
*usess
,
284 struct ltt_ust_channel
*uchan
)
289 int ust_app_create_event_glb(struct ltt_ust_session
*usess
,
290 struct ltt_ust_channel
*uchan
, struct ltt_ust_event
*uevent
)
295 int ust_app_disable_event_glb(struct ltt_ust_session
*usess
,
296 struct ltt_ust_channel
*uchan
, struct ltt_ust_event
*uevent
)
301 int ust_app_enable_event_glb(struct ltt_ust_session
*usess
,
302 struct ltt_ust_channel
*uchan
, struct ltt_ust_event
*uevent
)
307 int ust_app_add_ctx_event_glb(struct ltt_ust_session
*usess
,
308 struct ltt_ust_channel
*uchan
, struct ltt_ust_event
*uevent
,
309 struct ltt_ust_context
*uctx
)
314 int ust_app_add_ctx_channel_glb(struct ltt_ust_session
*usess
,
315 struct ltt_ust_channel
*uchan
, struct ltt_ust_context
*uctx
)
320 int ust_app_enable_event_pid(struct ltt_ust_session
*usess
,
321 struct ltt_ust_channel
*uchan
, struct ltt_ust_event
*uevent
,
327 int ust_app_disable_event_pid(struct ltt_ust_session
*usess
,
328 struct ltt_ust_channel
*uchan
, struct ltt_ust_event
*uevent
,
334 int ust_app_validate_version(int sock
)
339 int ust_app_calibrate_glb(struct lttng_ust_calibrate
*calibrate
)
344 #endif /* HAVE_LIBLTTNG_UST_CTL */
346 #endif /* _LTT_UST_APP_H */