sessiond: add variant selector intervals
[lttng-tools.git] / src / bin / lttng-sessiond / tsdl-trace-class-visitor.cpp
index 3432682815605afe49e5759de2c23ffbe09bcc92..835c5790520e4158906245a27c2750a766d8b016 100644 (file)
@@ -146,7 +146,7 @@ private:
                _current_field_name.push(_bypass_identifier_escape ?
                                field.name : escape_tsdl_identifier(field.name));
 
-               field._type->accept(*this);
+               field.get_type().accept(*this);
                _description += " ";
                _description += _current_field_name.top();
                _current_field_name.pop();
@@ -349,8 +349,8 @@ private:
                type.element_type->accept(*this);
                _type_suffixes.emplace(fmt::format("[{}]",
                                _bypass_identifier_escape ?
-                                               type.length_field_name :
-                                                     escape_tsdl_identifier(type.length_field_name)));
+                                               *(type.length_field_location.elements_.end() - 1) :
+                                                       escape_tsdl_identifier(*(type.length_field_location.elements_.end() - 1))));
        }
 
        virtual void visit(const lst::static_length_blob_type& type) override final
@@ -372,7 +372,7 @@ private:
                                _trace_abi.byte_order, 8, lst::integer_type::signedness::UNSIGNED,
                                lst::integer_type::base::HEXADECIMAL);
                const auto array = lttng::make_unique<lst::dynamic_length_array_type>(
-                               type.alignment, std::move(uint8_element), type.length_field_name);
+                               type.alignment, std::move(uint8_element), type.length_field_location);
 
                visit(*array);
        }
@@ -411,7 +411,8 @@ private:
                _description += "}";
        }
 
-       virtual void visit(const lst::variant_type& type) override final
+       template <class MappingIntegerType>
+       void visit_variant(const lst::variant_type<MappingIntegerType>& type)
        {
                if (type.alignment != 0) {
                        LTTNG_ASSERT(_current_field_name.size() > 0);
@@ -425,8 +426,8 @@ private:
                _indentation_level++;
                _description += fmt::format("variant <{}> {{\n",
                                _bypass_identifier_escape ?
-                                               type.tag_name :
-                                                     escape_tsdl_identifier(type.tag_name));
+                                               *(type.selector_field_location.elements_.end() - 1) :
+                                                       escape_tsdl_identifier(*(type.selector_field_location.elements_.end() - 1)));
 
                /*
                 * The CTF 1.8 specification only recommends that implementations ignore
@@ -438,7 +439,7 @@ private:
                _bypass_identifier_escape = true;
                for (const auto& field : type._choices) {
                        _description.resize(_description.size() + _indentation_level, '\t');
-                       field->accept(*this);
+                       field.second->accept(*this);
                        _description += "\n";
                }
 
@@ -449,6 +450,16 @@ private:
                _description += "}";
        }
 
+       virtual void visit(const lst::variant_type<lst::signed_enumeration_type::mapping::range_t::range_integer_t>& type) override final
+       {
+               visit_variant(type);
+       }
+
+       virtual void visit(const lst::variant_type<lst::unsigned_enumeration_type::mapping::range_t::range_integer_t>& type) override final
+       {
+               visit_variant(type);
+       }
+
        lst::type::cuptr create_character_type(enum lst::string_type::encoding encoding)
        {
                _current_integer_encoding_override = encoding;
@@ -477,7 +488,7 @@ private:
                 */
                const auto char_sequence = lttng::make_unique<lst::dynamic_length_array_type>(
                                type.alignment, create_character_type(type.encoding_),
-                               type.length_field_name);
+                               type.length_field_location);
 
                visit(*char_sequence);
        }
@@ -547,7 +558,7 @@ void tsdl::trace_class_visitor::visit(const lttng::sessiond::trace::trace_class&
                        fmt::arg("packet_header_layout", packet_header_visitor.get_description()));
 
        /* Declare trace scope and type aliases. */
-       append_metadata_fragment(std::move(trace_class_tsdl));
+       append_metadata_fragment(trace_class_tsdl);
 }
 
 void tsdl::trace_class_visitor::visit(const lttng::sessiond::trace::clock_class& clock_class)
@@ -574,7 +585,7 @@ void tsdl::trace_class_visitor::visit(const lttng::sessiond::trace::clock_class&
                        fmt::arg("frequency", clock_class.frequency),
                        fmt::arg("offset", clock_class.offset));
 
-       append_metadata_fragment(std::move(clock_class_str));
+       append_metadata_fragment(clock_class_str);
 }
 
 void tsdl::trace_class_visitor::visit(const lttng::sessiond::trace::stream_class& stream_class)
This page took 0.030174 seconds and 5 git commands to generate.