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 | |
28f23191 | 22 | #include <stdint.h> |
44d3bd01 | 23 | |
b551a063 DG |
24 | #define UST_APP_EVENT_LIST_SIZE 32 |
25 | ||
d88aee68 | 26 | /* Process name (short). */ |
28f23191 | 27 | #define UST_APP_PROCNAME_LEN 16 |
d0b96690 | 28 | |
2b00d462 | 29 | struct lttng_bytecode; |
53a80697 MD |
30 | struct lttng_ust_filter_bytecode; |
31 | ||
16d64977 JG |
32 | namespace lttng { |
33 | namespace sessiond { | |
34 | namespace ust { | |
35 | class registry_session; | |
36 | } /* namespace ust */ | |
37 | } /* namespace sessiond */ | |
38 | } /* namespace lttng */ | |
39 | ||
412d7227 | 40 | extern int the_ust_consumerd64_fd, the_ust_consumerd32_fd; |
ba5d816e | 41 | |
d88aee68 DG |
42 | /* |
43 | * Object used to close the notify socket in a call_rcu(). Since the | |
44 | * application might not be found, we need an independant object containing the | |
45 | * notify socket fd. | |
46 | */ | |
47 | struct ust_app_notify_sock_obj { | |
48 | int fd; | |
49 | struct rcu_head head; | |
50 | }; | |
51 | ||
18eace3b DG |
52 | struct ust_app_ht_key { |
53 | const char *name; | |
2b00d462 | 54 | const struct lttng_bytecode *filter; |
fc4b93fa | 55 | enum lttng_ust_abi_loglevel_type loglevel_type; |
dcd24bbf | 56 | int loglevel_value; |
51755dc8 | 57 | const struct lttng_event_exclusion *exclusion; |
18eace3b DG |
58 | }; |
59 | ||
099e26bd DG |
60 | /* |
61 | * Application registration data structure. | |
62 | */ | |
63 | struct ust_register_msg { | |
b623cb6a | 64 | enum lttng_ust_ctl_socket_type type; |
099e26bd DG |
65 | uint32_t major; |
66 | uint32_t minor; | |
d0b96690 DG |
67 | uint32_t abi_major; |
68 | uint32_t abi_minor; | |
099e26bd DG |
69 | pid_t pid; |
70 | pid_t ppid; | |
71 | uid_t uid; | |
72 | gid_t gid; | |
0df502fd | 73 | uint32_t bits_per_long; |
d0b96690 DG |
74 | uint32_t uint8_t_alignment; |
75 | uint32_t uint16_t_alignment; | |
76 | uint32_t uint32_t_alignment; | |
77 | uint32_t uint64_t_alignment; | |
78 | uint32_t long_alignment; | |
28f23191 | 79 | int byte_order; /* BIG_ENDIAN or LITTLE_ENDIAN */ |
d0b96690 | 80 | char name[LTTNG_UST_ABI_PROCNAME_LEN]; |
099e26bd DG |
81 | }; |
82 | ||
48842b30 | 83 | /* |
852d0037 DG |
84 | * Global applications HT used by the session daemon. This table is indexed by |
85 | * PID using the pid_n node and pid value of an ust_app. | |
48842b30 | 86 | */ |
44cdb3a2 | 87 | extern struct lttng_ht *ust_app_ht; |
f6a9efaa | 88 | |
852d0037 DG |
89 | /* |
90 | * Global applications HT used by the session daemon. This table is indexed by | |
91 | * socket using the sock_n node and sock value of an ust_app. | |
12e22e8d JG |
92 | * |
93 | * The 'sock' in question here is the 'command' socket. | |
852d0037 | 94 | */ |
44cdb3a2 | 95 | extern struct lttng_ht *ust_app_ht_by_sock; |
91d76f53 | 96 | |
d0b96690 DG |
97 | /* |
98 | * Global applications HT used by the session daemon. This table is indexed by | |
99 | * socket using the notify_sock_n node and notify_sock value of an ust_app. | |
100 | */ | |
44cdb3a2 | 101 | extern struct lttng_ht *ust_app_ht_by_notify_sock; |
d0b96690 | 102 | |
030a66fa DG |
103 | /* Stream list containing ust_app_stream. */ |
104 | struct ust_app_stream_list { | |
105 | unsigned int count; | |
106 | struct cds_list_head head; | |
107 | }; | |
108 | ||
55cc08a6 DG |
109 | struct ust_app_ctx { |
110 | int handle; | |
bdf64013 | 111 | struct lttng_ust_context_attr ctx; |
fc4b93fa | 112 | struct lttng_ust_abi_object_data *obj; |
bec39940 | 113 | struct lttng_ht_node_ulong node; |
31746f93 | 114 | struct cds_list_head list; |
55cc08a6 DG |
115 | }; |
116 | ||
48842b30 | 117 | struct ust_app_event { |
66cefebd | 118 | bool enabled; |
48842b30 | 119 | int handle; |
fc4b93fa MD |
120 | struct lttng_ust_abi_object_data *obj; |
121 | struct lttng_ust_abi_event attr; | |
122 | char name[LTTNG_UST_ABI_SYM_NAME_LEN]; | |
bec39940 | 123 | struct lttng_ht_node_str node; |
2b00d462 | 124 | struct lttng_bytecode *filter; |
51755dc8 | 125 | struct lttng_event_exclusion *exclusion; |
48842b30 DG |
126 | }; |
127 | ||
993578ff | 128 | struct ust_app_event_notifier_rule { |
66cefebd | 129 | bool enabled; |
533a90fb | 130 | uint64_t error_counter_index; |
993578ff | 131 | int handle; |
fc4b93fa | 132 | struct lttng_ust_abi_object_data *obj; |
993578ff | 133 | /* Holds a strong reference. */ |
267d66aa | 134 | struct lttng_trigger *trigger; |
993578ff JR |
135 | /* Unique ID returned by the tracer to identify this event notifier. */ |
136 | uint64_t token; | |
137 | struct lttng_ht_node_u64 node; | |
267d66aa | 138 | /* The trigger object owns the filter. */ |
2b00d462 | 139 | const struct lttng_bytecode *filter; |
993578ff JR |
140 | /* Owned by this. */ |
141 | struct lttng_event_exclusion *exclusion; | |
142 | /* For delayed reclaim. */ | |
143 | struct rcu_head rcu_head; | |
144 | }; | |
145 | ||
030a66fa DG |
146 | struct ust_app_stream { |
147 | int handle; | |
148 | char pathname[PATH_MAX]; | |
149 | /* Format is %s_%d respectively channel name and CPU number. */ | |
150 | char name[DEFAULT_STREAM_NAME_LEN]; | |
fc4b93fa | 151 | struct lttng_ust_abi_object_data *obj; |
030a66fa DG |
152 | /* Using a list of streams to keep order. */ |
153 | struct cds_list_head list; | |
154 | }; | |
155 | ||
48842b30 | 156 | struct ust_app_channel { |
66cefebd | 157 | bool enabled; |
48842b30 | 158 | int handle; |
dda154b8 JG |
159 | /* |
160 | * Unique key used to identify the channel on the consumer side. | |
161 | * 0 is a reserved 'invalid' value used to indicate that the consumer | |
a9577b76 | 162 | * does not know about this channel (i.e. an error occurred). |
dda154b8 | 163 | */ |
d88aee68 | 164 | uint64_t key; |
7972aab2 DG |
165 | /* Id of the tracing channel set on creation. */ |
166 | uint64_t tracing_channel_id; | |
ffe60014 DG |
167 | /* Number of stream that this channel is expected to receive. */ |
168 | unsigned int expected_stream_count; | |
fc4b93fa MD |
169 | char name[LTTNG_UST_ABI_SYM_NAME_LEN]; |
170 | struct lttng_ust_abi_object_data *obj; | |
b623cb6a | 171 | struct lttng_ust_ctl_consumer_channel_attr attr; |
030a66fa | 172 | struct ust_app_stream_list streams; |
d0b96690 DG |
173 | /* Session pointer that owns this object. */ |
174 | struct ust_app_session *session; | |
31746f93 DG |
175 | /* |
176 | * Contexts are kept in a hash table for fast lookup and in an ordered list | |
177 | * so we are able to enable them on the tracer side in the same order the | |
178 | * user added them. | |
179 | */ | |
bec39940 | 180 | struct lttng_ht *ctx; |
31746f93 DG |
181 | struct cds_list_head ctx_list; |
182 | ||
bec39940 | 183 | struct lttng_ht *events; |
1624d5b7 JD |
184 | uint64_t tracefile_size; |
185 | uint64_t tracefile_count; | |
e9404c27 | 186 | uint64_t monitor_timer_interval; |
d0b96690 DG |
187 | /* |
188 | * Node indexed by channel name in the channels' hash table of a session. | |
189 | */ | |
bec39940 | 190 | struct lttng_ht_node_str node; |
d0b96690 DG |
191 | /* |
192 | * Node indexed by UST channel object descriptor (handle). Stored in the | |
193 | * ust_objd hash table in the ust_app object. | |
194 | */ | |
195 | struct lttng_ht_node_ulong ust_objd_node; | |
36b588ed MD |
196 | /* For delayed reclaim */ |
197 | struct rcu_head rcu_head; | |
48842b30 DG |
198 | }; |
199 | ||
200 | struct ust_app_session { | |
84213d6c | 201 | private: |
16d64977 JG |
202 | static void _session_unlock(ust_app_session *session) |
203 | { | |
204 | _const_session_unlock(session); | |
205 | } | |
206 | ||
207 | static void _const_session_unlock(const ust_app_session *session) | |
208 | { | |
209 | pthread_mutex_unlock(&session->_lock); | |
210 | } | |
84213d6c JG |
211 | |
212 | public: | |
213 | using locked_weak_ref = lttng::non_copyable_reference< | |
214 | ust_app_session, | |
215 | lttng::memory::create_deleter_class<ust_app_session, | |
216 | ust_app_session::_session_unlock>::deleter>; | |
217 | using const_locked_weak_ref = lttng::non_copyable_reference< | |
218 | const ust_app_session, | |
219 | lttng::memory::create_deleter_class<const ust_app_session, | |
220 | ust_app_session::_const_session_unlock>::deleter>; | |
221 | ||
16d64977 JG |
222 | static locked_weak_ref make_locked_weak_ref(ust_app_session& ua_session) |
223 | { | |
224 | return lttng::make_non_copyable_reference<locked_weak_ref::referenced_type, | |
225 | locked_weak_ref::deleter>(ua_session); | |
226 | } | |
227 | ||
228 | static const_locked_weak_ref make_locked_weak_ref(const ust_app_session& ua_session) | |
229 | { | |
230 | return lttng::make_non_copyable_reference<const_locked_weak_ref::referenced_type, | |
231 | const_locked_weak_ref::deleter>( | |
232 | ua_session); | |
233 | } | |
234 | ||
235 | ust_app_session::const_locked_weak_ref lock() const noexcept | |
236 | { | |
237 | pthread_mutex_lock(&_lock); | |
238 | return ust_app_session::make_locked_weak_ref(*this); | |
239 | } | |
240 | ||
241 | ust_app_session::locked_weak_ref lock() noexcept | |
242 | { | |
243 | pthread_mutex_lock(&_lock); | |
244 | return ust_app_session::make_locked_weak_ref(*this); | |
245 | } | |
246 | ||
247 | struct identifier { | |
248 | enum class application_abi : std::uint8_t { ABI_32 = 32, ABI_64 = 64 }; | |
249 | enum class buffer_allocation_policy : std::uint8_t { PER_PID, PER_UID }; | |
250 | ||
251 | /* Unique identifier of the ust_app_session. */ | |
252 | std::uint64_t id; | |
253 | /* Unique identifier of the ltt_session. */ | |
254 | std::uint64_t session_id; | |
255 | /* Credentials of the application which owns the ust_app_session. */ | |
256 | lttng_credentials app_credentials; | |
257 | application_abi abi; | |
258 | buffer_allocation_policy allocation_policy; | |
259 | }; | |
260 | ||
261 | identifier get_identifier() const noexcept | |
262 | { | |
263 | /* | |
264 | * To work around synchro design issues, this method allows the sampling | |
265 | * of a ust_app_session's identifying properties without taking its lock. | |
266 | * | |
267 | * Since those properties are immutable, it is safe to sample them without | |
268 | * holding the lock (as long as the existence of the instance is somehow | |
269 | * guaranteed). | |
270 | * | |
271 | * The locking issue that motivates this method is that the application | |
272 | * notitication handling thread needs to access the registry_session in response to | |
273 | * a message from the application. The ust_app_session's ID is needed to look-up the | |
274 | * registry session. | |
275 | * | |
276 | * The application's message can be emited in response to a command from the | |
277 | * session daemon that is emited by the client thread. | |
278 | * | |
279 | * During that command, the client thread holds the ust_app_session lock until | |
280 | * the application replies to the command. This causes the notification thread | |
281 | * to block when it attempts to sample the ust_app_session's ID properties. | |
282 | */ | |
283 | LTTNG_ASSERT(bits_per_long == 32 || bits_per_long == 64); | |
284 | LTTNG_ASSERT(buffer_type == LTTNG_BUFFER_PER_PID || | |
285 | buffer_type == LTTNG_BUFFER_PER_UID); | |
286 | ||
287 | return { .id = id, | |
288 | .session_id = tracing_id, | |
289 | .app_credentials = real_credentials, | |
290 | .abi = bits_per_long == 32 ? identifier::application_abi::ABI_32 : | |
291 | identifier::application_abi::ABI_64, | |
292 | .allocation_policy = buffer_type == LTTNG_BUFFER_PER_PID ? | |
293 | identifier::buffer_allocation_policy::PER_PID : | |
294 | identifier::buffer_allocation_policy::PER_UID }; | |
295 | } | |
84213d6c JG |
296 | |
297 | bool enabled = false; | |
8be98f9a | 298 | /* started: has the session been in started state at any time ? */ |
84213d6c JG |
299 | bool started = false; /* allows detection of start vs restart. */ |
300 | int handle = 0; /* used has unique identifier for app session */ | |
7972aab2 | 301 | |
84213d6c | 302 | bool deleted = false; /* Session deleted flag. Check with lock held. */ |
b161602a | 303 | |
7972aab2 DG |
304 | /* |
305 | * Tracing session ID. Multiple ust app session can have the same tracing | |
306 | * session id making this value NOT unique to the object. | |
307 | */ | |
84213d6c JG |
308 | uint64_t tracing_id = 0; |
309 | uint64_t id = 0; /* Unique session identifier */ | |
310 | struct lttng_ht *channels = nullptr; /* Registered channels */ | |
311 | struct lttng_ht_node_u64 node = {}; | |
10b56aef MD |
312 | /* |
313 | * Node indexed by UST session object descriptor (handle). Stored in the | |
314 | * ust_sessions_objd hash table in the ust_app object. | |
315 | */ | |
84213d6c | 316 | struct lttng_ht_node_ulong ust_objd_node = {}; |
d2956687 | 317 | /* Starts with 'ust'; no leading slash. */ |
84213d6c | 318 | char path[PATH_MAX] = {}; |
7972aab2 | 319 | /* UID/GID of the application owning the session */ |
84213d6c | 320 | struct lttng_credentials real_credentials = {}; |
7972aab2 | 321 | /* Effective UID and GID. Same as the tracing session. */ |
84213d6c JG |
322 | struct lttng_credentials effective_credentials = {}; |
323 | struct cds_list_head teardown_node = {}; | |
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 | */ | |
401 | struct cds_list_head teardown_head; | |
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 JG |
453 | template <typename FormatContextType> |
454 | typename FormatContextType::iterator format(const ust_app& app, FormatContextType& ctx) | |
d7bfb9b0 | 455 | { |
28f23191 JG |
456 | return format_to( |
457 | ctx.out(), | |
458 | "{{ procname = `{}`, ppid = {}, pid = {}, uid = {}, gid = {}, version = {}.{}, registration time = {} }}", | |
459 | app.name, | |
460 | app.ppid, | |
461 | app.pid, | |
462 | app.uid, | |
463 | app.gid, | |
464 | app.v_major, | |
465 | app.v_minor, | |
466 | lttng::utils::time_to_iso8601_str(app.registration_time)); | |
d7bfb9b0 JG |
467 | } |
468 | }; | |
e2c2bec2 | 469 | } /* namespace fmt */ |
d7bfb9b0 | 470 | |
74d0b642 | 471 | #ifdef HAVE_LIBLTTNG_UST_CTL |
3bd1e081 | 472 | |
56fff090 | 473 | int ust_app_register(struct ust_register_msg *msg, int sock); |
fb45065e | 474 | int ust_app_register_done(struct ust_app *app); |
d0b96690 | 475 | int ust_app_version(struct ust_app *app); |
a7db814e | 476 | void ust_app_unregister_by_socket(int sock); |
421cb601 | 477 | int ust_app_start_trace_all(struct ltt_ust_session *usess); |
8be98f9a | 478 | int ust_app_stop_trace_all(struct ltt_ust_session *usess); |
84cd17c6 | 479 | int ust_app_destroy_trace_all(struct ltt_ust_session *usess); |
b551a063 | 480 | int ust_app_list_events(struct lttng_event **events); |
f37d259d | 481 | int ust_app_list_event_fields(struct lttng_event_field **fields); |
35a9059d | 482 | int ust_app_create_event_glb(struct ltt_ust_session *usess, |
28f23191 JG |
483 | struct ltt_ust_channel *uchan, |
484 | struct ltt_ust_event *uevent); | |
485 | int ust_app_disable_channel_glb(struct ltt_ust_session *usess, struct ltt_ust_channel *uchan); | |
486 | int ust_app_enable_channel_glb(struct ltt_ust_session *usess, struct ltt_ust_channel *uchan); | |
35a9059d | 487 | int ust_app_enable_event_glb(struct ltt_ust_session *usess, |
28f23191 JG |
488 | struct ltt_ust_channel *uchan, |
489 | struct ltt_ust_event *uevent); | |
35a9059d | 490 | int ust_app_disable_event_glb(struct ltt_ust_session *usess, |
28f23191 JG |
491 | struct ltt_ust_channel *uchan, |
492 | struct ltt_ust_event *uevent); | |
55cc08a6 | 493 | int ust_app_add_ctx_channel_glb(struct ltt_ust_session *usess, |
28f23191 JG |
494 | struct ltt_ust_channel *uchan, |
495 | struct ltt_ust_context *uctx); | |
a9ad0c8f MD |
496 | void ust_app_global_update(struct ltt_ust_session *usess, struct ust_app *app); |
497 | void ust_app_global_update_all(struct ltt_ust_session *usess); | |
993578ff | 498 | void ust_app_global_update_event_notifier_rules(struct ust_app *app); |
cd9adb8b | 499 | void ust_app_global_update_all_event_notifier_rules(); |
91d76f53 | 500 | |
cd9adb8b JG |
501 | void ust_app_clean_list(); |
502 | int ust_app_ht_alloc(); | |
f6a9efaa | 503 | struct ust_app *ust_app_find_by_pid(pid_t pid); |
cd9adb8b | 504 | struct ust_app_stream *ust_app_alloc_stream(); |
d0b96690 DG |
505 | int ust_app_recv_registration(int sock, struct ust_register_msg *msg); |
506 | int ust_app_recv_notify(int sock); | |
507 | void ust_app_add(struct ust_app *app); | |
508 | struct ust_app *ust_app_create(struct ust_register_msg *msg, int sock); | |
d88aee68 | 509 | void ust_app_notify_sock_unregister(int sock); |
16d64977 | 510 | |
28f23191 JG |
511 | enum lttng_error_code ust_app_snapshot_record(const struct ltt_ust_session *usess, |
512 | const struct consumer_output *output, | |
513 | uint64_t nb_packets_per_stream); | |
514 | uint64_t ust_app_get_size_one_more_packet_per_stream(const struct ltt_ust_session *usess, | |
515 | uint64_t cur_nr_packets); | |
f20baf8e | 516 | struct ust_app *ust_app_find_by_sock(int sock); |
fb83fe64 | 517 | int ust_app_uid_get_channel_runtime_stats(uint64_t ust_session_id, |
28f23191 JG |
518 | struct cds_list_head *buffer_reg_uid_list, |
519 | struct consumer_output *consumer, | |
520 | uint64_t uchan_id, | |
521 | int overwrite, | |
522 | uint64_t *discarded, | |
523 | uint64_t *lost); | |
fb83fe64 | 524 | int ust_app_pid_get_channel_runtime_stats(struct ltt_ust_session *usess, |
28f23191 JG |
525 | struct ltt_ust_channel *uchan, |
526 | struct consumer_output *consumer, | |
527 | int overwrite, | |
528 | uint64_t *discarded, | |
529 | uint64_t *lost); | |
c2561365 | 530 | int ust_app_regenerate_statedump_all(struct ltt_ust_session *usess); |
28f23191 JG |
531 | enum lttng_error_code ust_app_create_channel_subdirectories(const struct ltt_ust_session *session); |
532 | int ust_app_release_object(struct ust_app *app, struct lttng_ust_abi_object_data *data); | |
44d3bd01 | 533 | |
da873412 JR |
534 | int ust_app_setup_event_notifier_group(struct ust_app *app); |
535 | ||
28f23191 | 536 | static inline int ust_app_supported() |
b51ec5b4 MD |
537 | { |
538 | return 1; | |
539 | } | |
540 | ||
16d64977 JG |
541 | ust_app_session *ust_app_lookup_app_session(const struct ltt_ust_session *usess, |
542 | const struct ust_app *app); | |
543 | lttng::sessiond::ust::registry_session * | |
544 | ust_app_get_session_registry(const ust_app_session::identifier& identifier); | |
545 | ||
546 | lttng_ht *ust_app_get_all(); | |
547 | ||
783db316 MD |
548 | bool ust_app_supports_notifiers(const struct ust_app *app); |
549 | bool ust_app_supports_counters(const struct ust_app *app); | |
550 | ||
a7db814e JG |
551 | bool ust_app_get(ust_app& app); |
552 | void ust_app_put(ust_app *app); | |
553 | ||
554 | using ust_app_reference = | |
555 | std::unique_ptr<ust_app, lttng::memory::create_deleter_class<ust_app, ust_app_put>::deleter>; | |
556 | ||
74d0b642 | 557 | #else /* HAVE_LIBLTTNG_UST_CTL */ |
3bd1e081 | 558 | |
28f23191 | 559 | static inline int ust_app_destroy_trace_all(struct ltt_ust_session *usess __attribute__((unused))) |
cc920def DG |
560 | { |
561 | return 0; | |
562 | } | |
f46376a1 | 563 | |
28f23191 JG |
564 | static inline int ust_app_start_trace(struct ltt_ust_session *usess __attribute__((unused)), |
565 | struct ust_app *app __attribute__((unused))) | |
421cb601 DG |
566 | { |
567 | return 0; | |
568 | } | |
f46376a1 | 569 | |
28f23191 | 570 | static inline int ust_app_start_trace_all(struct ltt_ust_session *usess __attribute__((unused))) |
d974f197 | 571 | { |
5cf5d0e7 | 572 | return 0; |
d974f197 | 573 | } |
f46376a1 | 574 | |
28f23191 | 575 | static inline int ust_app_stop_trace_all(struct ltt_ust_session *usess __attribute__((unused))) |
cc920def DG |
576 | { |
577 | return 0; | |
578 | } | |
f46376a1 | 579 | |
28f23191 | 580 | static inline int ust_app_list_events(struct lttng_event **events __attribute__((unused))) |
b551a063 | 581 | { |
db7c0497 | 582 | return -ENOSYS; |
b551a063 | 583 | } |
f46376a1 | 584 | |
28f23191 JG |
585 | static inline int ust_app_list_event_fields(struct lttng_event_field **fields |
586 | __attribute__((unused))) | |
da0bdb87 MD |
587 | { |
588 | return -ENOSYS; | |
589 | } | |
f46376a1 | 590 | |
28f23191 JG |
591 | static inline int ust_app_register(struct ust_register_msg *msg __attribute__((unused)), |
592 | int sock __attribute__((unused))) | |
3bd1e081 MD |
593 | { |
594 | return -ENOSYS; | |
595 | } | |
f46376a1 | 596 | |
28f23191 | 597 | static inline int ust_app_register_done(struct ust_app *app __attribute__((unused))) |
f2ca2e25 GF |
598 | { |
599 | return -ENOSYS; | |
600 | } | |
f46376a1 | 601 | |
28f23191 | 602 | static inline int ust_app_version(struct ust_app *app __attribute__((unused))) |
d0b96690 DG |
603 | { |
604 | return -ENOSYS; | |
605 | } | |
f46376a1 | 606 | |
a7db814e | 607 | static inline void ust_app_unregister_by_socket(int sock __attribute__((unused))) |
3bd1e081 MD |
608 | { |
609 | } | |
f46376a1 | 610 | |
28f23191 | 611 | static inline void ust_app_clean_list(void) |
3bd1e081 MD |
612 | { |
613 | } | |
f46376a1 | 614 | |
28f23191 | 615 | static inline struct ust_app_list *ust_app_get_list(void) |
3bd1e081 MD |
616 | { |
617 | return NULL; | |
618 | } | |
f46376a1 | 619 | |
28f23191 | 620 | static inline struct ust_app *ust_app_get_by_pid(pid_t pid __attribute__((unused))) |
3bd1e081 MD |
621 | { |
622 | return NULL; | |
623 | } | |
f46376a1 | 624 | |
28f23191 | 625 | static inline int ust_app_ht_alloc(void) |
12a84043 JG |
626 | { |
627 | return 0; | |
628 | } | |
f46376a1 | 629 | |
28f23191 JG |
630 | static inline void ust_app_global_update(struct ltt_ust_session *usess __attribute__((unused)), |
631 | struct ust_app *app __attribute__((unused))) | |
632 | { | |
633 | } | |
f46376a1 | 634 | |
28f23191 JG |
635 | static inline void ust_app_global_update_event_notifier_rules(struct ust_app *app |
636 | __attribute__((unused))) | |
637 | { | |
638 | } | |
f46376a1 | 639 | |
28f23191 JG |
640 | static inline void ust_app_global_update_all_event_notifier_rules(void) |
641 | { | |
642 | } | |
f46376a1 | 643 | |
28f23191 | 644 | static inline int ust_app_setup_event_notifier_group(struct ust_app *app __attribute__((unused))) |
da873412 JR |
645 | { |
646 | return 0; | |
647 | } | |
f46376a1 | 648 | |
28f23191 JG |
649 | static inline int ust_app_disable_channel_glb(struct ltt_ust_session *usess __attribute__((unused)), |
650 | struct ltt_ust_channel *uchan __attribute__((unused))) | |
d974f197 | 651 | { |
cc920def | 652 | return 0; |
d974f197 | 653 | } |
f46376a1 | 654 | |
28f23191 JG |
655 | static inline int ust_app_enable_channel_glb(struct ltt_ust_session *usess __attribute__((unused)), |
656 | struct ltt_ust_channel *uchan __attribute__((unused))) | |
487cf67c | 657 | { |
cc920def DG |
658 | return 0; |
659 | } | |
f46376a1 | 660 | |
28f23191 JG |
661 | static inline int ust_app_create_event_glb(struct ltt_ust_session *usess __attribute__((unused)), |
662 | struct ltt_ust_channel *uchan __attribute__((unused)), | |
663 | struct ltt_ust_event *uevent __attribute__((unused))) | |
35a9059d DG |
664 | { |
665 | return 0; | |
666 | } | |
f46376a1 | 667 | |
28f23191 JG |
668 | static inline int ust_app_disable_event_glb(struct ltt_ust_session *usess __attribute__((unused)), |
669 | struct ltt_ust_channel *uchan __attribute__((unused)), | |
670 | struct ltt_ust_event *uevent __attribute__((unused))) | |
cc920def DG |
671 | { |
672 | return 0; | |
487cf67c | 673 | } |
f46376a1 | 674 | |
28f23191 JG |
675 | static inline int ust_app_enable_event_glb(struct ltt_ust_session *usess __attribute__((unused)), |
676 | struct ltt_ust_channel *uchan __attribute__((unused)), | |
677 | struct ltt_ust_event *uevent __attribute__((unused))) | |
edb67388 DG |
678 | { |
679 | return 0; | |
680 | } | |
f46376a1 | 681 | |
28f23191 JG |
682 | static inline int ust_app_add_ctx_channel_glb(struct ltt_ust_session *usess __attribute__((unused)), |
683 | struct ltt_ust_channel *uchan __attribute__((unused)), | |
684 | struct ltt_ust_context *uctx __attribute__((unused))) | |
55cc08a6 DG |
685 | { |
686 | return 0; | |
687 | } | |
f46376a1 | 688 | |
28f23191 JG |
689 | static inline int ust_app_enable_event_pid(struct ltt_ust_session *usess __attribute__((unused)), |
690 | struct ltt_ust_channel *uchan __attribute__((unused)), | |
691 | struct ltt_ust_event *uevent __attribute__((unused)), | |
692 | pid_t pid __attribute__((unused))) | |
76d45b40 DG |
693 | { |
694 | return 0; | |
695 | } | |
f46376a1 | 696 | |
28f23191 JG |
697 | static inline int ust_app_recv_registration(int sock __attribute__((unused)), |
698 | struct ust_register_msg *msg __attribute__((unused))) | |
d0b96690 DG |
699 | { |
700 | return 0; | |
701 | } | |
f46376a1 | 702 | |
28f23191 | 703 | static inline int ust_app_recv_notify(int sock __attribute__((unused))) |
4466912f DG |
704 | { |
705 | return 0; | |
706 | } | |
f46376a1 | 707 | |
28f23191 JG |
708 | static inline struct ust_app *ust_app_create(struct ust_register_msg *msg __attribute__((unused)), |
709 | int sock __attribute__((unused))) | |
d0b96690 DG |
710 | { |
711 | return NULL; | |
712 | } | |
f46376a1 | 713 | |
28f23191 | 714 | static inline void ust_app_add(struct ust_app *app __attribute__((unused))) |
d0b96690 DG |
715 | { |
716 | } | |
f46376a1 | 717 | |
28f23191 | 718 | static inline void ust_app_notify_sock_unregister(int sock __attribute__((unused))) |
d88aee68 DG |
719 | { |
720 | } | |
f46376a1 | 721 | |
28f23191 JG |
722 | static inline enum lttng_error_code |
723 | ust_app_snapshot_record(struct ltt_ust_session *usess __attribute__((unused)), | |
724 | const struct consumer_output *output __attribute__((unused)), | |
725 | uint64_t max_stream_size __attribute__((unused))) | |
5c786ded | 726 | { |
7966af57 | 727 | return LTTNG_ERR_UNK; |
5c786ded | 728 | } |
f46376a1 | 729 | |
28f23191 JG |
730 | static inline unsigned int ust_app_get_nb_stream(struct ltt_ust_session *usess |
731 | __attribute__((unused))) | |
6dc3064a DG |
732 | { |
733 | return 0; | |
734 | } | |
f46376a1 | 735 | |
28f23191 JG |
736 | static inline void ust_app_update_event_notifier_error_count(struct lttng_trigger *lttng_trigger |
737 | __attribute__((unused))) | |
533a90fb FD |
738 | { |
739 | return; | |
740 | } | |
f46376a1 | 741 | |
28f23191 | 742 | static inline int ust_app_supported(void) |
b51ec5b4 MD |
743 | { |
744 | return 0; | |
745 | } | |
f46376a1 | 746 | |
28f23191 | 747 | static inline bool ust_app_supports_notifiers(const struct ust_app *app __attribute__((unused))) |
783db316 MD |
748 | { |
749 | return false; | |
750 | } | |
f46376a1 | 751 | |
28f23191 | 752 | static inline bool ust_app_supports_counters(const struct ust_app *app __attribute__((unused))) |
783db316 MD |
753 | { |
754 | return false; | |
755 | } | |
f46376a1 | 756 | |
28f23191 | 757 | static inline struct ust_app *ust_app_find_by_sock(int sock __attribute__((unused))) |
f20baf8e DG |
758 | { |
759 | return NULL; | |
760 | } | |
f46376a1 | 761 | |
28f23191 | 762 | static inline struct ust_app *ust_app_find_by_pid(pid_t pid __attribute__((unused))) |
95b1d17c DG |
763 | { |
764 | return NULL; | |
765 | } | |
f46376a1 | 766 | |
28f23191 JG |
767 | static inline uint64_t |
768 | ust_app_get_size_one_more_packet_per_stream(const struct ltt_ust_session *usess | |
769 | __attribute__((unused)), | |
770 | uint64_t cur_nr_packets __attribute__((unused))) | |
771 | { | |
16f35901 JG |
772 | return 0; |
773 | } | |
f46376a1 | 774 | |
28f23191 JG |
775 | static inline int ust_app_uid_get_channel_runtime_stats(uint64_t ust_session_id |
776 | __attribute__((unused)), | |
777 | struct cds_list_head *buffer_reg_uid_list | |
778 | __attribute__((unused)), | |
779 | struct consumer_output *consumer | |
780 | __attribute__((unused)), | |
781 | int overwrite __attribute__((unused)), | |
782 | uint64_t uchan_id __attribute__((unused)), | |
783 | uint64_t *discarded __attribute__((unused)), | |
784 | uint64_t *lost __attribute__((unused))) | |
fb83fe64 JD |
785 | { |
786 | return 0; | |
787 | } | |
788 | ||
28f23191 JG |
789 | static inline int |
790 | ust_app_pid_get_channel_runtime_stats(struct ltt_ust_session *usess __attribute__((unused)), | |
791 | struct ltt_ust_channel *uchan __attribute__((unused)), | |
792 | struct consumer_output *consumer __attribute__((unused)), | |
793 | int overwrite __attribute__((unused)), | |
794 | uint64_t *discarded __attribute__((unused)), | |
795 | uint64_t *lost __attribute__((unused))) | |
fb83fe64 JD |
796 | { |
797 | return 0; | |
798 | } | |
b51ec5b4 | 799 | |
28f23191 JG |
800 | static inline int ust_app_regenerate_statedump_all(struct ltt_ust_session *usess |
801 | __attribute__((unused))) | |
6f698634 JG |
802 | { |
803 | return 0; | |
804 | } | |
805 | ||
16d64977 JG |
806 | static inline enum lttng_error_code |
807 | ust_app_create_channel_subdirectories(const struct ltt_ust_session *session __attribute__((unused))) | |
5c408ad8 | 808 | { |
7966af57 | 809 | return LTTNG_ERR_UNK; |
5c408ad8 JD |
810 | } |
811 | ||
16d64977 | 812 | static inline ust_app_session *ust_app_lookup_app_session(const ltt_ust_session *, const ust_app *) |
d2956687 | 813 | { |
16d64977 | 814 | return nullptr; |
d2956687 JG |
815 | } |
816 | ||
16d64977 JG |
817 | static inline lttng::sessiond::ust::registry_session * |
818 | ust_app_get_session_registry(const ust_app_session::identifier&) | |
75018ab6 | 819 | { |
16d64977 | 820 | return nullptr; |
75018ab6 JG |
821 | } |
822 | ||
16d64977 | 823 | static inline lttng_ht *ust_app_get_all() |
4a9b9759 | 824 | { |
16d64977 | 825 | return nullptr; |
4a9b9759 MD |
826 | } |
827 | ||
16d64977 JG |
828 | static inline int ust_app_release_object(struct ust_app *app __attribute__((unused)), |
829 | struct lttng_ust_abi_object_data *data | |
830 | __attribute__((unused))) | |
04ed9e10 | 831 | { |
16d64977 | 832 | return 0; |
04ed9e10 JG |
833 | } |
834 | ||
a7db814e JG |
835 | static inline void ust_app_get(ust_app& app __attribute__((unused))) |
836 | { | |
837 | } | |
838 | ||
839 | static inline void ust_app_put(ust_app *app __attribute__((unused))) | |
840 | { | |
841 | } | |
842 | ||
74d0b642 | 843 | #endif /* HAVE_LIBLTTNG_UST_CTL */ |
3bd1e081 | 844 | |
f6a9efaa | 845 | #endif /* _LTT_UST_APP_H */ |