X-Git-Url: https://git.liburcu.org/?a=blobdiff_plain;f=src%2Fbin%2Flttng-sessiond%2Fctf2-trace-class-visitor.cpp;h=6b6c6265b5c8e661b84fe8cc0e4ad961e113c42e;hb=cd9adb8b829564212158943a0d279bb35322ab30;hp=b7ab303a17294198d89662bca7eb4f7b4affe454;hpb=4bcf2294f0701b731d620c38216e1922e919e1b9;p=lttng-tools.git diff --git a/src/bin/lttng-sessiond/ctf2-trace-class-visitor.cpp b/src/bin/lttng-sessiond/ctf2-trace-class-visitor.cpp index b7ab303a1..6b6c6265b 100644 --- a/src/bin/lttng-sessiond/ctf2-trace-class-visitor.cpp +++ b/src/bin/lttng-sessiond/ctf2-trace-class-visitor.cpp @@ -6,8 +6,8 @@ * */ -#include "ctf2-trace-class-visitor.hpp" #include "clock-class.hpp" +#include "ctf2-trace-class-visitor.hpp" #include #include @@ -15,6 +15,7 @@ #include #include +#include namespace lsc = lttng::sessiond::ctf2; namespace lst = lttng::sessiond::trace; @@ -27,10 +28,10 @@ const std::string record_separator = "\x1e"; json::json make_json_fragment(const char *type) { - return {{"type", type}}; + return { { "type", type } }; } -json::json to_json(const lst::field_location &location) +json::json to_json(const lst::field_location& location) { json::json location_array; @@ -55,8 +56,9 @@ json::json to_json(const lst::field_location &location) break; } - std::copy(location.elements_.begin(), location.elements_.end(), - std::back_inserter(location_array)); + std::copy(location.elements_.begin(), + location.elements_.end(), + std::back_inserter(location_array)); return location_array; } @@ -101,16 +103,14 @@ const char *get_role_name(lst::static_length_blob_type::role role) namespace ctf2 { class trace_environment_visitor : public lst::trace_class_environment_visitor { public: - trace_environment_visitor() - { - } + trace_environment_visitor() = default; - virtual void visit(const lst::environment_field& field) override + void visit(const lst::environment_field& field) override { _visit(field); } - virtual void visit(const lst::environment_field& field) override + void visit(const lst::environment_field& field) override { _visit(field); } @@ -134,9 +134,7 @@ private: class field_visitor : public lttng::sessiond::trace::field_visitor, public lttng::sessiond::trace::type_visitor { public: - field_visitor() - { - } + field_visitor() = default; /* Only call once. */ json::json move_fragment() @@ -145,7 +143,7 @@ public: } private: - virtual void visit(const lst::field& field) override final + void visit(const lst::field& field) final { field_visitor field_type_visitor; field.get_type().accept(field_type_visitor); @@ -154,15 +152,15 @@ private: _fragment["field-class"] = field_type_visitor.move_fragment(); } - virtual void visit(const lst::integer_type& type) override final + void visit(const lst::integer_type& type) final { _fragment["type"] = type.signedness_ == lst::integer_type::signedness::SIGNED ? - "fixed-length-signed-integer" : - "fixed-length-unsigned-integer"; + "fixed-length-signed-integer" : + "fixed-length-unsigned-integer"; _fragment["length"] = type.size; _fragment["byte-order"] = type.byte_order == lst::byte_order::BIG_ENDIAN_ ? - "big-endian" : - "little-endian"; + "big-endian" : + "little-endian"; _fragment["alignment"] = type.alignment; _fragment["preferred-display-base"] = (unsigned int) type.base_; @@ -177,35 +175,37 @@ private: } } - virtual void visit(const lst::floating_point_type& type) override final + void visit(const lst::floating_point_type& type) final { _fragment["type"] = "fixed-length-floating-point-number"; _fragment["length"] = type.exponent_digits + type.mantissa_digits; _fragment["byte-order"] = type.byte_order == lst::byte_order::BIG_ENDIAN_ ? - "big-endian" : - "little-endian"; + "big-endian" : + "little-endian"; _fragment["alignment"] = type.alignment; } template void visit_enumeration(const EnumerationType& type) { - _fragment["type"] = std::is_signed::value ? - "fixed-length-signed-enumeration" : - "fixed-length-unsigned-enumeration"; + _fragment["type"] = + std::is_signed< + typename EnumerationType::mapping::range_t::range_integer_t>::value ? + "fixed-length-signed-enumeration" : + "fixed-length-unsigned-enumeration"; _fragment["length"] = type.size; _fragment["byte-order"] = type.byte_order == lst::byte_order::BIG_ENDIAN_ ? - "big-endian" : - "little-endian"; + "big-endian" : + "little-endian"; _fragment["alignment"] = type.alignment; _fragment["preferred-display-base"] = (unsigned int) type.base_; if (type.roles_.size() > 0) { if (std::is_signed::value) { - LTTNG_THROW_ERROR(fmt::format( - "Failed to serialize {}: unexpected role", - _fragment["type"])); + range_integer_t>::value) { + LTTNG_THROW_ERROR( + fmt::format("Failed to serialize {}: unexpected role", + _fragment["type"])); } auto role_array = json::json::array(); @@ -219,29 +219,30 @@ private: if (type.mappings_->size() < 1) { LTTNG_THROW_ERROR(fmt::format( - "Failed to serialize {}: enumeration must have at least one mapping", - _fragment["type"])); + "Failed to serialize {}: enumeration must have at least one mapping", + _fragment["type"])); } json::json mappings_value; - for (const auto &mapping : *type.mappings_) { - mappings_value[mapping.name] = {{mapping.range.begin, mapping.range.end}}; + for (const auto& mapping : *type.mappings_) { + mappings_value[mapping.name] = { { mapping.range.begin, + mapping.range.end } }; } _fragment["mappings"] = std::move(mappings_value); } - virtual void visit(const lst::signed_enumeration_type& type) override final + void visit(const lst::signed_enumeration_type& type) final { visit_enumeration(type); } - virtual void visit(const lst::unsigned_enumeration_type& type) override final + void visit(const lst::unsigned_enumeration_type& type) final { visit_enumeration(type); } - virtual void visit(const lst::static_length_array_type& type) override final + void visit(const lst::static_length_array_type& type) final { _fragment["type"] = "static-length-array"; @@ -256,7 +257,7 @@ private: _fragment["length"] = type.length; } - virtual void visit(const lst::dynamic_length_array_type& type) override final + void visit(const lst::dynamic_length_array_type& type) final { _fragment["type"] = "dynamic-length-array"; @@ -271,7 +272,7 @@ private: _fragment["length-field-location"] = to_json(type.length_field_location); } - virtual void visit(const lst::static_length_blob_type& type) override final + void visit(const lst::static_length_blob_type& type) final { _fragment["type"] = "static-length-blob"; _fragment["length"] = type.length_bytes; @@ -287,19 +288,18 @@ private: } } - virtual void visit(const lst::dynamic_length_blob_type& type) override final + void visit(const lst::dynamic_length_blob_type& type) final { _fragment["type"] = "dynamic-length-blob"; _fragment["length-field-location"] = to_json(type.length_field_location); } - virtual void visit(const lst::null_terminated_string_type& type - __attribute__((unused))) override final + void visit(const lst::null_terminated_string_type& type __attribute__((unused))) final { _fragment["type"] = "null-terminated-string"; } - virtual void visit(const lst::structure_type& type) override final + void visit(const lst::structure_type& type) final { _fragment["type"] = "structure"; @@ -308,7 +308,7 @@ private: } auto member_classes_value = json::json::array(); - for (const auto &field : type.fields_) { + for (const auto& field : type.fields_) { ::ctf2::field_visitor member_visitor; json::json member_class; @@ -331,7 +331,8 @@ private: json::json member_class; /* TODO missing selector-field-range. */ - member_class["selector-field-ranges"] = {{option.first.range.begin, option.first.range.end}}; + member_class["selector-field-ranges"] = { { option.first.range.begin, + option.first.range.end } }; option.second->accept(option_visitor); member_class["field-class"] = option_visitor.move_fragment(); options_value.emplace_back(std::move(member_class)); @@ -340,23 +341,23 @@ private: _fragment["options"] = std::move(options_value); } - virtual void visit(const lst::variant_type& type) override final + void visit(const lst::variant_type& type) final { visit_variant(type); } - virtual void visit(const lst::variant_type& type) override final + void visit(const lst::variant_type& type) final { visit_variant(type); } - virtual void visit(const lst::static_length_string_type& type) override final + void visit(const lst::static_length_string_type& type) final { _fragment["type"] = "static-length-string"; _fragment["length"] = type.length; } - virtual void visit(const lst::dynamic_length_string_type& type) override final + void visit(const lst::dynamic_length_string_type& type) final { _fragment["type"] = "dynamic-length-string"; _fragment["length-field-location"] = to_json(type.length_field_location); @@ -368,9 +369,9 @@ private: }; /* namespace */ -lsc::trace_class_visitor::trace_class_visitor(const lst::abi& trace_abi, - lsc::append_metadata_fragment_function append_metadata_fragment) : - _trace_abi{trace_abi}, _append_metadata_fragment(append_metadata_fragment) +lsc::trace_class_visitor::trace_class_visitor( + lsc::append_metadata_fragment_function append_metadata_fragment) : + _append_metadata_fragment(std::move(append_metadata_fragment)) { } @@ -403,17 +404,16 @@ void lsc::trace_class_visitor::visit(const lst::trace_class& trace_class) void lsc::trace_class_visitor::visit(const lst::clock_class& clock_class) { - auto clock_class_fragment = make_json_fragment("clock-class"); + auto clock_class_fragment = make_json_fragment("clock-class"); json::json offset; - offset.update({{"seconds", clock_class.offset / clock_class.frequency}, - {"cycles", clock_class.offset % clock_class.frequency}}); + offset.update({ { "seconds", clock_class.offset / clock_class.frequency }, + { "cycles", clock_class.offset % clock_class.frequency } }); - clock_class_fragment.update({ - {"name", clock_class.name}, - {"description", clock_class.description}, - {"frequency", clock_class.frequency}, - {"offset", std::move(offset)}}); + clock_class_fragment.update({ { "name", clock_class.name }, + { "description", clock_class.description }, + { "frequency", clock_class.frequency }, + { "offset", std::move(offset) } }); if (clock_class.uuid) { clock_class_fragment["uuid"] = *clock_class.uuid; @@ -429,7 +429,7 @@ void lsc::trace_class_visitor::visit(const lst::stream_class& stream_class) stream_class_fragment["id"] = stream_class.id; if (stream_class.default_clock_class_name) { stream_class_fragment["default-clock-class-name"] = - *stream_class.default_clock_class_name; + *stream_class.default_clock_class_name; } const auto packet_context = stream_class.packet_context(); @@ -445,8 +445,7 @@ void lsc::trace_class_visitor::visit(const lst::stream_class& stream_class) ::ctf2::field_visitor visitor; event_header->accept(visitor); - stream_class_fragment["event-record-header-field-class"] = - visitor.move_fragment(); + stream_class_fragment["event-record-header-field-class"] = visitor.move_fragment(); } const auto event_context = stream_class.event_context(); @@ -455,7 +454,7 @@ void lsc::trace_class_visitor::visit(const lst::stream_class& stream_class) event_context->accept(visitor); stream_class_fragment["event-record-common-context-field-class"] = - visitor.move_fragment(); + visitor.move_fragment(); } append_metadata_fragment(stream_class_fragment);