Commit | Line | Data |
---|---|---|
91d76f53 | 1 | /* |
21cf9b6b | 2 | * Copyright (C) 2011 EfficiOS Inc. |
ab5be9fa | 3 | * Copyright (C) 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com> |
91d76f53 | 4 | * |
ab5be9fa | 5 | * SPDX-License-Identifier: GPL-2.0-only |
91d76f53 | 6 | * |
91d76f53 DG |
7 | */ |
8 | ||
2106efa0 | 9 | #ifndef _LTT_UST_APP_H |
f6a9efaa | 10 | #define _LTT_UST_APP_H |
91d76f53 | 11 | |
16d64977 | 12 | #include "trace-class.hpp" |
28f23191 | 13 | #include "trace-ust.hpp" |
16d64977 | 14 | #include "ust-field-quirks.hpp" |
1e307fab | 15 | |
d7bfb9b0 | 16 | #include <common/format.hpp> |
28f23191 | 17 | #include <common/index-allocator.hpp> |
16d64977 | 18 | #include <common/reference.hpp> |
84213d6c | 19 | #include <common/scope-exit.hpp> |
c9e313bc | 20 | #include <common/uuid.hpp> |
f20baf8e | 21 | |
a1e1dc8b | 22 | #include <list> |
d425df61 | 23 | #include <stdint.h> |
44d3bd01 | 24 | |
b551a063 DG |
25 | #define UST_APP_EVENT_LIST_SIZE 32 |
26 | ||
d88aee68 | 27 | /* Process name (short). */ |
28f23191 | 28 | #define UST_APP_PROCNAME_LEN 16 |
d0b96690 | 29 | |
2b00d462 | 30 | struct lttng_bytecode; |
53a80697 MD |
31 | struct lttng_ust_filter_bytecode; |
32 | ||
16d64977 JG |
33 | namespace lttng { |
34 | namespace sessiond { | |
35 | namespace ust { | |
36 | class registry_session; | |
37 | } /* namespace ust */ | |
38 | } /* namespace sessiond */ | |
39 | } /* namespace lttng */ | |
40 | ||
412d7227 | 41 | extern int the_ust_consumerd64_fd, the_ust_consumerd32_fd; |
ba5d816e | 42 | |
d88aee68 DG |
43 | /* |
44 | * Object used to close the notify socket in a call_rcu(). Since the | |
45 | * application might not be found, we need an independant object containing the | |
46 | * notify socket fd. | |
47 | */ | |
48 | struct ust_app_notify_sock_obj { | |
49 | int fd; | |
50 | struct rcu_head head; | |
51 | }; | |
52 | ||
18eace3b DG |
53 | struct ust_app_ht_key { |
54 | const char *name; | |
2b00d462 | 55 | const struct lttng_bytecode *filter; |
fc4b93fa | 56 | enum lttng_ust_abi_loglevel_type loglevel_type; |
dcd24bbf | 57 | int loglevel_value; |
51755dc8 | 58 | const struct lttng_event_exclusion *exclusion; |
18eace3b DG |
59 | }; |
60 | ||
099e26bd DG |
61 | /* |
62 | * Application registration data structure. | |
63 | */ | |
64 | struct ust_register_msg { | |
b623cb6a | 65 | enum lttng_ust_ctl_socket_type type; |
099e26bd DG |
66 | uint32_t major; |
67 | uint32_t minor; | |
d0b96690 DG |
68 | uint32_t abi_major; |
69 | uint32_t abi_minor; | |
099e26bd DG |
70 | pid_t pid; |
71 | pid_t ppid; | |
72 | uid_t uid; | |
73 | gid_t gid; | |
0df502fd | 74 | uint32_t bits_per_long; |
d0b96690 DG |
75 | uint32_t uint8_t_alignment; |
76 | uint32_t uint16_t_alignment; | |
77 | uint32_t uint32_t_alignment; | |
78 | uint32_t uint64_t_alignment; | |
79 | uint32_t long_alignment; | |
28f23191 | 80 | int byte_order; /* BIG_ENDIAN or LITTLE_ENDIAN */ |
d0b96690 | 81 | char name[LTTNG_UST_ABI_PROCNAME_LEN]; |
099e26bd DG |
82 | }; |
83 | ||
48842b30 | 84 | /* |
852d0037 DG |
85 | * Global applications HT used by the session daemon. This table is indexed by |
86 | * PID using the pid_n node and pid value of an ust_app. | |
48842b30 | 87 | */ |
44cdb3a2 | 88 | extern struct lttng_ht *ust_app_ht; |
f6a9efaa | 89 | |
852d0037 DG |
90 | /* |
91 | * Global applications HT used by the session daemon. This table is indexed by | |
92 | * socket using the sock_n node and sock value of an ust_app. | |
12e22e8d JG |
93 | * |
94 | * The 'sock' in question here is the 'command' socket. | |
852d0037 | 95 | */ |
44cdb3a2 | 96 | extern struct lttng_ht *ust_app_ht_by_sock; |
91d76f53 | 97 | |
d0b96690 DG |
98 | /* |
99 | * Global applications HT used by the session daemon. This table is indexed by | |
100 | * socket using the notify_sock_n node and notify_sock value of an ust_app. | |
101 | */ | |
44cdb3a2 | 102 | extern struct lttng_ht *ust_app_ht_by_notify_sock; |
d0b96690 | 103 | |
030a66fa DG |
104 | /* Stream list containing ust_app_stream. */ |
105 | struct ust_app_stream_list { | |
106 | unsigned int count; | |
107 | struct cds_list_head head; | |
108 | }; | |
109 | ||
55cc08a6 DG |
110 | struct ust_app_ctx { |
111 | int handle; | |
bdf64013 | 112 | struct lttng_ust_context_attr ctx; |
fc4b93fa | 113 | struct lttng_ust_abi_object_data *obj; |
bec39940 | 114 | struct lttng_ht_node_ulong node; |
31746f93 | 115 | struct cds_list_head list; |
55cc08a6 DG |
116 | }; |
117 | ||
48842b30 | 118 | struct ust_app_event { |
66cefebd | 119 | bool enabled; |
48842b30 | 120 | int handle; |
fc4b93fa MD |
121 | struct lttng_ust_abi_object_data *obj; |
122 | struct lttng_ust_abi_event attr; | |
123 | char name[LTTNG_UST_ABI_SYM_NAME_LEN]; | |
bec39940 | 124 | struct lttng_ht_node_str node; |
2b00d462 | 125 | struct lttng_bytecode *filter; |
51755dc8 | 126 | struct lttng_event_exclusion *exclusion; |
48842b30 DG |
127 | }; |
128 | ||
993578ff | 129 | struct ust_app_event_notifier_rule { |
66cefebd | 130 | bool enabled; |
533a90fb | 131 | uint64_t error_counter_index; |
993578ff | 132 | int handle; |
fc4b93fa | 133 | struct lttng_ust_abi_object_data *obj; |
993578ff | 134 | /* Holds a strong reference. */ |
267d66aa | 135 | struct lttng_trigger *trigger; |
993578ff JR |
136 | /* Unique ID returned by the tracer to identify this event notifier. */ |
137 | uint64_t token; | |
138 | struct lttng_ht_node_u64 node; | |
267d66aa | 139 | /* The trigger object owns the filter. */ |
2b00d462 | 140 | const struct lttng_bytecode *filter; |
993578ff JR |
141 | /* Owned by this. */ |
142 | struct lttng_event_exclusion *exclusion; | |
143 | /* For delayed reclaim. */ | |
144 | struct rcu_head rcu_head; | |
145 | }; | |
146 | ||
030a66fa DG |
147 | struct ust_app_stream { |
148 | int handle; | |
149 | char pathname[PATH_MAX]; | |
150 | /* Format is %s_%d respectively channel name and CPU number. */ | |
151 | char name[DEFAULT_STREAM_NAME_LEN]; | |
fc4b93fa | 152 | struct lttng_ust_abi_object_data *obj; |
030a66fa DG |
153 | /* Using a list of streams to keep order. */ |
154 | struct cds_list_head list; | |
155 | }; | |
156 | ||
48842b30 | 157 | struct ust_app_channel { |
66cefebd | 158 | bool enabled; |
48842b30 | 159 | int handle; |
dda154b8 JG |
160 | /* |
161 | * Unique key used to identify the channel on the consumer side. | |
162 | * 0 is a reserved 'invalid' value used to indicate that the consumer | |
a9577b76 | 163 | * does not know about this channel (i.e. an error occurred). |
dda154b8 | 164 | */ |
d88aee68 | 165 | uint64_t key; |
7972aab2 DG |
166 | /* Id of the tracing channel set on creation. */ |
167 | uint64_t tracing_channel_id; | |
ffe60014 DG |
168 | /* Number of stream that this channel is expected to receive. */ |
169 | unsigned int expected_stream_count; | |
fc4b93fa MD |
170 | char name[LTTNG_UST_ABI_SYM_NAME_LEN]; |
171 | struct lttng_ust_abi_object_data *obj; | |
b623cb6a | 172 | struct lttng_ust_ctl_consumer_channel_attr attr; |
030a66fa | 173 | struct ust_app_stream_list streams; |
d0b96690 DG |
174 | /* Session pointer that owns this object. */ |
175 | struct ust_app_session *session; | |
31746f93 DG |
176 | /* |
177 | * Contexts are kept in a hash table for fast lookup and in an ordered list | |
178 | * so we are able to enable them on the tracer side in the same order the | |
179 | * user added them. | |
180 | */ | |
bec39940 | 181 | struct lttng_ht *ctx; |
31746f93 DG |
182 | struct cds_list_head ctx_list; |
183 | ||
bec39940 | 184 | struct lttng_ht *events; |
1624d5b7 JD |
185 | uint64_t tracefile_size; |
186 | uint64_t tracefile_count; | |
e9404c27 | 187 | uint64_t monitor_timer_interval; |
d0b96690 DG |
188 | /* |
189 | * Node indexed by channel name in the channels' hash table of a session. | |
190 | */ | |
bec39940 | 191 | struct lttng_ht_node_str node; |
d0b96690 DG |
192 | /* |
193 | * Node indexed by UST channel object descriptor (handle). Stored in the | |
194 | * ust_objd hash table in the ust_app object. | |
195 | */ | |
196 | struct lttng_ht_node_ulong ust_objd_node; | |
36b588ed MD |
197 | /* For delayed reclaim */ |
198 | struct rcu_head rcu_head; | |
48842b30 DG |
199 | }; |
200 | ||
201 | struct ust_app_session { | |
84213d6c | 202 | private: |
16d64977 JG |
203 | static void _session_unlock(ust_app_session *session) |
204 | { | |
205 | _const_session_unlock(session); | |
206 | } | |
207 | ||
208 | static void _const_session_unlock(const ust_app_session *session) | |
209 | { | |
210 | pthread_mutex_unlock(&session->_lock); | |
211 | } | |
84213d6c JG |
212 | |
213 | public: | |
214 | using locked_weak_ref = lttng::non_copyable_reference< | |
215 | ust_app_session, | |
216 | lttng::memory::create_deleter_class<ust_app_session, | |
217 | ust_app_session::_session_unlock>::deleter>; | |
218 | using const_locked_weak_ref = lttng::non_copyable_reference< | |
219 | const ust_app_session, | |
220 | lttng::memory::create_deleter_class<const ust_app_session, | |
221 | ust_app_session::_const_session_unlock>::deleter>; | |
222 | ||
16d64977 JG |
223 | static locked_weak_ref make_locked_weak_ref(ust_app_session& ua_session) |
224 | { | |
225 | return lttng::make_non_copyable_reference<locked_weak_ref::referenced_type, | |
226 | locked_weak_ref::deleter>(ua_session); | |
227 | } | |
228 | ||
229 | static const_locked_weak_ref make_locked_weak_ref(const ust_app_session& ua_session) | |
230 | { | |
231 | return lttng::make_non_copyable_reference<const_locked_weak_ref::referenced_type, | |
232 | const_locked_weak_ref::deleter>( | |
233 | ua_session); | |
234 | } | |
235 | ||
236 | ust_app_session::const_locked_weak_ref lock() const noexcept | |
237 | { | |
238 | pthread_mutex_lock(&_lock); | |
239 | return ust_app_session::make_locked_weak_ref(*this); | |
240 | } | |
241 | ||
242 | ust_app_session::locked_weak_ref lock() noexcept | |
243 | { | |
244 | pthread_mutex_lock(&_lock); | |
245 | return ust_app_session::make_locked_weak_ref(*this); | |
246 | } | |
247 | ||
248 | struct identifier { | |
249 | enum class application_abi : std::uint8_t { ABI_32 = 32, ABI_64 = 64 }; | |
250 | enum class buffer_allocation_policy : std::uint8_t { PER_PID, PER_UID }; | |
251 | ||
252 | /* Unique identifier of the ust_app_session. */ | |
253 | std::uint64_t id; | |
254 | /* Unique identifier of the ltt_session. */ | |
255 | std::uint64_t session_id; | |
256 | /* Credentials of the application which owns the ust_app_session. */ | |
257 | lttng_credentials app_credentials; | |
258 | application_abi abi; | |
259 | buffer_allocation_policy allocation_policy; | |
260 | }; | |
261 | ||
262 | identifier get_identifier() const noexcept | |
263 | { | |
264 | /* | |
265 | * To work around synchro design issues, this method allows the sampling | |
266 | * of a ust_app_session's identifying properties without taking its lock. | |
267 | * | |
268 | * Since those properties are immutable, it is safe to sample them without | |
269 | * holding the lock (as long as the existence of the instance is somehow | |
270 | * guaranteed). | |
271 | * | |
272 | * The locking issue that motivates this method is that the application | |
273 | * notitication handling thread needs to access the registry_session in response to | |
274 | * a message from the application. The ust_app_session's ID is needed to look-up the | |
275 | * registry session. | |
276 | * | |
277 | * The application's message can be emited in response to a command from the | |
278 | * session daemon that is emited by the client thread. | |
279 | * | |
280 | * During that command, the client thread holds the ust_app_session lock until | |
281 | * the application replies to the command. This causes the notification thread | |
282 | * to block when it attempts to sample the ust_app_session's ID properties. | |
283 | */ | |
284 | LTTNG_ASSERT(bits_per_long == 32 || bits_per_long == 64); | |
285 | LTTNG_ASSERT(buffer_type == LTTNG_BUFFER_PER_PID || | |
286 | buffer_type == LTTNG_BUFFER_PER_UID); | |
287 | ||
288 | return { .id = id, | |
289 | .session_id = tracing_id, | |
290 | .app_credentials = real_credentials, | |
291 | .abi = bits_per_long == 32 ? identifier::application_abi::ABI_32 : | |
292 | identifier::application_abi::ABI_64, | |
293 | .allocation_policy = buffer_type == LTTNG_BUFFER_PER_PID ? | |
294 | identifier::buffer_allocation_policy::PER_PID : | |
295 | identifier::buffer_allocation_policy::PER_UID }; | |
296 | } | |
84213d6c JG |
297 | |
298 | bool enabled = false; | |
8be98f9a | 299 | /* started: has the session been in started state at any time ? */ |
84213d6c JG |
300 | bool started = false; /* allows detection of start vs restart. */ |
301 | int handle = 0; /* used has unique identifier for app session */ | |
7972aab2 | 302 | |
84213d6c | 303 | bool deleted = false; /* Session deleted flag. Check with lock held. */ |
b161602a | 304 | |
7972aab2 DG |
305 | /* |
306 | * Tracing session ID. Multiple ust app session can have the same tracing | |
307 | * session id making this value NOT unique to the object. | |
308 | */ | |
84213d6c JG |
309 | uint64_t tracing_id = 0; |
310 | uint64_t id = 0; /* Unique session identifier */ | |
311 | struct lttng_ht *channels = nullptr; /* Registered channels */ | |
312 | struct lttng_ht_node_u64 node = {}; | |
10b56aef MD |
313 | /* |
314 | * Node indexed by UST session object descriptor (handle). Stored in the | |
315 | * ust_sessions_objd hash table in the ust_app object. | |
316 | */ | |
84213d6c | 317 | struct lttng_ht_node_ulong ust_objd_node = {}; |
d2956687 | 318 | /* Starts with 'ust'; no leading slash. */ |
84213d6c | 319 | char path[PATH_MAX] = {}; |
7972aab2 | 320 | /* UID/GID of the application owning the session */ |
84213d6c | 321 | struct lttng_credentials real_credentials = {}; |
7972aab2 | 322 | /* Effective UID and GID. Same as the tracing session. */ |
84213d6c | 323 | struct lttng_credentials effective_credentials = {}; |
d88aee68 DG |
324 | /* |
325 | * Once at least *one* session is created onto the application, the | |
326 | * corresponding consumer is set so we can use it on unregistration. | |
327 | */ | |
84213d6c JG |
328 | struct consumer_output *consumer = nullptr; |
329 | enum lttng_buffer_type buffer_type = LTTNG_BUFFER_PER_PID; | |
7972aab2 | 330 | /* ABI of the session. Same value as the application. */ |
84213d6c | 331 | uint32_t bits_per_long = 0; |
36b588ed | 332 | /* For delayed reclaim */ |
84213d6c | 333 | struct rcu_head rcu_head = {}; |
2bba9e53 | 334 | /* If the channel's streams have to be outputed or not. */ |
84213d6c JG |
335 | unsigned int output_traces = 0; |
336 | unsigned int live_timer_interval = 0; /* usec */ | |
ad7a9107 DG |
337 | |
338 | /* Metadata channel attributes. */ | |
84213d6c | 339 | struct lttng_ust_ctl_consumer_channel_attr metadata_attr = {}; |
d7ba1388 | 340 | |
84213d6c JG |
341 | char root_shm_path[PATH_MAX] = {}; |
342 | char shm_path[PATH_MAX] = {}; | |
343 | ||
344 | private: | |
345 | /* | |
346 | * Lock protecting this session's ust app interaction. Held | |
347 | * across command send/recv to/from app. Never nests within the | |
348 | * session registry lock. | |
349 | */ | |
350 | mutable pthread_mutex_t _lock = PTHREAD_MUTEX_INITIALIZER; | |
48842b30 DG |
351 | }; |
352 | ||
f6a9efaa DG |
353 | /* |
354 | * Registered traceable applications. Libust registers to the session daemon | |
050349bb | 355 | * and a linked list is kept of all running traceable app. |
91d76f53 | 356 | */ |
56fff090 | 357 | struct ust_app { |
a7db814e JG |
358 | /* |
359 | * The lifetime of 'sock' holds a reference to the application; the | |
360 | * application management thread will release a reference to the | |
361 | * application if the application dies. | |
362 | */ | |
363 | urcu_ref ref; | |
364 | ||
9fdee7ba | 365 | /* Traffic initiated from the session daemon to the application. */ |
852d0037 | 366 | int sock; |
28f23191 | 367 | pthread_mutex_t sock_lock; /* Protects sock protocol. */ |
fb45065e | 368 | |
9fdee7ba | 369 | /* Traffic initiated from the application to the session daemon. */ |
d0b96690 | 370 | int notify_sock; |
852d0037 | 371 | pid_t pid; |
099e26bd | 372 | pid_t ppid; |
28f23191 JG |
373 | uid_t uid; /* User ID that owns the apps */ |
374 | gid_t gid; /* Group ID that owns the apps */ | |
d0b96690 | 375 | |
d7bfb9b0 JG |
376 | /* App ABI. */ |
377 | lttng::sessiond::trace::abi abi; | |
d0b96690 | 378 | |
e0c7ec2b DG |
379 | int compatible; /* If the lttng-ust tracer version does not match the |
380 | supported version of the session daemon, this flag is | |
381 | set to 0 (NOT compatible) else 1. */ | |
fc4b93fa | 382 | struct lttng_ust_abi_tracer_version version; |
28f23191 JG |
383 | uint32_t v_major; /* Version major number */ |
384 | uint32_t v_minor; /* Version minor number */ | |
d88aee68 DG |
385 | /* Extra for the NULL byte. */ |
386 | char name[UST_APP_PROCNAME_LEN + 1]; | |
7d35269b | 387 | |
bec39940 | 388 | struct lttng_ht *sessions; |
852d0037 DG |
389 | struct lttng_ht_node_ulong pid_n; |
390 | struct lttng_ht_node_ulong sock_n; | |
d0b96690 | 391 | struct lttng_ht_node_ulong notify_sock_n; |
d42f20df DG |
392 | /* |
393 | * This is a list of ust app session that, once the app is going into | |
394 | * teardown mode, in the RCU call, each node in this list is removed and | |
395 | * deleted. | |
396 | * | |
397 | * Element of the list are added when an application unregisters after each | |
398 | * ht_del of ust_app_session associated to this app. This list is NOT used | |
399 | * when a session is destroyed. | |
400 | */ | |
a1e1dc8b | 401 | std::list<ust_app_session *> sessions_to_teardown; |
d0b96690 DG |
402 | /* |
403 | * Hash table containing ust_app_channel indexed by channel objd. | |
404 | */ | |
405 | struct lttng_ht *ust_objd; | |
10b56aef MD |
406 | /* |
407 | * Hash table containing ust_app_session indexed by objd. | |
408 | */ | |
409 | struct lttng_ht *ust_sessions_objd; | |
022d91ba | 410 | |
f20baf8e | 411 | /* |
022d91ba DG |
412 | * If this application is of the agent domain and this is non negative then |
413 | * a lookup MUST be done to acquire a read side reference to the | |
414 | * corresponding agent app object. If the lookup fails, this should be set | |
415 | * to a negative value indicating that the agent application is gone. | |
f20baf8e | 416 | */ |
022d91ba | 417 | int agent_app_sock; |
940c4592 JR |
418 | /* |
419 | * Time at which the app is registred. | |
420 | * Used for path creation | |
421 | */ | |
422 | time_t registration_time; | |
da873412 JR |
423 | /* |
424 | * Event notifier | |
425 | */ | |
426 | struct { | |
427 | /* | |
428 | * Handle to the lttng_ust object representing the event | |
429 | * notifier group. | |
430 | */ | |
fc4b93fa | 431 | struct lttng_ust_abi_object_data *object; |
da873412 | 432 | struct lttng_pipe *event_pipe; |
533a90fb FD |
433 | struct lttng_ust_abi_object_data *counter; |
434 | struct lttng_ust_abi_object_data **counter_cpu; | |
435 | int nr_counter_cpu; | |
da873412 | 436 | } event_notifier_group; |
993578ff JR |
437 | /* |
438 | * Hashtable indexing the application's event notifier rule's | |
439 | * (ust_app_event_notifier_rule) by their token's value. | |
440 | */ | |
441 | struct lttng_ht *token_to_event_notifier_rule_ht; | |
b6bbb1d6 JG |
442 | |
443 | lttng::sessiond::ust::ctl_field_quirks ctl_field_quirks() const; | |
91d76f53 DG |
444 | }; |
445 | ||
11bcbf89 JG |
446 | /* |
447 | * Due to a bug in g++ < 7.1, this specialization must be enclosed in the fmt namespace, | |
448 | * see https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56480. | |
449 | */ | |
e2c2bec2 | 450 | namespace fmt { |
d7bfb9b0 | 451 | template <> |
e2c2bec2 | 452 | struct formatter<ust_app> : formatter<std::string> { |
31375c42 | 453 | template <typename FormatContextType> |
cae96888 JG |
454 | typename FormatContextType::iterator format(const ust_app& app, |
455 | FormatContextType& ctx) const | |
d7bfb9b0 | 456 | { |
28f23191 JG |
457 | return format_to( |
458 | ctx.out(), | |
459 | "{{ procname = `{}`, ppid = {}, pid = {}, uid = {}, gid = {}, version = {}.{}, registration time = {} }}", | |
460 | app.name, | |
461 | app.ppid, | |
462 | app.pid, | |
463 | app.uid, | |
464 | app.gid, | |
465 | app.v_major, | |
466 | app.v_minor, | |
467 | lttng::utils::time_to_iso8601_str(app.registration_time)); | |
d7bfb9b0 JG |
468 | } |
469 | }; | |
e2c2bec2 | 470 | } /* namespace fmt */ |
d7bfb9b0 | 471 | |
74d0b642 | 472 | #ifdef HAVE_LIBLTTNG_UST_CTL |
3bd1e081 | 473 | |
56fff090 | 474 | int ust_app_register(struct ust_register_msg *msg, int sock); |
fb45065e | 475 | int ust_app_register_done(struct ust_app *app); |
d0b96690 | 476 | int ust_app_version(struct ust_app *app); |
a7db814e | 477 | void ust_app_unregister_by_socket(int sock); |
421cb601 | 478 | int ust_app_start_trace_all(struct ltt_ust_session *usess); |
8be98f9a | 479 | int ust_app_stop_trace_all(struct ltt_ust_session *usess); |
84cd17c6 | 480 | int ust_app_destroy_trace_all(struct ltt_ust_session *usess); |
b551a063 | 481 | int ust_app_list_events(struct lttng_event **events); |
f37d259d | 482 | int ust_app_list_event_fields(struct lttng_event_field **fields); |
35a9059d | 483 | int ust_app_create_event_glb(struct ltt_ust_session *usess, |
28f23191 JG |
484 | struct ltt_ust_channel *uchan, |
485 | struct ltt_ust_event *uevent); | |
486 | int ust_app_disable_channel_glb(struct ltt_ust_session *usess, struct ltt_ust_channel *uchan); | |
487 | int ust_app_enable_channel_glb(struct ltt_ust_session *usess, struct ltt_ust_channel *uchan); | |
35a9059d | 488 | int ust_app_enable_event_glb(struct ltt_ust_session *usess, |
28f23191 JG |
489 | struct ltt_ust_channel *uchan, |
490 | struct ltt_ust_event *uevent); | |
35a9059d | 491 | int ust_app_disable_event_glb(struct ltt_ust_session *usess, |
28f23191 JG |
492 | struct ltt_ust_channel *uchan, |
493 | struct ltt_ust_event *uevent); | |
55cc08a6 | 494 | int ust_app_add_ctx_channel_glb(struct ltt_ust_session *usess, |
28f23191 JG |
495 | struct ltt_ust_channel *uchan, |
496 | struct ltt_ust_context *uctx); | |
a9ad0c8f MD |
497 | void ust_app_global_update(struct ltt_ust_session *usess, struct ust_app *app); |
498 | void ust_app_global_update_all(struct ltt_ust_session *usess); | |
993578ff | 499 | void ust_app_global_update_event_notifier_rules(struct ust_app *app); |
cd9adb8b | 500 | void ust_app_global_update_all_event_notifier_rules(); |
91d76f53 | 501 | |
cd9adb8b JG |
502 | void ust_app_clean_list(); |
503 | int ust_app_ht_alloc(); | |
f6a9efaa | 504 | struct ust_app *ust_app_find_by_pid(pid_t pid); |
cd9adb8b | 505 | struct ust_app_stream *ust_app_alloc_stream(); |
d0b96690 DG |
506 | int ust_app_recv_registration(int sock, struct ust_register_msg *msg); |
507 | int ust_app_recv_notify(int sock); | |
508 | void ust_app_add(struct ust_app *app); | |
509 | struct ust_app *ust_app_create(struct ust_register_msg *msg, int sock); | |
d88aee68 | 510 | void ust_app_notify_sock_unregister(int sock); |
16d64977 | 511 | |
28f23191 JG |
512 | enum lttng_error_code ust_app_snapshot_record(const struct ltt_ust_session *usess, |
513 | const struct consumer_output *output, | |
514 | uint64_t nb_packets_per_stream); | |
515 | uint64_t ust_app_get_size_one_more_packet_per_stream(const struct ltt_ust_session *usess, | |
516 | uint64_t cur_nr_packets); | |
f20baf8e | 517 | struct ust_app *ust_app_find_by_sock(int sock); |
fb83fe64 | 518 | int ust_app_uid_get_channel_runtime_stats(uint64_t ust_session_id, |
28f23191 JG |
519 | struct cds_list_head *buffer_reg_uid_list, |
520 | struct consumer_output *consumer, | |
521 | uint64_t uchan_id, | |
522 | int overwrite, | |
523 | uint64_t *discarded, | |
524 | uint64_t *lost); | |
fb83fe64 | 525 | int ust_app_pid_get_channel_runtime_stats(struct ltt_ust_session *usess, |
28f23191 JG |
526 | struct ltt_ust_channel *uchan, |
527 | struct consumer_output *consumer, | |
528 | int overwrite, | |
529 | uint64_t *discarded, | |
530 | uint64_t *lost); | |
c2561365 | 531 | int ust_app_regenerate_statedump_all(struct ltt_ust_session *usess); |
28f23191 JG |
532 | enum lttng_error_code ust_app_create_channel_subdirectories(const struct ltt_ust_session *session); |
533 | int ust_app_release_object(struct ust_app *app, struct lttng_ust_abi_object_data *data); | |
44d3bd01 | 534 | |
da873412 JR |
535 | int ust_app_setup_event_notifier_group(struct ust_app *app); |
536 | ||
28f23191 | 537 | static inline int ust_app_supported() |
b51ec5b4 MD |
538 | { |
539 | return 1; | |
540 | } | |
541 | ||
16d64977 JG |
542 | ust_app_session *ust_app_lookup_app_session(const struct ltt_ust_session *usess, |
543 | const struct ust_app *app); | |
544 | lttng::sessiond::ust::registry_session * | |
545 | ust_app_get_session_registry(const ust_app_session::identifier& identifier); | |
546 | ||
547 | lttng_ht *ust_app_get_all(); | |
548 | ||
783db316 MD |
549 | bool ust_app_supports_notifiers(const struct ust_app *app); |
550 | bool ust_app_supports_counters(const struct ust_app *app); | |
551 | ||
a7db814e JG |
552 | bool ust_app_get(ust_app& app); |
553 | void ust_app_put(ust_app *app); | |
554 | ||
555 | using ust_app_reference = | |
556 | std::unique_ptr<ust_app, lttng::memory::create_deleter_class<ust_app, ust_app_put>::deleter>; | |
557 | ||
74d0b642 | 558 | #else /* HAVE_LIBLTTNG_UST_CTL */ |
3bd1e081 | 559 | |
28f23191 | 560 | static inline int ust_app_destroy_trace_all(struct ltt_ust_session *usess __attribute__((unused))) |
cc920def DG |
561 | { |
562 | return 0; | |
563 | } | |
f46376a1 | 564 | |
28f23191 JG |
565 | static inline int ust_app_start_trace(struct ltt_ust_session *usess __attribute__((unused)), |
566 | struct ust_app *app __attribute__((unused))) | |
421cb601 DG |
567 | { |
568 | return 0; | |
569 | } | |
f46376a1 | 570 | |
28f23191 | 571 | static inline int ust_app_start_trace_all(struct ltt_ust_session *usess __attribute__((unused))) |
d974f197 | 572 | { |
5cf5d0e7 | 573 | return 0; |
d974f197 | 574 | } |
f46376a1 | 575 | |
28f23191 | 576 | static inline int ust_app_stop_trace_all(struct ltt_ust_session *usess __attribute__((unused))) |
cc920def DG |
577 | { |
578 | return 0; | |
579 | } | |
f46376a1 | 580 | |
28f23191 | 581 | static inline int ust_app_list_events(struct lttng_event **events __attribute__((unused))) |
b551a063 | 582 | { |
db7c0497 | 583 | return -ENOSYS; |
b551a063 | 584 | } |
f46376a1 | 585 | |
28f23191 JG |
586 | static inline int ust_app_list_event_fields(struct lttng_event_field **fields |
587 | __attribute__((unused))) | |
da0bdb87 MD |
588 | { |
589 | return -ENOSYS; | |
590 | } | |
f46376a1 | 591 | |
28f23191 JG |
592 | static inline int ust_app_register(struct ust_register_msg *msg __attribute__((unused)), |
593 | int sock __attribute__((unused))) | |
3bd1e081 MD |
594 | { |
595 | return -ENOSYS; | |
596 | } | |
f46376a1 | 597 | |
28f23191 | 598 | static inline int ust_app_register_done(struct ust_app *app __attribute__((unused))) |
f2ca2e25 GF |
599 | { |
600 | return -ENOSYS; | |
601 | } | |
f46376a1 | 602 | |
28f23191 | 603 | static inline int ust_app_version(struct ust_app *app __attribute__((unused))) |
d0b96690 DG |
604 | { |
605 | return -ENOSYS; | |
606 | } | |
f46376a1 | 607 | |
a7db814e | 608 | static inline void ust_app_unregister_by_socket(int sock __attribute__((unused))) |
3bd1e081 MD |
609 | { |
610 | } | |
f46376a1 | 611 | |
28f23191 | 612 | static inline void ust_app_clean_list(void) |
3bd1e081 MD |
613 | { |
614 | } | |
f46376a1 | 615 | |
28f23191 | 616 | static inline struct ust_app_list *ust_app_get_list(void) |
3bd1e081 MD |
617 | { |
618 | return NULL; | |
619 | } | |
f46376a1 | 620 | |
28f23191 | 621 | static inline struct ust_app *ust_app_get_by_pid(pid_t pid __attribute__((unused))) |
3bd1e081 MD |
622 | { |
623 | return NULL; | |
624 | } | |
f46376a1 | 625 | |
28f23191 | 626 | static inline int ust_app_ht_alloc(void) |
12a84043 JG |
627 | { |
628 | return 0; | |
629 | } | |
f46376a1 | 630 | |
28f23191 JG |
631 | static inline void ust_app_global_update(struct ltt_ust_session *usess __attribute__((unused)), |
632 | struct ust_app *app __attribute__((unused))) | |
633 | { | |
634 | } | |
f46376a1 | 635 | |
28f23191 JG |
636 | static inline void ust_app_global_update_event_notifier_rules(struct ust_app *app |
637 | __attribute__((unused))) | |
638 | { | |
639 | } | |
f46376a1 | 640 | |
28f23191 JG |
641 | static inline void ust_app_global_update_all_event_notifier_rules(void) |
642 | { | |
643 | } | |
f46376a1 | 644 | |
28f23191 | 645 | static inline int ust_app_setup_event_notifier_group(struct ust_app *app __attribute__((unused))) |
da873412 JR |
646 | { |
647 | return 0; | |
648 | } | |
f46376a1 | 649 | |
28f23191 JG |
650 | static inline int ust_app_disable_channel_glb(struct ltt_ust_session *usess __attribute__((unused)), |
651 | struct ltt_ust_channel *uchan __attribute__((unused))) | |
d974f197 | 652 | { |
cc920def | 653 | return 0; |
d974f197 | 654 | } |
f46376a1 | 655 | |
28f23191 JG |
656 | static inline int ust_app_enable_channel_glb(struct ltt_ust_session *usess __attribute__((unused)), |
657 | struct ltt_ust_channel *uchan __attribute__((unused))) | |
487cf67c | 658 | { |
cc920def DG |
659 | return 0; |
660 | } | |
f46376a1 | 661 | |
28f23191 JG |
662 | static inline int ust_app_create_event_glb(struct ltt_ust_session *usess __attribute__((unused)), |
663 | struct ltt_ust_channel *uchan __attribute__((unused)), | |
664 | struct ltt_ust_event *uevent __attribute__((unused))) | |
35a9059d DG |
665 | { |
666 | return 0; | |
667 | } | |
f46376a1 | 668 | |
28f23191 JG |
669 | static inline int ust_app_disable_event_glb(struct ltt_ust_session *usess __attribute__((unused)), |
670 | struct ltt_ust_channel *uchan __attribute__((unused)), | |
671 | struct ltt_ust_event *uevent __attribute__((unused))) | |
cc920def DG |
672 | { |
673 | return 0; | |
487cf67c | 674 | } |
f46376a1 | 675 | |
28f23191 JG |
676 | static inline int ust_app_enable_event_glb(struct ltt_ust_session *usess __attribute__((unused)), |
677 | struct ltt_ust_channel *uchan __attribute__((unused)), | |
678 | struct ltt_ust_event *uevent __attribute__((unused))) | |
edb67388 DG |
679 | { |
680 | return 0; | |
681 | } | |
f46376a1 | 682 | |
28f23191 JG |
683 | static inline int ust_app_add_ctx_channel_glb(struct ltt_ust_session *usess __attribute__((unused)), |
684 | struct ltt_ust_channel *uchan __attribute__((unused)), | |
685 | struct ltt_ust_context *uctx __attribute__((unused))) | |
55cc08a6 DG |
686 | { |
687 | return 0; | |
688 | } | |
f46376a1 | 689 | |
28f23191 JG |
690 | static inline int ust_app_enable_event_pid(struct ltt_ust_session *usess __attribute__((unused)), |
691 | struct ltt_ust_channel *uchan __attribute__((unused)), | |
692 | struct ltt_ust_event *uevent __attribute__((unused)), | |
693 | pid_t pid __attribute__((unused))) | |
76d45b40 DG |
694 | { |
695 | return 0; | |
696 | } | |
f46376a1 | 697 | |
28f23191 JG |
698 | static inline int ust_app_recv_registration(int sock __attribute__((unused)), |
699 | struct ust_register_msg *msg __attribute__((unused))) | |
d0b96690 DG |
700 | { |
701 | return 0; | |
702 | } | |
f46376a1 | 703 | |
28f23191 | 704 | static inline int ust_app_recv_notify(int sock __attribute__((unused))) |
4466912f DG |
705 | { |
706 | return 0; | |
707 | } | |
f46376a1 | 708 | |
28f23191 JG |
709 | static inline struct ust_app *ust_app_create(struct ust_register_msg *msg __attribute__((unused)), |
710 | int sock __attribute__((unused))) | |
d0b96690 DG |
711 | { |
712 | return NULL; | |
713 | } | |
f46376a1 | 714 | |
28f23191 | 715 | static inline void ust_app_add(struct ust_app *app __attribute__((unused))) |
d0b96690 DG |
716 | { |
717 | } | |
f46376a1 | 718 | |
28f23191 | 719 | static inline void ust_app_notify_sock_unregister(int sock __attribute__((unused))) |
d88aee68 DG |
720 | { |
721 | } | |
f46376a1 | 722 | |
28f23191 JG |
723 | static inline enum lttng_error_code |
724 | ust_app_snapshot_record(struct ltt_ust_session *usess __attribute__((unused)), | |
725 | const struct consumer_output *output __attribute__((unused)), | |
726 | uint64_t max_stream_size __attribute__((unused))) | |
5c786ded | 727 | { |
7966af57 | 728 | return LTTNG_ERR_UNK; |
5c786ded | 729 | } |
f46376a1 | 730 | |
28f23191 JG |
731 | static inline unsigned int ust_app_get_nb_stream(struct ltt_ust_session *usess |
732 | __attribute__((unused))) | |
6dc3064a DG |
733 | { |
734 | return 0; | |
735 | } | |
f46376a1 | 736 | |
28f23191 JG |
737 | static inline void ust_app_update_event_notifier_error_count(struct lttng_trigger *lttng_trigger |
738 | __attribute__((unused))) | |
533a90fb FD |
739 | { |
740 | return; | |
741 | } | |
f46376a1 | 742 | |
28f23191 | 743 | static inline int ust_app_supported(void) |
b51ec5b4 MD |
744 | { |
745 | return 0; | |
746 | } | |
f46376a1 | 747 | |
28f23191 | 748 | static inline bool ust_app_supports_notifiers(const struct ust_app *app __attribute__((unused))) |
783db316 MD |
749 | { |
750 | return false; | |
751 | } | |
f46376a1 | 752 | |
28f23191 | 753 | static inline bool ust_app_supports_counters(const struct ust_app *app __attribute__((unused))) |
783db316 MD |
754 | { |
755 | return false; | |
756 | } | |
f46376a1 | 757 | |
28f23191 | 758 | static inline struct ust_app *ust_app_find_by_sock(int sock __attribute__((unused))) |
f20baf8e DG |
759 | { |
760 | return NULL; | |
761 | } | |
f46376a1 | 762 | |
28f23191 | 763 | static inline struct ust_app *ust_app_find_by_pid(pid_t pid __attribute__((unused))) |
95b1d17c DG |
764 | { |
765 | return NULL; | |
766 | } | |
f46376a1 | 767 | |
28f23191 JG |
768 | static inline uint64_t |
769 | ust_app_get_size_one_more_packet_per_stream(const struct ltt_ust_session *usess | |
770 | __attribute__((unused)), | |
771 | uint64_t cur_nr_packets __attribute__((unused))) | |
772 | { | |
16f35901 JG |
773 | return 0; |
774 | } | |
f46376a1 | 775 | |
28f23191 JG |
776 | static inline int ust_app_uid_get_channel_runtime_stats(uint64_t ust_session_id |
777 | __attribute__((unused)), | |
778 | struct cds_list_head *buffer_reg_uid_list | |
779 | __attribute__((unused)), | |
780 | struct consumer_output *consumer | |
781 | __attribute__((unused)), | |
782 | int overwrite __attribute__((unused)), | |
783 | uint64_t uchan_id __attribute__((unused)), | |
784 | uint64_t *discarded __attribute__((unused)), | |
785 | uint64_t *lost __attribute__((unused))) | |
fb83fe64 JD |
786 | { |
787 | return 0; | |
788 | } | |
789 | ||
28f23191 JG |
790 | static inline int |
791 | ust_app_pid_get_channel_runtime_stats(struct ltt_ust_session *usess __attribute__((unused)), | |
792 | struct ltt_ust_channel *uchan __attribute__((unused)), | |
793 | struct consumer_output *consumer __attribute__((unused)), | |
794 | int overwrite __attribute__((unused)), | |
795 | uint64_t *discarded __attribute__((unused)), | |
796 | uint64_t *lost __attribute__((unused))) | |
fb83fe64 JD |
797 | { |
798 | return 0; | |
799 | } | |
b51ec5b4 | 800 | |
28f23191 JG |
801 | static inline int ust_app_regenerate_statedump_all(struct ltt_ust_session *usess |
802 | __attribute__((unused))) | |
6f698634 JG |
803 | { |
804 | return 0; | |
805 | } | |
806 | ||
16d64977 JG |
807 | static inline enum lttng_error_code |
808 | ust_app_create_channel_subdirectories(const struct ltt_ust_session *session __attribute__((unused))) | |
5c408ad8 | 809 | { |
7966af57 | 810 | return LTTNG_ERR_UNK; |
5c408ad8 JD |
811 | } |
812 | ||
16d64977 | 813 | static inline ust_app_session *ust_app_lookup_app_session(const ltt_ust_session *, const ust_app *) |
d2956687 | 814 | { |
16d64977 | 815 | return nullptr; |
d2956687 JG |
816 | } |
817 | ||
16d64977 JG |
818 | static inline lttng::sessiond::ust::registry_session * |
819 | ust_app_get_session_registry(const ust_app_session::identifier&) | |
75018ab6 | 820 | { |
16d64977 | 821 | return nullptr; |
75018ab6 JG |
822 | } |
823 | ||
16d64977 | 824 | static inline lttng_ht *ust_app_get_all() |
4a9b9759 | 825 | { |
16d64977 | 826 | return nullptr; |
4a9b9759 MD |
827 | } |
828 | ||
16d64977 JG |
829 | static inline int ust_app_release_object(struct ust_app *app __attribute__((unused)), |
830 | struct lttng_ust_abi_object_data *data | |
831 | __attribute__((unused))) | |
04ed9e10 | 832 | { |
16d64977 | 833 | return 0; |
04ed9e10 JG |
834 | } |
835 | ||
a7db814e JG |
836 | static inline void ust_app_get(ust_app& app __attribute__((unused))) |
837 | { | |
838 | } | |
839 | ||
840 | static inline void ust_app_put(ust_app *app __attribute__((unused))) | |
841 | { | |
842 | } | |
843 | ||
74d0b642 | 844 | #endif /* HAVE_LIBLTTNG_UST_CTL */ |
3bd1e081 | 845 | |
f6a9efaa | 846 | #endif /* _LTT_UST_APP_H */ |