Docs: sessiond: document the role of an application's two sockets
[lttng-tools.git] / src / bin / lttng-sessiond / ust-app.hpp
index 48dc7b64ef5557df6930ed944ce6fb939491141f..3200b654986596fb2eda518f96da35e2bccb097e 100644 (file)
 #include <stdint.h>
 
 #include <common/index-allocator.hpp>
+#include <common/format.hpp>
 #include <common/uuid.hpp>
 
 #include "trace-ust.hpp"
 #include "ust-registry.hpp"
+#include "ust-registry-session.hpp"
 #include "session.hpp"
+#include "ust-field-convert.hpp"
 
 #define UST_APP_EVENT_LIST_SIZE 32
 
@@ -103,7 +106,7 @@ struct ust_app_ctx {
 };
 
 struct ust_app_event {
-       int enabled;
+       bool enabled;
        int handle;
        struct lttng_ust_abi_object_data *obj;
        struct lttng_ust_abi_event attr;
@@ -114,7 +117,7 @@ struct ust_app_event {
 };
 
 struct ust_app_event_notifier_rule {
-       int enabled;
+       bool enabled;
        uint64_t error_counter_index;
        int handle;
        struct lttng_ust_abi_object_data *obj;
@@ -142,7 +145,7 @@ struct ust_app_stream {
 };
 
 struct ust_app_channel {
-       int enabled;
+       bool enabled;
        int handle;
        /*
         * Unique key used to identify the channel on the consumer side.
@@ -193,9 +196,9 @@ struct ust_app_session {
         */
        pthread_mutex_t lock;
 
-       int enabled;
+       bool enabled;
        /* started: has the session been in started state at any time ? */
-       int started;  /* allows detection of start vs restart. */
+       bool started;  /* allows detection of start vs restart. */
        int handle;   /* used has unique identifier for app session */
 
        bool deleted;   /* Session deleted flag. Check with lock held. */
@@ -246,23 +249,19 @@ struct ust_app_session {
  * and a linked list is kept of all running traceable app.
  */
 struct ust_app {
+       /* Traffic initiated from the session daemon to the application. */
        int sock;
        pthread_mutex_t sock_lock;      /* Protects sock protocol. */
 
+       /* Traffic initiated from the application to the session daemon. */
        int notify_sock;
        pid_t pid;
        pid_t ppid;
        uid_t uid;           /* User ID that owns the apps */
        gid_t gid;           /* Group ID that owns the apps */
 
-       /* App ABI */
-       uint32_t bits_per_long;
-       uint32_t uint8_t_alignment;
-       uint32_t uint16_t_alignment;
-       uint32_t uint32_t_alignment;
-       uint32_t uint64_t_alignment;
-       uint32_t long_alignment;
-       int byte_order;         /* BIG_ENDIAN or LITTLE_ENDIAN */
+       /* App ABI. */
+       lttng::sessiond::trace::abi abi;
 
        int compatible; /* If the lttng-ust tracer version does not match the
                                           supported version of the session daemon, this flag is
@@ -328,7 +327,28 @@ struct ust_app {
         * (ust_app_event_notifier_rule) by their token's value.
         */
        struct lttng_ht *token_to_event_notifier_rule_ht;
+
+       lttng::sessiond::ust::ctl_field_quirks ctl_field_quirks() const;
+};
+
+/*
+ * Due to a bug in g++ < 7.1, this specialization must be enclosed in the fmt namespace,
+ * see https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56480.
+ */
+namespace fmt {
+template <>
+struct formatter<ust_app> : formatter<std::string> {
+       template <typename FormatContextType>
+       typename FormatContextType::iterator format(const ust_app& app, FormatContextType& ctx)
+       {
+               return format_to(ctx.out(),
+                               "{{ procname = `{}`, ppid = {}, pid = {}, uid = {}, gid = {}, version = {}.{}, registration time = {} }}",
+                               app.name, app.ppid, app.pid, app.uid, app.gid, app.v_major,
+                               app.v_minor,
+                               lttng::utils::time_to_iso8601_str(app.registration_time));
+       }
 };
+} /* namespace fmt */
 
 #ifdef HAVE_LIBLTTNG_UST_CTL
 
@@ -356,19 +376,20 @@ int ust_app_add_ctx_channel_glb(struct ltt_ust_session *usess,
 void ust_app_global_update(struct ltt_ust_session *usess, struct ust_app *app);
 void ust_app_global_update_all(struct ltt_ust_session *usess);
 void ust_app_global_update_event_notifier_rules(struct ust_app *app);
-void ust_app_global_update_all_event_notifier_rules(void);
+void ust_app_global_update_all_event_notifier_rules();
 
-void ust_app_clean_list(void);
-int ust_app_ht_alloc(void);
+void ust_app_clean_list();
+int ust_app_ht_alloc();
 struct ust_app *ust_app_find_by_pid(pid_t pid);
-struct ust_app_stream *ust_app_alloc_stream(void);
+struct ust_app_stream *ust_app_alloc_stream();
 int ust_app_recv_registration(int sock, struct ust_register_msg *msg);
 int ust_app_recv_notify(int sock);
 void ust_app_add(struct ust_app *app);
 struct ust_app *ust_app_create(struct ust_register_msg *msg, int sock);
 void ust_app_notify_sock_unregister(int sock);
-ssize_t ust_app_push_metadata(ust_registry_session *registry,
-               struct consumer_socket *socket, int send_zero_data);
+ssize_t ust_app_push_metadata(const lttng::sessiond::ust::registry_session::locked_ptr& registry,
+               struct consumer_socket *socket,
+               int send_zero_data);
 void ust_app_destroy(struct ust_app *app);
 enum lttng_error_code ust_app_snapshot_record(
                const struct ltt_ust_session *usess,
@@ -397,7 +418,7 @@ enum lttng_error_code ust_app_open_packets(struct ltt_session *session);
 int ust_app_setup_event_notifier_group(struct ust_app *app);
 
 static inline
-int ust_app_supported(void)
+int ust_app_supported()
 {
        return 1;
 }
@@ -616,7 +637,7 @@ void ust_app_notify_sock_unregister(int sock __attribute__((unused)))
 
 static inline
 ssize_t ust_app_push_metadata(
-               ust_registry_session *registry __attribute__((unused)),
+               lttng::sessiond::ust::registry_session *registry __attribute__((unused)),
                struct consumer_socket *socket __attribute__((unused)),
                int send_zero_data __attribute__((unused)))
 {
This page took 0.025635 seconds and 4 git commands to generate.