sessiond: add a CTF 2-generating trace class visitor
[lttng-tools.git] / src / bin / lttng-sessiond / ust-registry-session.cpp
index 48983f2b21d8d4f3347ae63d784c766c9597160f..e1089bd58678eaf07e07a416b0ffbe4373cd5513 100644 (file)
@@ -11,6 +11,7 @@
 #include "session.hpp"
 #include "trace-class.hpp"
 #include "tsdl-trace-class-visitor.hpp"
+#include "ctf2-trace-class-visitor.hpp"
 #include "ust-app.hpp"
 #include "ust-field-convert.hpp"
 #include "ust-registry.hpp"
@@ -222,7 +223,6 @@ unsigned long ht_hash_enum(void *_key, unsigned long seed)
        LTTNG_ASSERT(key);
        return hash_key_str(key->name.c_str(), seed);
 }
-
 } /* namespace */
 
 void lsu::details::locked_registry_session_release(lsu::registry_session *session)
@@ -251,7 +251,8 @@ lsu::registry_session::registry_session(const struct lst::abi& in_abi,
        _metadata_generating_visitor{lttng::make_unique<ls::tsdl::trace_class_visitor>(
                        abi, [this](const std::string& fragment) {
                                _append_metadata_fragment(fragment);
-                       })}
+                       })},
+       _packet_header{_create_packet_header()}
 {
        pthread_mutex_init(&_lock, NULL);
        if (_shm_path.size() > 0) {
@@ -287,6 +288,44 @@ lsu::registry_session::registry_session(const struct lst::abi& in_abi,
        }
 }
 
+lst::type::cuptr lsu::registry_session::_create_packet_header() const
+{
+       lst::structure_type::fields packet_header_fields;
+
+       /* uint32_t magic */
+       packet_header_fields.emplace_back(lttng::make_unique<lst::field>("magic",
+                       lttng::make_unique<lst::integer_type>(abi.uint32_t_alignment,
+                                       abi.byte_order, 32, lst::integer_type::signedness::UNSIGNED,
+                                       lst::integer_type::base::HEXADECIMAL,
+                                       std::initializer_list<lst::integer_type::role>({lst::integer_type::role::PACKET_MAGIC_NUMBER}))));
+
+       /* uuid */
+       packet_header_fields.emplace_back(lttng::make_unique<lst::field>("uuid",
+                       lttng::make_unique<lst::static_length_blob_type>(0, 16,
+                                       std::initializer_list<lst::static_length_blob_type::role>({lst::static_length_blob_type::role::METADATA_STREAM_UUID}))));
+
+       /* uint32_t stream_id */
+       packet_header_fields.emplace_back(lttng::make_unique<lst::field>("stream_id",
+                       lttng::make_unique<lst::integer_type>(abi.uint32_t_alignment,
+                                       abi.byte_order, 32, lst::integer_type::signedness::UNSIGNED,
+                                       lst::integer_type::base::DECIMAL,
+                                       std::initializer_list<lst::integer_type::role>({lst::integer_type::role::DATA_STREAM_CLASS_ID}))));
+
+       /* uint64_t stream_instance_id */
+       packet_header_fields.emplace_back(lttng::make_unique<lst::field>("stream_instance_id",
+                       lttng::make_unique<lst::integer_type>(abi.uint64_t_alignment,
+                                       abi.byte_order, 64, lst::integer_type::signedness::UNSIGNED,
+                                       lst::integer_type::base::DECIMAL,
+                                       std::initializer_list<lst::integer_type::role>({lst::integer_type::role::DATA_STREAM_ID}))));
+
+       return lttng::make_unique<lst::structure_type>(0, std::move(packet_header_fields));
+}
+
+const lst::type *lsu::registry_session::get_packet_header() const noexcept
+{
+       return _packet_header.get();
+}
+
 /*
  * For a given enumeration in a registry, delete the entry and destroy
  * the enumeration.
@@ -456,8 +495,8 @@ void lsu::registry_session::remove_channel(uint64_t channel_key, bool notify)
        destroy_channel(&channel, notify);
 }
 
-void lsu::registry_session::_visit_environment(
-               lttng::sessiond::trace::trace_class_visitor& visitor) const
+void lsu::registry_session::accept(
+               lttng::sessiond::trace::trace_class_environment_visitor& visitor) const
 {
        ASSERT_LOCKED(_lock);
 
@@ -608,7 +647,7 @@ void lsu::registry_session::_reset_metadata()
 
 void lsu::registry_session::_generate_metadata()
 {
-       accept(*_metadata_generating_visitor);
+       trace_class::accept(*_metadata_generating_visitor);
 }
 
 void lsu::registry_session::regenerate_metadata()
@@ -665,39 +704,6 @@ lsu::registry_session::get_enumeration(const char *enum_name, uint64_t enum_id)
        return lsu::registry_enum::const_rcu_protected_reference{*reg_enum, std::move(rcu_lock)};
 }
 
-lst::type::cuptr lsu::registry_session::get_packet_header() const
-{
-       lst::structure_type::fields packet_header_fields;
-
-       /* uint32_t magic */
-       packet_header_fields.emplace_back(lttng::make_unique<lst::field>("magic",
-                       lttng::make_unique<lst::integer_type>(abi.uint32_t_alignment,
-                                       abi.byte_order, 32, lst::integer_type::signedness::UNSIGNED,
-                                       lst::integer_type::base::HEXADECIMAL,
-                                       std::initializer_list<lst::integer_type::role>({lst::integer_type::role::PACKET_MAGIC_NUMBER}))));
-
-       /* uuid */
-       packet_header_fields.emplace_back(lttng::make_unique<lst::field>("uuid",
-                       lttng::make_unique<lst::static_length_blob_type>(0, 16,
-                                       std::initializer_list<lst::static_length_blob_type::role>({lst::static_length_blob_type::role::TRACE_CLASS_UUID}))));
-
-       /* uint32_t stream_id */
-       packet_header_fields.emplace_back(lttng::make_unique<lst::field>("stream_id",
-                       lttng::make_unique<lst::integer_type>(abi.uint32_t_alignment,
-                                       abi.byte_order, 32, lst::integer_type::signedness::UNSIGNED,
-                                       lst::integer_type::base::DECIMAL,
-                                       std::initializer_list<lst::integer_type::role>({lst::integer_type::role::DATA_STREAM_CLASS_ID}))));
-
-       /* uint64_t stream_instance_id */
-       packet_header_fields.emplace_back(lttng::make_unique<lst::field>("stream_instance_id",
-                       lttng::make_unique<lst::integer_type>(abi.uint64_t_alignment,
-                                       abi.byte_order, 64, lst::integer_type::signedness::UNSIGNED,
-                                       lst::integer_type::base::DECIMAL,
-                                       std::initializer_list<lst::integer_type::role>({lst::integer_type::role::DATA_STREAM_ID}))));
-
-       return lttng::make_unique<lst::structure_type>(0, std::move(packet_header_fields));
-}
-
 /*
  * Lookup enumeration by name and comparing enumeration entries.
  * Needs to be called from RCU read-side critical section.
This page took 0.025848 seconds and 4 git commands to generate.