| 1 | /* |
| 2 | * Copyright (C) 2011 EfficiOS Inc. |
| 3 | * Copyright (C) 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com> |
| 4 | * |
| 5 | * SPDX-License-Identifier: GPL-2.0-only |
| 6 | * |
| 7 | */ |
| 8 | |
| 9 | #ifndef _LTT_UST_APP_H |
| 10 | #define _LTT_UST_APP_H |
| 11 | |
| 12 | #include "trace-class.hpp" |
| 13 | #include "trace-ust.hpp" |
| 14 | #include "ust-field-quirks.hpp" |
| 15 | |
| 16 | #include <common/format.hpp> |
| 17 | #include <common/index-allocator.hpp> |
| 18 | #include <common/reference.hpp> |
| 19 | #include <common/scope-exit.hpp> |
| 20 | #include <common/uuid.hpp> |
| 21 | |
| 22 | #include <list> |
| 23 | #include <stdint.h> |
| 24 | |
| 25 | #define UST_APP_EVENT_LIST_SIZE 32 |
| 26 | |
| 27 | /* Process name (short). */ |
| 28 | #define UST_APP_PROCNAME_LEN 16 |
| 29 | |
| 30 | struct lttng_bytecode; |
| 31 | struct lttng_ust_filter_bytecode; |
| 32 | |
| 33 | namespace lttng { |
| 34 | namespace sessiond { |
| 35 | namespace ust { |
| 36 | class registry_session; |
| 37 | } /* namespace ust */ |
| 38 | } /* namespace sessiond */ |
| 39 | } /* namespace lttng */ |
| 40 | |
| 41 | extern int the_ust_consumerd64_fd, the_ust_consumerd32_fd; |
| 42 | |
| 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 | |
| 53 | struct ust_app_ht_key { |
| 54 | const char *name; |
| 55 | const struct lttng_bytecode *filter; |
| 56 | enum lttng_ust_abi_loglevel_type loglevel_type; |
| 57 | int loglevel_value; |
| 58 | const struct lttng_event_exclusion *exclusion; |
| 59 | }; |
| 60 | |
| 61 | /* |
| 62 | * Application registration data structure. |
| 63 | */ |
| 64 | struct ust_register_msg { |
| 65 | enum lttng_ust_ctl_socket_type type; |
| 66 | uint32_t major; |
| 67 | uint32_t minor; |
| 68 | uint32_t abi_major; |
| 69 | uint32_t abi_minor; |
| 70 | pid_t pid; |
| 71 | pid_t ppid; |
| 72 | uid_t uid; |
| 73 | gid_t gid; |
| 74 | uint32_t bits_per_long; |
| 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; |
| 80 | int byte_order; /* BIG_ENDIAN or LITTLE_ENDIAN */ |
| 81 | char name[LTTNG_UST_ABI_PROCNAME_LEN]; |
| 82 | }; |
| 83 | |
| 84 | /* |
| 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. |
| 87 | */ |
| 88 | extern struct lttng_ht *ust_app_ht; |
| 89 | |
| 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. |
| 93 | * |
| 94 | * The 'sock' in question here is the 'command' socket. |
| 95 | */ |
| 96 | extern struct lttng_ht *ust_app_ht_by_sock; |
| 97 | |
| 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 | */ |
| 102 | extern struct lttng_ht *ust_app_ht_by_notify_sock; |
| 103 | |
| 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 | |
| 110 | struct ust_app_ctx { |
| 111 | int handle; |
| 112 | struct lttng_ust_context_attr ctx; |
| 113 | struct lttng_ust_abi_object_data *obj; |
| 114 | struct lttng_ht_node_ulong node; |
| 115 | struct cds_list_head list; |
| 116 | }; |
| 117 | |
| 118 | struct ust_app_event { |
| 119 | bool enabled; |
| 120 | int handle; |
| 121 | struct lttng_ust_abi_object_data *obj; |
| 122 | struct lttng_ust_abi_event attr; |
| 123 | char name[LTTNG_UST_ABI_SYM_NAME_LEN]; |
| 124 | struct lttng_ht_node_str node; |
| 125 | struct lttng_bytecode *filter; |
| 126 | struct lttng_event_exclusion *exclusion; |
| 127 | }; |
| 128 | |
| 129 | struct ust_app_event_notifier_rule { |
| 130 | bool enabled; |
| 131 | uint64_t error_counter_index; |
| 132 | int handle; |
| 133 | struct lttng_ust_abi_object_data *obj; |
| 134 | /* Holds a strong reference. */ |
| 135 | struct lttng_trigger *trigger; |
| 136 | /* Unique ID returned by the tracer to identify this event notifier. */ |
| 137 | uint64_t token; |
| 138 | struct lttng_ht_node_u64 node; |
| 139 | /* The trigger object owns the filter. */ |
| 140 | const struct lttng_bytecode *filter; |
| 141 | /* Owned by this. */ |
| 142 | struct lttng_event_exclusion *exclusion; |
| 143 | /* For delayed reclaim. */ |
| 144 | struct rcu_head rcu_head; |
| 145 | }; |
| 146 | |
| 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]; |
| 152 | struct lttng_ust_abi_object_data *obj; |
| 153 | /* Using a list of streams to keep order. */ |
| 154 | struct cds_list_head list; |
| 155 | }; |
| 156 | |
| 157 | struct ust_app_channel { |
| 158 | bool enabled; |
| 159 | int handle; |
| 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 |
| 163 | * does not know about this channel (i.e. an error occurred). |
| 164 | */ |
| 165 | uint64_t key; |
| 166 | /* Id of the tracing channel set on creation. */ |
| 167 | uint64_t tracing_channel_id; |
| 168 | /* Number of stream that this channel is expected to receive. */ |
| 169 | unsigned int expected_stream_count; |
| 170 | char name[LTTNG_UST_ABI_SYM_NAME_LEN]; |
| 171 | struct lttng_ust_abi_object_data *obj; |
| 172 | struct lttng_ust_ctl_consumer_channel_attr attr; |
| 173 | struct ust_app_stream_list streams; |
| 174 | /* Session pointer that owns this object. */ |
| 175 | struct ust_app_session *session; |
| 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 | */ |
| 181 | struct lttng_ht *ctx; |
| 182 | struct cds_list_head ctx_list; |
| 183 | |
| 184 | struct lttng_ht *events; |
| 185 | uint64_t tracefile_size; |
| 186 | uint64_t tracefile_count; |
| 187 | uint64_t monitor_timer_interval; |
| 188 | /* |
| 189 | * Node indexed by channel name in the channels' hash table of a session. |
| 190 | */ |
| 191 | struct lttng_ht_node_str node; |
| 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; |
| 197 | /* For delayed reclaim */ |
| 198 | struct rcu_head rcu_head; |
| 199 | }; |
| 200 | |
| 201 | struct ust_app_session { |
| 202 | private: |
| 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 | } |
| 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 | |
| 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 | } |
| 297 | |
| 298 | bool enabled = false; |
| 299 | /* started: has the session been in started state at any time ? */ |
| 300 | bool started = false; /* allows detection of start vs restart. */ |
| 301 | int handle = 0; /* used has unique identifier for app session */ |
| 302 | |
| 303 | bool deleted = false; /* Session deleted flag. Check with lock held. */ |
| 304 | |
| 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 | */ |
| 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 = {}; |
| 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 | */ |
| 317 | struct lttng_ht_node_ulong ust_objd_node = {}; |
| 318 | /* Starts with 'ust'; no leading slash. */ |
| 319 | char path[PATH_MAX] = {}; |
| 320 | /* UID/GID of the application owning the session */ |
| 321 | struct lttng_credentials real_credentials = {}; |
| 322 | /* Effective UID and GID. Same as the tracing session. */ |
| 323 | struct lttng_credentials effective_credentials = {}; |
| 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 | */ |
| 328 | struct consumer_output *consumer = nullptr; |
| 329 | enum lttng_buffer_type buffer_type = LTTNG_BUFFER_PER_PID; |
| 330 | /* ABI of the session. Same value as the application. */ |
| 331 | uint32_t bits_per_long = 0; |
| 332 | /* For delayed reclaim */ |
| 333 | struct rcu_head rcu_head = {}; |
| 334 | /* If the channel's streams have to be outputed or not. */ |
| 335 | unsigned int output_traces = 0; |
| 336 | unsigned int live_timer_interval = 0; /* usec */ |
| 337 | |
| 338 | /* Metadata channel attributes. */ |
| 339 | struct lttng_ust_ctl_consumer_channel_attr metadata_attr = {}; |
| 340 | |
| 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; |
| 351 | }; |
| 352 | |
| 353 | /* |
| 354 | * Registered traceable applications. Libust registers to the session daemon |
| 355 | * and a linked list is kept of all running traceable app. |
| 356 | */ |
| 357 | struct ust_app { |
| 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 | |
| 365 | /* Traffic initiated from the session daemon to the application. */ |
| 366 | int sock; |
| 367 | pthread_mutex_t sock_lock; /* Protects sock protocol. */ |
| 368 | |
| 369 | /* Traffic initiated from the application to the session daemon. */ |
| 370 | int notify_sock; |
| 371 | pid_t pid; |
| 372 | pid_t ppid; |
| 373 | uid_t uid; /* User ID that owns the apps */ |
| 374 | gid_t gid; /* Group ID that owns the apps */ |
| 375 | |
| 376 | /* App ABI. */ |
| 377 | lttng::sessiond::trace::abi abi; |
| 378 | |
| 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. */ |
| 382 | struct lttng_ust_abi_tracer_version version; |
| 383 | uint32_t v_major; /* Version major number */ |
| 384 | uint32_t v_minor; /* Version minor number */ |
| 385 | /* Extra for the NULL byte. */ |
| 386 | char name[UST_APP_PROCNAME_LEN + 1]; |
| 387 | |
| 388 | struct lttng_ht *sessions; |
| 389 | struct lttng_ht_node_ulong pid_n; |
| 390 | struct lttng_ht_node_ulong sock_n; |
| 391 | struct lttng_ht_node_ulong notify_sock_n; |
| 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 | std::list<ust_app_session *> sessions_to_teardown; |
| 402 | /* |
| 403 | * Hash table containing ust_app_channel indexed by channel objd. |
| 404 | */ |
| 405 | struct lttng_ht *ust_objd; |
| 406 | /* |
| 407 | * Hash table containing ust_app_session indexed by objd. |
| 408 | */ |
| 409 | struct lttng_ht *ust_sessions_objd; |
| 410 | |
| 411 | /* |
| 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. |
| 416 | */ |
| 417 | int agent_app_sock; |
| 418 | /* |
| 419 | * Time at which the app is registred. |
| 420 | * Used for path creation |
| 421 | */ |
| 422 | time_t registration_time; |
| 423 | /* |
| 424 | * Event notifier |
| 425 | */ |
| 426 | struct { |
| 427 | /* |
| 428 | * Handle to the lttng_ust object representing the event |
| 429 | * notifier group. |
| 430 | */ |
| 431 | struct lttng_ust_abi_object_data *object; |
| 432 | struct lttng_pipe *event_pipe; |
| 433 | struct lttng_ust_abi_object_data *counter; |
| 434 | struct lttng_ust_abi_object_data **counter_cpu; |
| 435 | int nr_counter_cpu; |
| 436 | } event_notifier_group; |
| 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; |
| 442 | |
| 443 | lttng::sessiond::ust::ctl_field_quirks ctl_field_quirks() const; |
| 444 | }; |
| 445 | |
| 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 | */ |
| 450 | namespace fmt { |
| 451 | template <> |
| 452 | struct formatter<ust_app> : formatter<std::string> { |
| 453 | template <typename FormatContextType> |
| 454 | typename FormatContextType::iterator format(const ust_app& app, |
| 455 | FormatContextType& ctx) const |
| 456 | { |
| 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)); |
| 468 | } |
| 469 | }; |
| 470 | } /* namespace fmt */ |
| 471 | |
| 472 | #ifdef HAVE_LIBLTTNG_UST_CTL |
| 473 | |
| 474 | int ust_app_register(struct ust_register_msg *msg, int sock); |
| 475 | int ust_app_register_done(struct ust_app *app); |
| 476 | int ust_app_version(struct ust_app *app); |
| 477 | void ust_app_unregister_by_socket(int sock); |
| 478 | int ust_app_start_trace_all(struct ltt_ust_session *usess); |
| 479 | int ust_app_stop_trace_all(struct ltt_ust_session *usess); |
| 480 | int ust_app_destroy_trace_all(struct ltt_ust_session *usess); |
| 481 | int ust_app_list_events(struct lttng_event **events); |
| 482 | int ust_app_list_event_fields(struct lttng_event_field **fields); |
| 483 | int ust_app_create_event_glb(struct ltt_ust_session *usess, |
| 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); |
| 488 | int ust_app_enable_event_glb(struct ltt_ust_session *usess, |
| 489 | struct ltt_ust_channel *uchan, |
| 490 | struct ltt_ust_event *uevent); |
| 491 | int ust_app_disable_event_glb(struct ltt_ust_session *usess, |
| 492 | struct ltt_ust_channel *uchan, |
| 493 | struct ltt_ust_event *uevent); |
| 494 | int ust_app_add_ctx_channel_glb(struct ltt_ust_session *usess, |
| 495 | struct ltt_ust_channel *uchan, |
| 496 | struct ltt_ust_context *uctx); |
| 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); |
| 499 | void ust_app_global_update_event_notifier_rules(struct ust_app *app); |
| 500 | void ust_app_global_update_all_event_notifier_rules(); |
| 501 | |
| 502 | void ust_app_clean_list(); |
| 503 | int ust_app_ht_alloc(); |
| 504 | struct ust_app *ust_app_find_by_pid(pid_t pid); |
| 505 | struct ust_app_stream *ust_app_alloc_stream(); |
| 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); |
| 510 | void ust_app_notify_sock_unregister(int sock); |
| 511 | |
| 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); |
| 517 | struct ust_app *ust_app_find_by_sock(int sock); |
| 518 | int ust_app_uid_get_channel_runtime_stats(uint64_t ust_session_id, |
| 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); |
| 525 | int ust_app_pid_get_channel_runtime_stats(struct ltt_ust_session *usess, |
| 526 | struct ltt_ust_channel *uchan, |
| 527 | struct consumer_output *consumer, |
| 528 | int overwrite, |
| 529 | uint64_t *discarded, |
| 530 | uint64_t *lost); |
| 531 | int ust_app_regenerate_statedump_all(struct ltt_ust_session *usess); |
| 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); |
| 534 | |
| 535 | int ust_app_setup_event_notifier_group(struct ust_app *app); |
| 536 | |
| 537 | static inline int ust_app_supported() |
| 538 | { |
| 539 | return 1; |
| 540 | } |
| 541 | |
| 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 | |
| 549 | bool ust_app_supports_notifiers(const struct ust_app *app); |
| 550 | bool ust_app_supports_counters(const struct ust_app *app); |
| 551 | |
| 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 | |
| 558 | #else /* HAVE_LIBLTTNG_UST_CTL */ |
| 559 | |
| 560 | static inline int ust_app_destroy_trace_all(struct ltt_ust_session *usess __attribute__((unused))) |
| 561 | { |
| 562 | return 0; |
| 563 | } |
| 564 | |
| 565 | static inline int ust_app_start_trace(struct ltt_ust_session *usess __attribute__((unused)), |
| 566 | struct ust_app *app __attribute__((unused))) |
| 567 | { |
| 568 | return 0; |
| 569 | } |
| 570 | |
| 571 | static inline int ust_app_start_trace_all(struct ltt_ust_session *usess __attribute__((unused))) |
| 572 | { |
| 573 | return 0; |
| 574 | } |
| 575 | |
| 576 | static inline int ust_app_stop_trace_all(struct ltt_ust_session *usess __attribute__((unused))) |
| 577 | { |
| 578 | return 0; |
| 579 | } |
| 580 | |
| 581 | static inline int ust_app_list_events(struct lttng_event **events __attribute__((unused))) |
| 582 | { |
| 583 | return -ENOSYS; |
| 584 | } |
| 585 | |
| 586 | static inline int ust_app_list_event_fields(struct lttng_event_field **fields |
| 587 | __attribute__((unused))) |
| 588 | { |
| 589 | return -ENOSYS; |
| 590 | } |
| 591 | |
| 592 | static inline int ust_app_register(struct ust_register_msg *msg __attribute__((unused)), |
| 593 | int sock __attribute__((unused))) |
| 594 | { |
| 595 | return -ENOSYS; |
| 596 | } |
| 597 | |
| 598 | static inline int ust_app_register_done(struct ust_app *app __attribute__((unused))) |
| 599 | { |
| 600 | return -ENOSYS; |
| 601 | } |
| 602 | |
| 603 | static inline int ust_app_version(struct ust_app *app __attribute__((unused))) |
| 604 | { |
| 605 | return -ENOSYS; |
| 606 | } |
| 607 | |
| 608 | static inline void ust_app_unregister_by_socket(int sock __attribute__((unused))) |
| 609 | { |
| 610 | } |
| 611 | |
| 612 | static inline void ust_app_clean_list(void) |
| 613 | { |
| 614 | } |
| 615 | |
| 616 | static inline struct ust_app_list *ust_app_get_list(void) |
| 617 | { |
| 618 | return NULL; |
| 619 | } |
| 620 | |
| 621 | static inline struct ust_app *ust_app_get_by_pid(pid_t pid __attribute__((unused))) |
| 622 | { |
| 623 | return NULL; |
| 624 | } |
| 625 | |
| 626 | static inline int ust_app_ht_alloc(void) |
| 627 | { |
| 628 | return 0; |
| 629 | } |
| 630 | |
| 631 | static inline void ust_app_global_update(struct ltt_ust_session *usess __attribute__((unused)), |
| 632 | struct ust_app *app __attribute__((unused))) |
| 633 | { |
| 634 | } |
| 635 | |
| 636 | static inline void ust_app_global_update_event_notifier_rules(struct ust_app *app |
| 637 | __attribute__((unused))) |
| 638 | { |
| 639 | } |
| 640 | |
| 641 | static inline void ust_app_global_update_all_event_notifier_rules(void) |
| 642 | { |
| 643 | } |
| 644 | |
| 645 | static inline int ust_app_setup_event_notifier_group(struct ust_app *app __attribute__((unused))) |
| 646 | { |
| 647 | return 0; |
| 648 | } |
| 649 | |
| 650 | static inline int ust_app_disable_channel_glb(struct ltt_ust_session *usess __attribute__((unused)), |
| 651 | struct ltt_ust_channel *uchan __attribute__((unused))) |
| 652 | { |
| 653 | return 0; |
| 654 | } |
| 655 | |
| 656 | static inline int ust_app_enable_channel_glb(struct ltt_ust_session *usess __attribute__((unused)), |
| 657 | struct ltt_ust_channel *uchan __attribute__((unused))) |
| 658 | { |
| 659 | return 0; |
| 660 | } |
| 661 | |
| 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))) |
| 665 | { |
| 666 | return 0; |
| 667 | } |
| 668 | |
| 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))) |
| 672 | { |
| 673 | return 0; |
| 674 | } |
| 675 | |
| 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))) |
| 679 | { |
| 680 | return 0; |
| 681 | } |
| 682 | |
| 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))) |
| 686 | { |
| 687 | return 0; |
| 688 | } |
| 689 | |
| 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))) |
| 694 | { |
| 695 | return 0; |
| 696 | } |
| 697 | |
| 698 | static inline int ust_app_recv_registration(int sock __attribute__((unused)), |
| 699 | struct ust_register_msg *msg __attribute__((unused))) |
| 700 | { |
| 701 | return 0; |
| 702 | } |
| 703 | |
| 704 | static inline int ust_app_recv_notify(int sock __attribute__((unused))) |
| 705 | { |
| 706 | return 0; |
| 707 | } |
| 708 | |
| 709 | static inline struct ust_app *ust_app_create(struct ust_register_msg *msg __attribute__((unused)), |
| 710 | int sock __attribute__((unused))) |
| 711 | { |
| 712 | return NULL; |
| 713 | } |
| 714 | |
| 715 | static inline void ust_app_add(struct ust_app *app __attribute__((unused))) |
| 716 | { |
| 717 | } |
| 718 | |
| 719 | static inline void ust_app_notify_sock_unregister(int sock __attribute__((unused))) |
| 720 | { |
| 721 | } |
| 722 | |
| 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))) |
| 727 | { |
| 728 | return LTTNG_ERR_UNK; |
| 729 | } |
| 730 | |
| 731 | static inline unsigned int ust_app_get_nb_stream(struct ltt_ust_session *usess |
| 732 | __attribute__((unused))) |
| 733 | { |
| 734 | return 0; |
| 735 | } |
| 736 | |
| 737 | static inline void ust_app_update_event_notifier_error_count(struct lttng_trigger *lttng_trigger |
| 738 | __attribute__((unused))) |
| 739 | { |
| 740 | return; |
| 741 | } |
| 742 | |
| 743 | static inline int ust_app_supported(void) |
| 744 | { |
| 745 | return 0; |
| 746 | } |
| 747 | |
| 748 | static inline bool ust_app_supports_notifiers(const struct ust_app *app __attribute__((unused))) |
| 749 | { |
| 750 | return false; |
| 751 | } |
| 752 | |
| 753 | static inline bool ust_app_supports_counters(const struct ust_app *app __attribute__((unused))) |
| 754 | { |
| 755 | return false; |
| 756 | } |
| 757 | |
| 758 | static inline struct ust_app *ust_app_find_by_sock(int sock __attribute__((unused))) |
| 759 | { |
| 760 | return NULL; |
| 761 | } |
| 762 | |
| 763 | static inline struct ust_app *ust_app_find_by_pid(pid_t pid __attribute__((unused))) |
| 764 | { |
| 765 | return NULL; |
| 766 | } |
| 767 | |
| 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 | { |
| 773 | return 0; |
| 774 | } |
| 775 | |
| 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))) |
| 786 | { |
| 787 | return 0; |
| 788 | } |
| 789 | |
| 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))) |
| 797 | { |
| 798 | return 0; |
| 799 | } |
| 800 | |
| 801 | static inline int ust_app_regenerate_statedump_all(struct ltt_ust_session *usess |
| 802 | __attribute__((unused))) |
| 803 | { |
| 804 | return 0; |
| 805 | } |
| 806 | |
| 807 | static inline enum lttng_error_code |
| 808 | ust_app_create_channel_subdirectories(const struct ltt_ust_session *session __attribute__((unused))) |
| 809 | { |
| 810 | return LTTNG_ERR_UNK; |
| 811 | } |
| 812 | |
| 813 | static inline ust_app_session *ust_app_lookup_app_session(const ltt_ust_session *, const ust_app *) |
| 814 | { |
| 815 | return nullptr; |
| 816 | } |
| 817 | |
| 818 | static inline lttng::sessiond::ust::registry_session * |
| 819 | ust_app_get_session_registry(const ust_app_session::identifier&) |
| 820 | { |
| 821 | return nullptr; |
| 822 | } |
| 823 | |
| 824 | static inline lttng_ht *ust_app_get_all() |
| 825 | { |
| 826 | return nullptr; |
| 827 | } |
| 828 | |
| 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))) |
| 832 | { |
| 833 | return 0; |
| 834 | } |
| 835 | |
| 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 | |
| 844 | #endif /* HAVE_LIBLTTNG_UST_CTL */ |
| 845 | |
| 846 | #endif /* _LTT_UST_APP_H */ |