Fix: syscall event rule: emission sites not compared in is_equal
[lttng-tools.git] / src / bin / lttng-sessiond / ust-registry.hpp
index 627ae06c0a65ee91aa058e75123f8113df8042cd..4bb14be6fcc7d3a1f6c76ffa674bc847927c3650 100644 (file)
@@ -18,7 +18,6 @@
 #include "ust-clock-class.hpp"
 #include "ust-registry-channel.hpp"
 #include "ust-registry-event.hpp"
-#include "ust-registry-session.hpp"
 
 #include <common/format.hpp>
 #include <common/hashtable/hashtable.hpp>
 #include <string>
 #include <type_traits>
 
-#define CTF_SPEC_MAJOR 1
-#define CTF_SPEC_MINOR 8
+#define CTF_SPEC_MAJOR 1
+#define CTF_SPEC_MINOR 8
 
 struct ust_app;
 
 namespace lttng {
 namespace sessiond {
 namespace ust {
-namespace details {
 
-template <class MappingIntegerType>
-typename trace::typed_enumeration_type<MappingIntegerType>::mapping mapping_from_ust_ctl_entry(
-               const lttng_ust_ctl_enum_entry& entry)
-{
-       if (entry.u.extra.options & LTTNG_UST_CTL_UST_ENUM_ENTRY_OPTION_IS_AUTO) {
-               return {entry.string};
+class registry_session;
 
-       } else {
-               return {entry.string,
-                               {(MappingIntegerType) entry.start.value,
-                                               (MappingIntegerType) entry.end.value}};
-       }
-}
+namespace details {
 
 template <class MappingIntegerType>
-typename trace::typed_enumeration_type<MappingIntegerType>::mappings mappings_from_ust_ctl_entries(
-               const lttng_ust_ctl_enum_entry *in_entries, size_t in_entry_count)
+typename trace::typed_enumeration_type<MappingIntegerType>::mappings
+mappings_from_ust_ctl_entries(const lttng_ust_ctl_enum_entry *in_entries, size_t in_entry_count)
 {
        typename trace::typed_enumeration_type<MappingIntegerType>::mappings mappings;
 
+       MappingIntegerType next_range_begin = 0;
        for (size_t entry_idx = 0; entry_idx < in_entry_count; entry_idx++) {
                const auto& entry = in_entries[entry_idx];
-
-               mappings.emplace_back(mapping_from_ust_ctl_entry<MappingIntegerType>(entry));
+               MappingIntegerType range_begin, range_end;
+
+               if (entry.u.extra.options & LTTNG_UST_CTL_UST_ENUM_ENTRY_OPTION_IS_AUTO) {
+                       range_begin = range_end = next_range_begin;
+               } else {
+                       range_begin = (MappingIntegerType) entry.start.value;
+                       range_end = (MappingIntegerType) entry.end.value;
+               }
+
+               next_range_begin = range_end + 1;
+               mappings.emplace_back(
+                       entry.string,
+                       typename trace::typed_enumeration_type<MappingIntegerType>::mapping::range_t{
+                               range_begin, range_end });
        }
 
        return mappings;
@@ -77,10 +78,16 @@ typename trace::typed_enumeration_type<MappingIntegerType>::mappings mappings_fr
 
 class registry_enum {
 public:
-       using const_rcu_protected_reference = lttng::locked_reference<const registry_enum, lttng::urcu::unique_read_lock>;
+       using const_rcu_protected_reference =
+               lttng::locked_reference<const registry_enum, lttng::urcu::unique_read_lock>;
 
-       registry_enum(std::string name, enum lttng::sessiond::trace::integer_type::signedness signedness);
+       registry_enum(std::string name,
+                     enum lttng::sessiond::trace::integer_type::signedness signedness);
        virtual ~registry_enum() = default;
+       registry_enum(const registry_enum&) = delete;
+       registry_enum(registry_enum&&) = delete;
+       registry_enum& operator=(registry_enum&&) = delete;
+       registry_enum& operator=(const registry_enum&) = delete;
 
        std::string name;
        enum lttng::sessiond::trace::integer_type::signedness signedness;
@@ -92,6 +99,7 @@ public:
        struct rcu_head rcu_head;
 
        friend bool operator==(const registry_enum& lhs, const registry_enum& rhs) noexcept;
+
 protected:
        virtual bool _is_equal(const registry_enum& other) const noexcept = 0;
 };
@@ -102,27 +110,27 @@ template <class MappingIntegerType>
 class registry_typed_enum : public registry_enum {
 public:
        registry_typed_enum(const char *in_name,
-                       const lttng_ust_ctl_enum_entry *entries,
-                       size_t entry_count) :
+                           const lttng_ust_ctl_enum_entry *entries,
+                           size_t entry_count) :
                registry_enum(in_name,
-                               std::is_signed<MappingIntegerType>::value ?
-                                               lttng::sessiond::trace::integer_type::signedness::SIGNED :
-                                                     lttng::sessiond::trace::integer_type::signedness::UNSIGNED),
-               _mappings{std::make_shared<
-                               typename trace::typed_enumeration_type<MappingIntegerType>::mappings>(
-                               details::mappings_from_ust_ctl_entries<MappingIntegerType>(
-                                               entries, entry_count))}
+                             std::is_signed<MappingIntegerType>::value ?
+                                     lttng::sessiond::trace::integer_type::signedness::SIGNED :
+                                     lttng::sessiond::trace::integer_type::signedness::UNSIGNED),
+               _mappings{ std::make_shared<
+                       typename trace::typed_enumeration_type<MappingIntegerType>::mappings>(
+                       details::mappings_from_ust_ctl_entries<MappingIntegerType>(entries,
+                                                                                  entry_count)) }
        {
        }
 
        const typename std::shared_ptr<const typename lttng::sessiond::trace::typed_enumeration_type<
-                       MappingIntegerType>::mappings>
-                       _mappings;
+               MappingIntegerType>::mappings>
+               _mappings;
 
 protected:
-       virtual bool _is_equal(const registry_enum& base_other) const noexcept
+       bool _is_equal(const registry_enum& base_other) const noexcept override
        {
-               const auto &other = static_cast<decltype(*this)&>(base_other);
+               const autoother = static_cast<decltype(*this)&>(base_other);
 
                /* Don't compare IDs as some comparisons are performed before an id is assigned. */
                return this->name == other.name && *this->_mappings == *other._mappings;
@@ -143,152 +151,116 @@ using registry_unsigned_enum = registry_typed_enum<uint64_t>;
  *
  * Return new instance on success, nullptr on error.
  */
-lttng::sessiond::ust::registry_session *ust_registry_session_per_uid_create(
-               const lttng::sessiond::trace::abi& abi,
-               uint32_t major,
-               uint32_t minor,
-               const char *root_shm_path,
-               const char *shm_path,
-               uid_t euid,
-               gid_t egid,
-               uint64_t tracing_id,
-               uid_t tracing_uid);
+lttng::sessiond::ust::registry_session *
+ust_registry_session_per_uid_create(const lttng::sessiond::trace::abi& abi,
+                                   uint32_t major,
+                                   uint32_t minor,
+                                   const char *root_shm_path,
+                                   const char *shm_path,
+                                   uid_t euid,
+                                   gid_t egid,
+                                   uint64_t tracing_id,
+                                   uid_t tracing_uid);
 
 /*
  * Create per-pid registry with default values.
  *
  * Return new instance on success, nullptr on error.
  */
-lttng::sessiond::ust::registry_session *ust_registry_session_per_pid_create(struct ust_app *app,
-               const lttng::sessiond::trace::abi& abi,
-               uint32_t major,
-               uint32_t minor,
-               const char *root_shm_path,
-               const char *shm_path,
-               uid_t euid,
-               gid_t egid,
-               uint64_t tracing_id);
+lttng::sessiond::ust::registry_session *
+ust_registry_session_per_pid_create(struct ust_app *app,
+                                   const lttng::sessiond::trace::abi& abi,
+                                   uint32_t major,
+                                   uint32_t minor,
+                                   const char *root_shm_path,
+                                   const char *shm_path,
+                                   uid_t euid,
+                                   gid_t egid,
+                                   uint64_t tracing_id);
 void ust_registry_session_destroy(lttng::sessiond::ust::registry_session *session);
 
 void ust_registry_channel_destroy_event(lttng::sessiond::ust::registry_channel *chan,
-               lttng::sessiond::ust::registry_event *event);
-
-int ust_registry_create_or_find_enum(lttng::sessiond::ust::registry_session *session,
-               int session_objd, char *name,
-               struct lttng_ust_ctl_enum_entry *entries, size_t nr_entries,
-               uint64_t *enum_id);
-lttng::sessiond::ust::registry_enum::const_rcu_protected_reference
-ust_registry_lookup_enum_by_id(const lttng::sessiond::ust::registry_session *session,
-               const char *name, uint64_t id);
-void ust_registry_destroy_enum(lttng::sessiond::ust::registry_session *reg_session,
-               lttng::sessiond::ust::registry_enum *reg_enum);
+                                       lttng::sessiond::ust::registry_event *event);
+
 #else /* HAVE_LIBLTTNG_UST_CTL */
 
-static inline
-lttng::sessiond::ust::registry_session *ust_registry_session_per_uid_create(
-               uint32_t bits_per_long __attribute__((unused)),
-               uint32_t uint8_t_alignment __attribute__((unused)),
-               uint32_t uint16_t_alignment __attribute__((unused)),
-               uint32_t uint32_t_alignment __attribute__((unused)),
-               uint32_t uint64_t_alignment __attribute__((unused)),
-               uint32_t long_alignment __attribute__((unused)),
-               int byte_order __attribute__((unused)),
-               uint32_t major __attribute__((unused)),
-               uint32_t minor __attribute__((unused)),
-               const char *root_shm_path __attribute__((unused)),
-               const char *shm_path __attribute__((unused)),
-               uid_t euid __attribute__((unused)),
-               gid_t egid __attribute__((unused)),
-               uint64_t tracing_id __attribute__((unused)),
-               uid_t tracing_uid __attribute__((unused)))
+static inline lttng::sessiond::ust::registry_session *
+ust_registry_session_per_uid_create(uint32_t bits_per_long __attribute__((unused)),
+                                   uint32_t uint8_t_alignment __attribute__((unused)),
+                                   uint32_t uint16_t_alignment __attribute__((unused)),
+                                   uint32_t uint32_t_alignment __attribute__((unused)),
+                                   uint32_t uint64_t_alignment __attribute__((unused)),
+                                   uint32_t long_alignment __attribute__((unused)),
+                                   int byte_order __attribute__((unused)),
+                                   uint32_t major __attribute__((unused)),
+                                   uint32_t minor __attribute__((unused)),
+                                   const char *root_shm_path __attribute__((unused)),
+                                   const char *shm_path __attribute__((unused)),
+                                   uid_t euid __attribute__((unused)),
+                                   gid_t egid __attribute__((unused)),
+                                   uint64_t tracing_id __attribute__((unused)),
+                                   uid_t tracing_uid __attribute__((unused)))
 {
        return nullptr;
 }
 
-static inline
-lttng::sessiond::ust::registry_session *ust_registry_session_per_pid_create(
-               struct ust_app *app __attribute__((unused)),
-               uint32_t bits_per_long __attribute__((unused)),
-               uint32_t uint8_t_alignment __attribute__((unused)),
-               uint32_t uint16_t_alignment __attribute__((unused)),
-               uint32_t uint32_t_alignment __attribute__((unused)),
-               uint32_t uint64_t_alignment __attribute__((unused)),
-               uint32_t long_alignment __attribute__((unused)),
-               int byte_order __attribute__((unused)),
-               uint32_t major __attribute__((unused)),
-               uint32_t minor __attribute__((unused)),
-               const char *root_shm_path __attribute__((unused)),
-               const char *shm_path __attribute__((unused)),
-               uid_t euid __attribute__((unused)),
-               gid_t egid __attribute__((unused)),
-               uint64_t tracing_id __attribute__((unused)))
+static inline lttng::sessiond::ust::registry_session *
+ust_registry_session_per_pid_create(struct ust_app *app __attribute__((unused)),
+                                   uint32_t bits_per_long __attribute__((unused)),
+                                   uint32_t uint8_t_alignment __attribute__((unused)),
+                                   uint32_t uint16_t_alignment __attribute__((unused)),
+                                   uint32_t uint32_t_alignment __attribute__((unused)),
+                                   uint32_t uint64_t_alignment __attribute__((unused)),
+                                   uint32_t long_alignment __attribute__((unused)),
+                                   int byte_order __attribute__((unused)),
+                                   uint32_t major __attribute__((unused)),
+                                   uint32_t minor __attribute__((unused)),
+                                   const char *root_shm_path __attribute__((unused)),
+                                   const char *shm_path __attribute__((unused)),
+                                   uid_t euid __attribute__((unused)),
+                                   gid_t egid __attribute__((unused)),
+                                   uint64_t tracing_id __attribute__((unused)))
 {
        return nullptr;
 }
 
-static inline
-void ust_registry_session_destroy(
-               lttng::sessiond::ust::registry_session *session __attribute__((unused)))
-{}
-
-static inline
-void ust_registry_destroy_event(
-               lttng::sessiond::ust::registry_channel *chan __attribute__((unused)),
-               lttng::sessiond::ust::registry_event *event __attribute__((unused)))
-{}
-
-/* The app object can be NULL for registry shared across applications. */
-static inline
-int ust_metadata_session_statedump(
-               lttng::sessiond::ust::registry_session *session __attribute__((unused)))
+static inline void ust_registry_session_destroy(lttng::sessiond::ust::registry_session *session
+                                               __attribute__((unused)))
 {
-       return 0;
 }
 
-static inline
-int ust_metadata_channel_statedump(
-               lttng::sessiond::ust::registry_session *session __attribute__((unused)),
-               lttng::sessiond::ust::registry_channel *chan __attribute__((unused)))
+static inline void ust_registry_destroy_event(lttng::sessiond::ust::registry_channel *chan
+                                             __attribute__((unused)),
+                                             lttng::sessiond::ust::registry_event *event
+                                             __attribute__((unused)))
 {
-       return 0;
 }
 
-static inline
-int ust_metadata_event_statedump(
-               lttng::sessiond::ust::registry_session *session __attribute__((unused)),
-               lttng::sessiond::ust::registry_channel *chan __attribute__((unused)),
-               lttng::sessiond::ust::registry_event *event __attribute__((unused)))
+/* The app object can be NULL for registry shared across applications. */
+static inline int ust_metadata_session_statedump(lttng::sessiond::ust::registry_session *session
+                                                __attribute__((unused)))
 {
        return 0;
 }
 
-static inline
-int ust_registry_create_or_find_enum(
-               lttng::sessiond::ust::registry_session *session __attribute__((unused)),
-               int session_objd __attribute__((unused)),
-               char *name __attribute__((unused)),
-               struct lttng_ust_ctl_enum_entry *entries __attribute__((unused)),
-               size_t nr_entries __attribute__((unused)),
-               uint64_t *enum_id __attribute__((unused)))
+static inline int ust_metadata_channel_statedump(lttng::sessiond::ust::registry_session *session
+                                                __attribute__((unused)),
+                                                lttng::sessiond::ust::registry_channel *chan
+                                                __attribute__((unused)))
 {
        return 0;
 }
 
-static inline
-struct ust_registry_enum *
-       ust_registry_lookup_enum_by_id(
-               const lttng::sessiond::ust::registry_session *session __attribute__((unused)),
-               const char *name __attribute__((unused)),
-               uint64_t id __attribute__((unused)))
+static inline int ust_metadata_event_statedump(lttng::sessiond::ust::registry_session *session
+                                              __attribute__((unused)),
+                                              lttng::sessiond::ust::registry_channel *chan
+                                              __attribute__((unused)),
+                                              lttng::sessiond::ust::registry_event *event
+                                              __attribute__((unused)))
 {
-       return NULL;
+       return 0;
 }
 
-static inline
-void ust_registry_destroy_enum(lttng::sessiond::ust::registry_session *reg_session __attribute__((unused)),
-               struct ust_registry_enum *reg_enum __attribute__((unused)))
-{}
-
 #endif /* HAVE_LIBLTTNG_UST_CTL */
 
 #endif /* LTTNG_UST_REGISTRY_H */
This page took 0.034153 seconds and 4 git commands to generate.