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 2 /* UST version supported */
29 #define UST_APP_EVENT_LIST_SIZE 32
31 extern int ust_consumerd64_fd
, ust_consumerd32_fd
;
34 * Application registration data structure.
36 struct ust_register_msg
{
43 uint32_t bits_per_long
;
48 * Global applications HT used by the session daemon.
50 struct lttng_ht
*ust_app_ht
;
52 struct lttng_ht
*ust_app_sock_key_map
;
57 struct lttng_ht_node_ulong node
;
62 struct lttng_ust_context ctx
;
63 struct lttng_ust_object_data
*obj
;
64 struct lttng_ht_node_ulong node
;
67 struct ust_app_event
{
70 struct lttng_ust_object_data
*obj
;
71 struct lttng_ust_event attr
;
72 char name
[LTTNG_UST_SYM_NAME_LEN
];
74 struct lttng_ht_node_str node
;
77 struct ust_app_channel
{
80 char name
[LTTNG_UST_SYM_NAME_LEN
];
81 struct lttng_ust_channel attr
;
82 struct lttng_ust_object_data
*obj
;
83 struct ltt_ust_stream_list streams
;
85 struct lttng_ht
*events
;
86 struct lttng_ht_node_str node
;
89 struct ust_app_session
{
91 /* started: has the session been in started state at any time ? */
92 int started
; /* allows detection of start vs restart. */
93 int handle
; /* used has unique identifier for app session */
94 int id
; /* session unique identifier */
95 struct ltt_ust_metadata
*metadata
;
96 struct lttng_ht
*channels
; /* Registered channels */
97 struct lttng_ht_node_ulong node
;
99 /* UID/GID of the user owning the session */
105 * Registered traceable applications. Libust registers to the session daemon
106 * and a linked list is kept of all running traceable app.
110 uid_t uid
; /* User ID that owns the apps */
111 gid_t gid
; /* Group ID that owns the apps */
113 int compatible
; /* If the lttng-ust tracer version does not match the
114 supported version of the session daemon, this flag is
115 set to 0 (NOT compatible) else 1. */
116 struct lttng_ust_tracer_version version
;
117 uint32_t v_major
; /* Verion major number */
118 uint32_t v_minor
; /* Verion minor number */
119 char name
[17]; /* Process name (short) */
120 struct lttng_ht
*sessions
;
121 struct lttng_ht_node_ulong node
;
122 struct ust_app_key key
;
125 #ifdef HAVE_LIBLTTNG_UST_CTL
127 int ust_app_register(struct ust_register_msg
*msg
, int sock
);
129 int ust_app_register_done(int sock
)
131 return ustctl_register_done(sock
);
133 void ust_app_unregister(int sock
);
134 unsigned long ust_app_list_count(void);
135 int ust_app_start_trace(struct ltt_ust_session
*usess
, struct ust_app
*app
);
136 int ust_app_stop_trace(struct ltt_ust_session
*usess
, struct ust_app
*app
);
137 int ust_app_start_trace_all(struct ltt_ust_session
*usess
);
138 int ust_app_stop_trace_all(struct ltt_ust_session
*usess
);
139 int ust_app_destroy_trace(struct ltt_ust_session
*usess
, struct ust_app
*app
);
140 int ust_app_destroy_trace_all(struct ltt_ust_session
*usess
);
141 int ust_app_list_events(struct lttng_event
**events
);
142 int ust_app_create_channel_glb(struct ltt_ust_session
*usess
,
143 struct ltt_ust_channel
*uchan
);
144 int ust_app_create_event_glb(struct ltt_ust_session
*usess
,
145 struct ltt_ust_channel
*uchan
, struct ltt_ust_event
*uevent
);
146 int ust_app_disable_event_pid(struct ltt_ust_session
*usess
,
147 struct ltt_ust_channel
*uchan
, struct ltt_ust_event
*uevent
,
149 int ust_app_enable_event_pid(struct ltt_ust_session
*usess
,
150 struct ltt_ust_channel
*uchan
, struct ltt_ust_event
*uevent
,
152 int ust_app_disable_channel_glb(struct ltt_ust_session
*usess
,
153 struct ltt_ust_channel
*uchan
);
154 int ust_app_enable_channel_glb(struct ltt_ust_session
*usess
,
155 struct ltt_ust_channel
*uchan
);
156 int ust_app_enable_event_glb(struct ltt_ust_session
*usess
,
157 struct ltt_ust_channel
*uchan
, struct ltt_ust_event
*uevent
);
158 int ust_app_disable_all_event_glb(struct ltt_ust_session
*usess
,
159 struct ltt_ust_channel
*uchan
);
160 int ust_app_enable_all_event_glb(struct ltt_ust_session
*usess
,
161 struct ltt_ust_channel
*uchan
);
162 int ust_app_disable_event_glb(struct ltt_ust_session
*usess
,
163 struct ltt_ust_channel
*uchan
, struct ltt_ust_event
*uevent
);
164 int ust_app_add_ctx_event_glb(struct ltt_ust_session
*usess
,
165 struct ltt_ust_channel
*uchan
, struct ltt_ust_event
*uevent
,
166 struct ltt_ust_context
*uctx
);
167 int ust_app_add_ctx_channel_glb(struct ltt_ust_session
*usess
,
168 struct ltt_ust_channel
*uchan
, struct ltt_ust_context
*uctx
);
169 void ust_app_global_update(struct ltt_ust_session
*usess
, int sock
);
171 void ust_app_clean_list(void);
172 void ust_app_ht_alloc(void);
173 struct lttng_ht
*ust_app_get_ht(void);
174 struct ust_app
*ust_app_find_by_pid(pid_t pid
);
175 int ust_app_validate_version(int sock
);
176 int ust_app_calibrate_glb(struct lttng_ust_calibrate
*calibrate
);
178 #else /* HAVE_LIBLTTNG_UST_CTL */
181 int ust_app_destroy_trace_all(struct ltt_ust_session
*usess
)
186 int ust_app_start_trace(struct ltt_ust_session
*usess
, struct ust_app
*app
)
191 int ust_app_start_trace_all(struct ltt_ust_session
*usess
)
196 int ust_app_stop_trace_all(struct ltt_ust_session
*usess
)
201 int ust_app_list_events(struct lttng_event
**events
)
206 int ust_app_register(struct ust_register_msg
*msg
, int sock
)
211 int ust_app_register_done(int sock
)
216 void ust_app_unregister(int sock
)
220 unsigned int ust_app_list_count(void)
225 void ust_app_lock_list(void)
229 void ust_app_unlock_list(void)
233 void ust_app_clean_list(void)
237 struct ust_app_list
*ust_app_get_list(void)
242 struct ust_app
*ust_app_get_by_pid(pid_t pid
)
247 struct lttng_ht
*ust_app_get_ht(void)
252 void ust_app_ht_alloc(void)
255 void ust_app_global_update(struct ltt_ust_session
*usess
, int sock
)
258 int ust_app_disable_channel_glb(struct ltt_ust_session
*usess
,
259 struct ltt_ust_channel
*uchan
)
264 int ust_app_enable_channel_glb(struct ltt_ust_session
*usess
,
265 struct ltt_ust_channel
*uchan
)
270 int ust_app_create_channel_glb(struct ltt_ust_session
*usess
,
271 struct ltt_ust_channel
*uchan
)
276 int ust_app_disable_all_event_glb(struct ltt_ust_session
*usess
,
277 struct ltt_ust_channel
*uchan
)
282 int ust_app_enable_all_event_glb(struct ltt_ust_session
*usess
,
283 struct ltt_ust_channel
*uchan
)
288 int ust_app_create_event_glb(struct ltt_ust_session
*usess
,
289 struct ltt_ust_channel
*uchan
, struct ltt_ust_event
*uevent
)
294 int ust_app_disable_event_glb(struct ltt_ust_session
*usess
,
295 struct ltt_ust_channel
*uchan
, struct ltt_ust_event
*uevent
)
300 int ust_app_enable_event_glb(struct ltt_ust_session
*usess
,
301 struct ltt_ust_channel
*uchan
, struct ltt_ust_event
*uevent
)
306 int ust_app_add_ctx_event_glb(struct ltt_ust_session
*usess
,
307 struct ltt_ust_channel
*uchan
, struct ltt_ust_event
*uevent
,
308 struct ltt_ust_context
*uctx
)
313 int ust_app_add_ctx_channel_glb(struct ltt_ust_session
*usess
,
314 struct ltt_ust_channel
*uchan
, struct ltt_ust_context
*uctx
)
319 int ust_app_enable_event_pid(struct ltt_ust_session
*usess
,
320 struct ltt_ust_channel
*uchan
, struct ltt_ust_event
*uevent
,
326 int ust_app_disable_event_pid(struct ltt_ust_session
*usess
,
327 struct ltt_ust_channel
*uchan
, struct ltt_ust_event
*uevent
,
333 int ust_app_validate_version(int sock
)
338 int ust_app_calibrate_glb(struct lttng_ust_calibrate
*calibrate
)
343 #endif /* HAVE_LIBLTTNG_UST_CTL */
345 #endif /* _LTT_UST_APP_H */