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
;
37 * Application registration data structure.
39 struct ust_register_msg
{
46 uint32_t bits_per_long
;
51 * Global applications HT used by the session daemon. This table is indexed by
52 * PID using the pid_n node and pid value of an ust_app.
54 struct lttng_ht
*ust_app_ht
;
57 * Global applications HT used by the session daemon. This table is indexed by
58 * socket using the sock_n node and sock value of an ust_app.
60 struct lttng_ht
*ust_app_ht_by_sock
;
64 struct lttng_ust_context ctx
;
65 struct lttng_ust_object_data
*obj
;
66 struct lttng_ht_node_ulong node
;
69 struct ust_app_event
{
72 struct lttng_ust_object_data
*obj
;
73 struct lttng_ust_event attr
;
74 char name
[LTTNG_UST_SYM_NAME_LEN
];
75 struct lttng_ht_node_str node
;
76 struct lttng_ust_filter_bytecode
*filter
;
79 struct ust_app_channel
{
82 char name
[LTTNG_UST_SYM_NAME_LEN
];
83 struct lttng_ust_channel attr
;
84 struct lttng_ust_object_data
*obj
;
85 struct ltt_ust_stream_list streams
;
87 struct lttng_ht
*events
;
88 struct lttng_ht_node_str node
;
91 struct ust_app_session
{
93 /* started: has the session been in started state at any time ? */
94 int started
; /* allows detection of start vs restart. */
95 int handle
; /* used has unique identifier for app session */
96 int id
; /* session unique identifier */
97 struct ltt_ust_metadata
*metadata
;
98 struct lttng_ht
*channels
; /* Registered channels */
99 struct lttng_ht_node_ulong node
;
101 /* UID/GID of the user owning the session */
107 * Registered traceable applications. Libust registers to the session daemon
108 * and a linked list is kept of all running traceable app.
114 uid_t uid
; /* User ID that owns the apps */
115 gid_t gid
; /* Group ID that owns the apps */
117 int compatible
; /* If the lttng-ust tracer version does not match the
118 supported version of the session daemon, this flag is
119 set to 0 (NOT compatible) else 1. */
120 struct lttng_ust_tracer_version version
;
121 uint32_t v_major
; /* Verion major number */
122 uint32_t v_minor
; /* Verion minor number */
123 char name
[17]; /* Process name (short) */
124 struct lttng_ht
*sessions
;
125 struct lttng_ht_node_ulong pid_n
;
126 struct lttng_ht_node_ulong sock_n
;
129 #ifdef HAVE_LIBLTTNG_UST_CTL
131 int ust_app_register(struct ust_register_msg
*msg
, int sock
);
133 int ust_app_register_done(int sock
)
135 return ustctl_register_done(sock
);
137 void ust_app_unregister(int sock
);
138 unsigned long ust_app_list_count(void);
139 int ust_app_start_trace(struct ltt_ust_session
*usess
, struct ust_app
*app
);
140 int ust_app_stop_trace(struct ltt_ust_session
*usess
, struct ust_app
*app
);
141 int ust_app_start_trace_all(struct ltt_ust_session
*usess
);
142 int ust_app_stop_trace_all(struct ltt_ust_session
*usess
);
143 int ust_app_destroy_trace(struct ltt_ust_session
*usess
, struct ust_app
*app
);
144 int ust_app_destroy_trace_all(struct ltt_ust_session
*usess
);
145 int ust_app_list_events(struct lttng_event
**events
);
146 int ust_app_list_event_fields(struct lttng_event_field
**fields
);
147 int ust_app_create_channel_glb(struct ltt_ust_session
*usess
,
148 struct ltt_ust_channel
*uchan
);
149 int ust_app_create_event_glb(struct ltt_ust_session
*usess
,
150 struct ltt_ust_channel
*uchan
, struct ltt_ust_event
*uevent
);
151 int ust_app_disable_event_pid(struct ltt_ust_session
*usess
,
152 struct ltt_ust_channel
*uchan
, struct ltt_ust_event
*uevent
,
154 int ust_app_enable_event_pid(struct ltt_ust_session
*usess
,
155 struct ltt_ust_channel
*uchan
, struct ltt_ust_event
*uevent
,
157 int ust_app_disable_channel_glb(struct ltt_ust_session
*usess
,
158 struct ltt_ust_channel
*uchan
);
159 int ust_app_enable_channel_glb(struct ltt_ust_session
*usess
,
160 struct ltt_ust_channel
*uchan
);
161 int ust_app_enable_event_glb(struct ltt_ust_session
*usess
,
162 struct ltt_ust_channel
*uchan
, struct ltt_ust_event
*uevent
);
163 int ust_app_disable_all_event_glb(struct ltt_ust_session
*usess
,
164 struct ltt_ust_channel
*uchan
);
165 int ust_app_enable_all_event_glb(struct ltt_ust_session
*usess
,
166 struct ltt_ust_channel
*uchan
);
167 int ust_app_disable_event_glb(struct ltt_ust_session
*usess
,
168 struct ltt_ust_channel
*uchan
, struct ltt_ust_event
*uevent
);
169 int ust_app_add_ctx_channel_glb(struct ltt_ust_session
*usess
,
170 struct ltt_ust_channel
*uchan
, struct ltt_ust_context
*uctx
);
171 int ust_app_set_filter_event_glb(struct ltt_ust_session
*usess
,
172 struct ltt_ust_channel
*uchan
, struct ltt_ust_event
*uevent
,
173 struct lttng_filter_bytecode
*bytecode
);
174 void ust_app_global_update(struct ltt_ust_session
*usess
, int sock
);
176 void ust_app_clean_list(void);
177 void ust_app_ht_alloc(void);
178 struct lttng_ht
*ust_app_get_ht(void);
179 struct ust_app
*ust_app_find_by_pid(pid_t pid
);
180 int ust_app_validate_version(int sock
);
181 int ust_app_calibrate_glb(struct lttng_ust_calibrate
*calibrate
);
183 #else /* HAVE_LIBLTTNG_UST_CTL */
186 int ust_app_destroy_trace_all(struct ltt_ust_session
*usess
)
191 int ust_app_start_trace(struct ltt_ust_session
*usess
, struct ust_app
*app
)
196 int ust_app_start_trace_all(struct ltt_ust_session
*usess
)
201 int ust_app_stop_trace_all(struct ltt_ust_session
*usess
)
206 int ust_app_list_events(struct lttng_event
**events
)
211 int ust_app_list_event_fields(struct lttng_event_field
**fields
)
216 int ust_app_register(struct ust_register_msg
*msg
, int sock
)
221 int ust_app_register_done(int sock
)
226 void ust_app_unregister(int sock
)
230 unsigned int ust_app_list_count(void)
235 void ust_app_lock_list(void)
239 void ust_app_unlock_list(void)
243 void ust_app_clean_list(void)
247 struct ust_app_list
*ust_app_get_list(void)
252 struct ust_app
*ust_app_get_by_pid(pid_t pid
)
257 struct lttng_ht
*ust_app_get_ht(void)
262 void ust_app_ht_alloc(void)
265 void ust_app_global_update(struct ltt_ust_session
*usess
, int sock
)
268 int ust_app_disable_channel_glb(struct ltt_ust_session
*usess
,
269 struct ltt_ust_channel
*uchan
)
274 int ust_app_enable_channel_glb(struct ltt_ust_session
*usess
,
275 struct ltt_ust_channel
*uchan
)
280 int ust_app_create_channel_glb(struct ltt_ust_session
*usess
,
281 struct ltt_ust_channel
*uchan
)
286 int ust_app_disable_all_event_glb(struct ltt_ust_session
*usess
,
287 struct ltt_ust_channel
*uchan
)
292 int ust_app_enable_all_event_glb(struct ltt_ust_session
*usess
,
293 struct ltt_ust_channel
*uchan
)
298 int ust_app_create_event_glb(struct ltt_ust_session
*usess
,
299 struct ltt_ust_channel
*uchan
, struct ltt_ust_event
*uevent
)
304 int ust_app_disable_event_glb(struct ltt_ust_session
*usess
,
305 struct ltt_ust_channel
*uchan
, struct ltt_ust_event
*uevent
)
310 int ust_app_enable_event_glb(struct ltt_ust_session
*usess
,
311 struct ltt_ust_channel
*uchan
, struct ltt_ust_event
*uevent
)
316 int ust_app_add_ctx_channel_glb(struct ltt_ust_session
*usess
,
317 struct ltt_ust_channel
*uchan
, struct ltt_ust_context
*uctx
)
322 int ust_app_enable_event_pid(struct ltt_ust_session
*usess
,
323 struct ltt_ust_channel
*uchan
, struct ltt_ust_event
*uevent
,
329 int ust_app_disable_event_pid(struct ltt_ust_session
*usess
,
330 struct ltt_ust_channel
*uchan
, struct ltt_ust_event
*uevent
,
336 int ust_app_validate_version(int sock
)
341 int ust_app_calibrate_glb(struct lttng_ust_calibrate
*calibrate
)
346 int ust_app_set_filter_event_glb(struct ltt_ust_session
*usess
,
347 struct ltt_ust_channel
*uchan
, struct ltt_ust_event
*uevent
,
348 struct lttng_filter_bytecode
*bytecode
)
353 #endif /* HAVE_LIBLTTNG_UST_CTL */
355 #endif /* _LTT_UST_APP_H */