X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;f=src%2Fbin%2Flttng-sessiond%2Fust-registry-session.cpp;h=a8199bb6253ced527bf857cdeee12ab28262ac96;hb=4bcf2294f0701b731d620c38216e1922e919e1b9;hp=6e21cee00c6d314419761d6a494d7b41c2084bec;hpb=0114db0ec2407029052eb61a0189c9b1cd64d520;p=lttng-tools.git diff --git a/src/bin/lttng-sessiond/ust-registry-session.cpp b/src/bin/lttng-sessiond/ust-registry-session.cpp index 6e21cee00..a8199bb62 100644 --- a/src/bin/lttng-sessiond/ust-registry-session.cpp +++ b/src/bin/lttng-sessiond/ust-registry-session.cpp @@ -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" @@ -29,6 +30,7 @@ #include #include +#include #include #include #include @@ -125,7 +127,7 @@ void destroy_channel(lsu::registry_channel *chan, bool notify) noexcept DIAGNOSTIC_PUSH DIAGNOSTIC_IGNORE_INVALID_OFFSETOF cds_lfht_for_each_entry( - chan->_events->ht, &iter.iter, event, _node.node) { + chan->_events->ht, &iter.iter, event, _node) { /* Delete the node from the ht and free it. */ ust_registry_channel_destroy_event(chan, event); } @@ -221,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) @@ -240,16 +241,18 @@ lsu::registry_session::registry_session(const struct lst::abi& in_abi, lst::trace_class(in_abi, generate_uuid_or_throw()), _root_shm_path{root_shm_path ? root_shm_path : ""}, _shm_path{shm_path ? shm_path : ""}, - _metadata_path{_shm_path.size() > 0 ? - fmt::format("{}/metadata", _shm_path) : std::string("")}, + _metadata_path{_shm_path.size() > 0 ? fmt::format("{}/metadata", _shm_path) : + std::string("")}, _uid{euid}, _gid{egid}, _app_tracer_version{.major = major, .minor = minor}, _tracing_id{tracing_id}, - _metadata_generating_visitor{lttng::make_unique(abi, - [this](const std::string& fragment) { + _clock{lttng::make_unique()}, + _metadata_generating_visitor{lttng::make_unique( + 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) { @@ -285,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("magic", + lttng::make_unique(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::PACKET_MAGIC_NUMBER})))); + + /* uuid */ + packet_header_fields.emplace_back(lttng::make_unique("uuid", + lttng::make_unique(0, 16, + std::initializer_list({lst::static_length_blob_type::role::METADATA_STREAM_UUID})))); + + /* uint32_t stream_id */ + packet_header_fields.emplace_back(lttng::make_unique("stream_id", + lttng::make_unique(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::DATA_STREAM_CLASS_ID})))); + + /* uint64_t stream_instance_id */ + packet_header_fields.emplace_back(lttng::make_unique("stream_instance_id", + lttng::make_unique(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::DATA_STREAM_ID})))); + + return lttng::make_unique(0, std::move(packet_header_fields)); +} + +const lst::type *lsu::registry_session::packet_header() const noexcept +{ + return _packet_header.get(); +} + /* * For a given enumeration in a registry, delete the entry and destroy * the enumeration. @@ -389,7 +430,7 @@ void lsu::registry_session::add_channel(uint64_t key) } auto chan = new lsu::registry_channel( - _get_next_channel_id(), + _get_next_channel_id(), abi, _clock->name, /* Registered channel listener. */ [this](const lsu::registry_channel& registered_channel) { /* @@ -416,7 +457,7 @@ void lsu::registry_session::add_channel(uint64_t key) lttng_ht_add_unique_u64(_channels.get(), &chan->_node); } -lttng::sessiond::ust::registry_channel& lsu::registry_session::get_channel( +lttng::sessiond::ust::registry_channel& lsu::registry_session::channel( uint64_t channel_key) const { lttng::urcu::read_lock_guard read_lock_guard; @@ -446,16 +487,16 @@ void lsu::registry_session::remove_channel(uint64_t channel_key, bool notify) lttng::urcu::read_lock_guard read_lock_guard; ASSERT_LOCKED(_lock); - auto& channel = get_channel(channel_key); + auto& channel_to_remove = channel(channel_key); - iter.iter.node = &channel._node.node; + iter.iter.node = &channel_to_remove._node.node; ret = lttng_ht_del(_channels.get(), &iter); LTTNG_ASSERT(!ret); - destroy_channel(&channel, notify); + destroy_channel(&channel_to_remove, 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); @@ -464,7 +505,7 @@ void lsu::registry_session::_visit_environment( visitor.visit(lst::environment_field("tracer_major", _app_tracer_version.major)); visitor.visit(lst::environment_field("tracer_minor", _app_tracer_version.minor)); visitor.visit(lst::environment_field("tracer_buffering_scheme", - get_buffering_scheme() == LTTNG_BUFFER_PER_PID ? "pid" : "uid")); + buffering_scheme() == LTTNG_BUFFER_PER_PID ? "pid" : "uid")); visitor.visit(lst::environment_field("architecture_bit_width", abi.bits_per_long)); { @@ -487,7 +528,7 @@ void lsu::registry_session::_visit_environment( void lsu::registry_session::_accept_on_clock_classes(lst::trace_class_visitor& visitor) const { ASSERT_LOCKED(_lock); - _clock.accept(visitor); + _clock->accept(visitor); } void lsu::registry_session::_accept_on_stream_classes(lst::trace_class_visitor& visitor) const @@ -606,13 +647,16 @@ 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() { lttng::pthread::lock_guard registry_lock(_lock); + /* Resample the clock */ + _clock = lttng::make_unique(); + _metadata_version++; _reset_metadata(); _generate_metadata(); @@ -627,7 +671,7 @@ void lsu::registry_session::regenerate_metadata() * disposes of the object. */ lsu::registry_enum::const_rcu_protected_reference -lsu::registry_session::get_enumeration(const char *enum_name, uint64_t enum_id) const +lsu::registry_session::enumeration(const char *enum_name, uint64_t enum_id) const { lsu::registry_enum *reg_enum = NULL; struct lttng_ht_node_str *node; @@ -762,4 +806,4 @@ void lsu::registry_session::create_or_find_enum( DBG("UST registry reply with enum %s with id %" PRIu64 " in sess_objd: %u", enum_name, reg_enum->id, session_objd); *enum_id = reg_enum->id; -} \ No newline at end of file +}