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
];
76 struct lttng_ht_node_str node
;
77 struct lttng_ust_filter_bytecode
*filter
;
80 struct ust_app_channel
{
83 char name
[LTTNG_UST_SYM_NAME_LEN
];
84 struct lttng_ust_channel attr
;
85 struct lttng_ust_object_data
*obj
;
86 struct ltt_ust_stream_list streams
;
88 struct lttng_ht
*events
;
89 struct lttng_ht_node_str node
;
92 struct ust_app_session
{
94 /* started: has the session been in started state at any time ? */
95 int started
; /* allows detection of start vs restart. */
96 int handle
; /* used has unique identifier for app session */
97 int id
; /* session unique identifier */
98 struct ltt_ust_metadata
*metadata
;
99 struct lttng_ht
*channels
; /* Registered channels */
100 struct lttng_ht_node_ulong node
;
102 /* UID/GID of the user owning the session */
108 * Registered traceable applications. Libust registers to the session daemon
109 * and a linked list is kept of all running traceable app.
115 uid_t uid
; /* User ID that owns the apps */
116 gid_t gid
; /* Group ID that owns the apps */
118 int compatible
; /* If the lttng-ust tracer version does not match the
119 supported version of the session daemon, this flag is
120 set to 0 (NOT compatible) else 1. */
121 struct lttng_ust_tracer_version version
;
122 uint32_t v_major
; /* Verion major number */
123 uint32_t v_minor
; /* Verion minor number */
124 char name
[17]; /* Process name (short) */
125 struct lttng_ht
*sessions
;
126 struct lttng_ht_node_ulong pid_n
;
127 struct lttng_ht_node_ulong sock_n
;
130 #ifdef HAVE_LIBLTTNG_UST_CTL
132 int ust_app_register(struct ust_register_msg
*msg
, int sock
);
134 int ust_app_register_done(int sock
)
136 return ustctl_register_done(sock
);
138 void ust_app_unregister(int sock
);
139 unsigned long ust_app_list_count(void);
140 int ust_app_start_trace(struct ltt_ust_session
*usess
, struct ust_app
*app
);
141 int ust_app_stop_trace(struct ltt_ust_session
*usess
, struct ust_app
*app
);
142 int ust_app_start_trace_all(struct ltt_ust_session
*usess
);
143 int ust_app_stop_trace_all(struct ltt_ust_session
*usess
);
144 int ust_app_destroy_trace(struct ltt_ust_session
*usess
, struct ust_app
*app
);
145 int ust_app_destroy_trace_all(struct ltt_ust_session
*usess
);
146 int ust_app_list_events(struct lttng_event
**events
);
147 int ust_app_list_event_fields(struct lttng_event_field
**fields
);
148 int ust_app_create_channel_glb(struct ltt_ust_session
*usess
,
149 struct ltt_ust_channel
*uchan
);
150 int ust_app_create_event_glb(struct ltt_ust_session
*usess
,
151 struct ltt_ust_channel
*uchan
, struct ltt_ust_event
*uevent
);
152 int ust_app_disable_event_pid(struct ltt_ust_session
*usess
,
153 struct ltt_ust_channel
*uchan
, struct ltt_ust_event
*uevent
,
155 int ust_app_enable_event_pid(struct ltt_ust_session
*usess
,
156 struct ltt_ust_channel
*uchan
, struct ltt_ust_event
*uevent
,
158 int ust_app_disable_channel_glb(struct ltt_ust_session
*usess
,
159 struct ltt_ust_channel
*uchan
);
160 int ust_app_enable_channel_glb(struct ltt_ust_session
*usess
,
161 struct ltt_ust_channel
*uchan
);
162 int ust_app_enable_event_glb(struct ltt_ust_session
*usess
,
163 struct ltt_ust_channel
*uchan
, struct ltt_ust_event
*uevent
);
164 int ust_app_disable_all_event_glb(struct ltt_ust_session
*usess
,
165 struct ltt_ust_channel
*uchan
);
166 int ust_app_enable_all_event_glb(struct ltt_ust_session
*usess
,
167 struct ltt_ust_channel
*uchan
);
168 int ust_app_disable_event_glb(struct ltt_ust_session
*usess
,
169 struct ltt_ust_channel
*uchan
, struct ltt_ust_event
*uevent
);
170 int ust_app_add_ctx_event_glb(struct ltt_ust_session
*usess
,
171 struct ltt_ust_channel
*uchan
, struct ltt_ust_event
*uevent
,
172 struct ltt_ust_context
*uctx
);
173 int ust_app_add_ctx_channel_glb(struct ltt_ust_session
*usess
,
174 struct ltt_ust_channel
*uchan
, struct ltt_ust_context
*uctx
);
175 int ust_app_set_filter_event_glb(struct ltt_ust_session
*usess
,
176 struct ltt_ust_channel
*uchan
, struct ltt_ust_event
*uevent
,
177 struct lttng_filter_bytecode
*bytecode
);
178 void ust_app_global_update(struct ltt_ust_session
*usess
, int sock
);
180 void ust_app_clean_list(void);
181 void ust_app_ht_alloc(void);
182 struct lttng_ht
*ust_app_get_ht(void);
183 struct ust_app
*ust_app_find_by_pid(pid_t pid
);
184 int ust_app_validate_version(int sock
);
185 int ust_app_calibrate_glb(struct lttng_ust_calibrate
*calibrate
);
187 #else /* HAVE_LIBLTTNG_UST_CTL */
190 int ust_app_destroy_trace_all(struct ltt_ust_session
*usess
)
195 int ust_app_start_trace(struct ltt_ust_session
*usess
, struct ust_app
*app
)
200 int ust_app_start_trace_all(struct ltt_ust_session
*usess
)
205 int ust_app_stop_trace_all(struct ltt_ust_session
*usess
)
210 int ust_app_list_events(struct lttng_event
**events
)
215 int ust_app_list_event_fields(struct lttng_event_field
**fields
)
220 int ust_app_register(struct ust_register_msg
*msg
, int sock
)
225 int ust_app_register_done(int sock
)
230 void ust_app_unregister(int sock
)
234 unsigned int ust_app_list_count(void)
239 void ust_app_lock_list(void)
243 void ust_app_unlock_list(void)
247 void ust_app_clean_list(void)
251 struct ust_app_list
*ust_app_get_list(void)
256 struct ust_app
*ust_app_get_by_pid(pid_t pid
)
261 struct lttng_ht
*ust_app_get_ht(void)
266 void ust_app_ht_alloc(void)
269 void ust_app_global_update(struct ltt_ust_session
*usess
, int sock
)
272 int ust_app_disable_channel_glb(struct ltt_ust_session
*usess
,
273 struct ltt_ust_channel
*uchan
)
278 int ust_app_enable_channel_glb(struct ltt_ust_session
*usess
,
279 struct ltt_ust_channel
*uchan
)
284 int ust_app_create_channel_glb(struct ltt_ust_session
*usess
,
285 struct ltt_ust_channel
*uchan
)
290 int ust_app_disable_all_event_glb(struct ltt_ust_session
*usess
,
291 struct ltt_ust_channel
*uchan
)
296 int ust_app_enable_all_event_glb(struct ltt_ust_session
*usess
,
297 struct ltt_ust_channel
*uchan
)
302 int ust_app_create_event_glb(struct ltt_ust_session
*usess
,
303 struct ltt_ust_channel
*uchan
, struct ltt_ust_event
*uevent
)
308 int ust_app_disable_event_glb(struct ltt_ust_session
*usess
,
309 struct ltt_ust_channel
*uchan
, struct ltt_ust_event
*uevent
)
314 int ust_app_enable_event_glb(struct ltt_ust_session
*usess
,
315 struct ltt_ust_channel
*uchan
, struct ltt_ust_event
*uevent
)
320 int ust_app_add_ctx_event_glb(struct ltt_ust_session
*usess
,
321 struct ltt_ust_channel
*uchan
, struct ltt_ust_event
*uevent
,
322 struct ltt_ust_context
*uctx
)
327 int ust_app_add_ctx_channel_glb(struct ltt_ust_session
*usess
,
328 struct ltt_ust_channel
*uchan
, struct ltt_ust_context
*uctx
)
333 int ust_app_enable_event_pid(struct ltt_ust_session
*usess
,
334 struct ltt_ust_channel
*uchan
, struct ltt_ust_event
*uevent
,
340 int ust_app_disable_event_pid(struct ltt_ust_session
*usess
,
341 struct ltt_ust_channel
*uchan
, struct ltt_ust_event
*uevent
,
347 int ust_app_validate_version(int sock
)
352 int ust_app_calibrate_glb(struct lttng_ust_calibrate
*calibrate
)
357 int ust_app_set_filter_event_glb(struct ltt_ust_session
*usess
,
358 struct ltt_ust_channel
*uchan
, struct ltt_ust_event
*uevent
,
359 struct lttng_filter_bytecode
*bytecode
)
364 #endif /* HAVE_LIBLTTNG_UST_CTL */
366 #endif /* _LTT_UST_APP_H */