Fix: sessiond: work-around mismatching variant type tag field and selector names
[lttng-tools.git] / src / bin / lttng-sessiond / ust-field-convert.cpp
index 9a07b38c46d3b054482e40f9044ec148ed2f7a9d..21fd3e0c968bc2c5018adf3762339a1fa4399852 100644 (file)
@@ -7,6 +7,7 @@
 
 #include "ust-field-convert.hpp"
 
+#include <common/exception.hpp>
 #include <common/make-unique.hpp>
 
 #include <unordered_map>
@@ -37,19 +38,30 @@ public:
 };
 
 /* Used to publish fields on which a field being decoded has an implicit dependency. */
-using publish_field_fn = std::function<void(lst::field::cuptr)>;
+using publish_field_fn = std::function<void(lst::field::uptr)>;
+
+/* Look-up field from a field location. */
+using lookup_field_fn = std::function<const lst::field &(const lst::field_location &)>;
 
 lst::type::cuptr create_type_from_ust_ctl_fields(const lttng_ust_ctl_field *current,
                const lttng_ust_ctl_field *end,
                const session_attributes& session_attributes,
                const lttng_ust_ctl_field **next_ust_ctl_field,
-               publish_field_fn publish_field);
+               publish_field_fn publish_field,
+               lookup_field_fn lookup_field,
+               lst::field_location::root lookup_root,
+               lst::field_location::elements& current_field_location_elements,
+               lsu::ctl_field_quirks quirks);
 
 void create_field_from_ust_ctl_fields(const lttng_ust_ctl_field *current,
                const lttng_ust_ctl_field *end,
                const session_attributes& session_attributes,
                const lttng_ust_ctl_field **next_ust_ctl_field,
-               publish_field_fn publish_field);
+               publish_field_fn publish_field,
+               lookup_field_fn lookup_field,
+               lst::field_location::root lookup_root,
+               lst::field_location::elements& current_field_location_elements,
+               lsu::ctl_field_quirks quirks);
 
 template <class UstCtlEncodingType>
 enum lst::null_terminated_string_type::encoding ust_ctl_encoding_to_string_field_encoding(UstCtlEncodingType encoding)
@@ -94,7 +106,8 @@ enum lst::integer_type::base ust_ctl_base_to_integer_field_base(UstCtlBaseType b
 lst::type::cuptr create_integer_type_from_ust_ctl_fields(const lttng_ust_ctl_field *current,
                const lttng_ust_ctl_field *end,
                const session_attributes& session_attributes,
-               const lttng_ust_ctl_field **next_ust_ctl_field)
+               const lttng_ust_ctl_field **next_ust_ctl_field,
+               lsu::ctl_field_quirks quirks __attribute__((unused)))
 {
        if (current >= end) {
                LTTNG_THROW_PROTOCOL_ERROR(
@@ -119,7 +132,8 @@ lst::type::cuptr create_integer_type_from_ust_ctl_fields(const lttng_ust_ctl_fie
 lst::type::cuptr create_floating_point_type_from_ust_ctl_fields(const lttng_ust_ctl_field *current,
                const lttng_ust_ctl_field *end,
                const session_attributes& session_attributes,
-               const lttng_ust_ctl_field **next_ust_ctl_field)
+               const lttng_ust_ctl_field **next_ust_ctl_field,
+               lsu::ctl_field_quirks quirks __attribute__((unused)))
 {
        if (current >= end) {
                LTTNG_THROW_PROTOCOL_ERROR(
@@ -146,7 +160,8 @@ lst::type::cuptr create_floating_point_type_from_ust_ctl_fields(const lttng_ust_
 lst::type::cuptr create_enumeration_type_from_ust_ctl_fields(const lttng_ust_ctl_field *current,
                const lttng_ust_ctl_field *end,
                const session_attributes& session_attributes,
-               const lttng_ust_ctl_field **next_ust_ctl_field)
+               const lttng_ust_ctl_field **next_ust_ctl_field,
+               lsu::ctl_field_quirks quirks __attribute__((unused)))
 {
        if (current >= end) {
                LTTNG_THROW_PROTOCOL_ERROR(
@@ -218,7 +233,8 @@ lst::type::cuptr create_enumeration_type_from_ust_ctl_fields(const lttng_ust_ctl
 lst::type::cuptr create_string_type_from_ust_ctl_fields(const lttng_ust_ctl_field *current,
                const lttng_ust_ctl_field *end,
                const session_attributes& session_attributes __attribute__((unused)),
-               const lttng_ust_ctl_field **next_ust_ctl_field)
+               const lttng_ust_ctl_field **next_ust_ctl_field,
+               lsu::ctl_field_quirks quirks __attribute__((unused)))
 {
        if (current >= end) {
                LTTNG_THROW_PROTOCOL_ERROR(
@@ -259,7 +275,8 @@ lst::type::cuptr create_integer_type_from_ust_ctl_basic_type(
 lst::type::cuptr create_array_type_from_ust_ctl_fields(const lttng_ust_ctl_field *current,
                const lttng_ust_ctl_field *end,
                const session_attributes& session_attributes,
-               const lttng_ust_ctl_field **next_ust_ctl_field)
+               const lttng_ust_ctl_field **next_ust_ctl_field,
+               lsu::ctl_field_quirks quirks __attribute__((unused)))
 {
        if (current >= end) {
                LTTNG_THROW_PROTOCOL_ERROR(
@@ -316,7 +333,11 @@ lst::type::cuptr create_array_nestable_type_from_ust_ctl_fields(const lttng_ust_
                const lttng_ust_ctl_field *end,
                const session_attributes& session_attributes,
                const lttng_ust_ctl_field **next_ust_ctl_field,
-               publish_field_fn publish_field)
+               publish_field_fn publish_field,
+               lookup_field_fn lookup_field,
+               lst::field_location::root lookup_root,
+               lst::field_location::elements &current_field_location_elements,
+               lsu::ctl_field_quirks quirks)
 {
        if (current >= end) {
                LTTNG_THROW_PROTOCOL_ERROR(
@@ -337,7 +358,8 @@ lst::type::cuptr create_array_nestable_type_from_ust_ctl_fields(const lttng_ust_
 
        /* next_ust_ctl_field is updated as needed. */
        element_type = create_type_from_ust_ctl_fields(&element_uctl_field, end, session_attributes,
-                       next_ust_ctl_field, publish_field);
+                       next_ust_ctl_field, publish_field, lookup_field, lookup_root,
+                       current_field_location_elements, quirks);
        if (element_uctl_field.type.atype == lttng_ust_ctl_atype_integer &&
                        element_uctl_field.type.u.integer.encoding != lttng_ust_ctl_encode_none) {
                /* Element represents a text character. */
@@ -372,7 +394,10 @@ lst::type::cuptr create_sequence_type_from_ust_ctl_fields(const lttng_ust_ctl_fi
                const lttng_ust_ctl_field *end,
                const session_attributes& session_attributes,
                const lttng_ust_ctl_field **next_ust_ctl_field,
-               publish_field_fn publish_field)
+               publish_field_fn publish_field,
+               lst::field_location::root lookup_root,
+               lst::field_location::elements &current_field_location_elements,
+               lsu::ctl_field_quirks quirks __attribute__((unused)))
 {
        if (current >= end) {
                LTTNG_THROW_PROTOCOL_ERROR(
@@ -411,8 +436,15 @@ lst::type::cuptr create_sequence_type_from_ust_ctl_fields(const lttng_ust_ctl_fi
        auto length_type = create_integer_type_from_ust_ctl_basic_type(
                        length_uctl_type, session_attributes);
 
+       lst::field_location::elements length_field_location_elements =
+                       current_field_location_elements;
+       length_field_location_elements.emplace_back(length_field_name);
+
+       const lst::field_location length_field_location{
+                       lookup_root, std::move(length_field_location_elements)};
+
        /* Publish an implicit length field _before_ the sequence field. */
-       publish_field(lttng::make_unique<lst::field>(length_field_name, std::move(length_type)));
+       publish_field(lttng::make_unique<lst::field>(std::move(length_field_name), std::move(length_type)));
 
        *next_ust_ctl_field = current + 1;
 
@@ -428,11 +460,11 @@ lst::type::cuptr create_sequence_type_from_ust_ctl_fields(const lttng_ust_ctl_fi
 
                /* Sequence is a dynamic-length string. */
                return lttng::make_unique<lst::dynamic_length_string_type>(sequence_alignment,
-                               *element_encoding, std::move(length_field_name));
+                               *element_encoding, std::move(length_field_location));
        }
 
-       return lttng::make_unique<lst::dynamic_length_array_type>(
-                       sequence_alignment, std::move(element_type), std::move(length_field_name));
+       return lttng::make_unique<lst::dynamic_length_array_type>(sequence_alignment,
+                       std::move(element_type), std::move(length_field_location));
 }
 
 lst::type::cuptr create_sequence_nestable_type_from_ust_ctl_fields(
@@ -440,7 +472,11 @@ lst::type::cuptr create_sequence_nestable_type_from_ust_ctl_fields(
                const lttng_ust_ctl_field *end,
                const session_attributes& session_attributes,
                const lttng_ust_ctl_field **next_ust_ctl_field,
-               publish_field_fn publish_field)
+               publish_field_fn publish_field,
+               lookup_field_fn lookup_field,
+               lst::field_location::root lookup_root,
+               lst::field_location::elements &current_field_location_elements,
+               lsu::ctl_field_quirks quirks)
 {
        if (current >= end) {
                LTTNG_THROW_PROTOCOL_ERROR(
@@ -465,7 +501,8 @@ lst::type::cuptr create_sequence_nestable_type_from_ust_ctl_fields(
 
        /* next_ust_ctl_field is updated as needed. */
        auto element_type = create_type_from_ust_ctl_fields(&element_uctl_field, end,
-                       session_attributes, next_ust_ctl_field, publish_field);
+                       session_attributes, next_ust_ctl_field, publish_field, lookup_field,
+                       lookup_root, current_field_location_elements, quirks);
 
        if (lttng_strnlen(sequence_uctl_field.type.u.sequence_nestable.length_name,
                            sizeof(sequence_uctl_field.type.u.sequence_nestable.length_name)) ==
@@ -473,6 +510,21 @@ lst::type::cuptr create_sequence_nestable_type_from_ust_ctl_fields(
                LTTNG_THROW_PROTOCOL_ERROR("Sequence length field name is not null terminated");
        }
 
+       lst::field_location::elements length_field_location_elements =
+                       current_field_location_elements;
+       length_field_location_elements.emplace_back(std::move(length_field_name));
+
+       const lst::field_location length_field_location{
+                       lookup_root, std::move(length_field_location_elements)};
+
+       /* Validate existence of length field (throws if not found). */
+       const auto &length_field = lookup_field(length_field_location);
+       const auto *integer_selector_field =
+                       dynamic_cast<const lst::integer_type *>(&length_field.get_type());
+       if (!integer_selector_field) {
+               LTTNG_THROW_PROTOCOL_ERROR("Invalid selector field type referenced from sequence: expected integer or enumeration");
+       }
+
        if (element_encoding) {
                const auto integer_element_size =
                                static_cast<const lst::integer_type&>(*element_type).size;
@@ -485,17 +537,18 @@ lst::type::cuptr create_sequence_nestable_type_from_ust_ctl_fields(
 
                /* Sqeuence is a dynamic-length string. */
                return lttng::make_unique<lst::dynamic_length_string_type>(sequence_alignment,
-                               *element_encoding, std::move(length_field_name));
+                               *element_encoding, std::move(length_field_location));
        }
 
-       return lttng::make_unique<lst::dynamic_length_array_type>(
-                       sequence_alignment, std::move(element_type), std::move(length_field_name));
+       return lttng::make_unique<lst::dynamic_length_array_type>(sequence_alignment,
+                       std::move(element_type), std::move(length_field_location));
 }
 
 lst::type::cuptr create_structure_field_from_ust_ctl_fields(const lttng_ust_ctl_field *current,
                const lttng_ust_ctl_field *end,
                const session_attributes& session_attributes __attribute__((unused)),
-               const lttng_ust_ctl_field **next_ust_ctl_field)
+               const lttng_ust_ctl_field **next_ust_ctl_field,
+               lsu::ctl_field_quirks quirks __attribute__((unused)))
 {
        if (current >= end) {
                LTTNG_THROW_PROTOCOL_ERROR(
@@ -525,10 +578,78 @@ lst::type::cuptr create_structure_field_from_ust_ctl_fields(const lttng_ust_ctl_
        return lttng::make_unique<lst::structure_type>(alignment, lst::structure_type::fields());
 }
 
+template <class VariantSelectorMappingIntegerType>
+typename lst::variant_type<VariantSelectorMappingIntegerType>::choices create_typed_variant_choices(
+               const lttng_ust_ctl_field *current,
+               const lttng_ust_ctl_field *end,
+               const session_attributes& session_attributes,
+               const lttng_ust_ctl_field **next_ust_ctl_field,
+               lookup_field_fn lookup_field,
+               lst::field_location::root lookup_root,
+               lst::field_location::elements& current_field_location_elements,
+               unsigned int choice_count,
+               const lst::field& selector_field,
+               lsu::ctl_field_quirks quirks)
+{
+       typename lst::variant_type<VariantSelectorMappingIntegerType>::choices choices;
+       const auto& typed_enumeration = static_cast<
+                       const lst::typed_enumeration_type<VariantSelectorMappingIntegerType>&>(
+                       selector_field.get_type());
+
+       for (unsigned int i = 0; i < choice_count; i++) {
+               create_field_from_ust_ctl_fields(
+                               current, end, session_attributes, next_ust_ctl_field,
+                               [&choices, typed_enumeration, &selector_field, quirks](
+                                               lst::field::uptr field) {
+                                       /*
+                                        * Find the enumeration mapping that matches the
+                                        * field's name.
+                                        */
+                                       const auto mapping_it = std::find_if(
+                                                       typed_enumeration.mappings_->begin(),
+                                                       typed_enumeration.mappings_->end(),
+                                                       [&field, quirks](const typename std::remove_reference<
+                                                                       decltype(typed_enumeration)>::type::
+                                                                                       mapping& mapping) {
+                                                               if (static_cast<bool>(quirks & lsu::ctl_field_quirks::UNDERSCORE_PREFIXED_VARIANT_TAG_MAPPINGS)) {
+                                                                       /*
+                                                                        * Check if they match with
+                                                                        * a prepended underscore
+                                                                        * and, if not, perform the
+                                                                        * regular check.
+                                                                        */
+                                                                       if ((std::string("_") + field->name) == mapping.name) {
+                                                                               return true;
+                                                                       }
+                                                               }
+
+                                                               return mapping.name == field->name;
+                                                       });
+
+                                       if (mapping_it == typed_enumeration.mappings_->end()) {
+                                               LTTNG_THROW_PROTOCOL_ERROR(fmt::format(
+                                                               "Invalid variant choice: `{}` does not match any mapping in `{}` enumeration",
+                                                               field->name, selector_field.name));
+                                       }
+
+                                       choices.emplace_back(*mapping_it, field->move_type());
+                               },
+                               lookup_field, lookup_root, current_field_location_elements, quirks);
+
+               current = *next_ust_ctl_field;
+       }
+
+       return choices;
+}
+
 lst::type::cuptr create_variant_field_from_ust_ctl_fields(const lttng_ust_ctl_field *current,
                const lttng_ust_ctl_field *end,
                const session_attributes& session_attributes,
-               const lttng_ust_ctl_field **next_ust_ctl_field)
+               const lttng_ust_ctl_field **next_ust_ctl_field,
+               lookup_field_fn lookup_field,
+               lst::field_location::root lookup_root,
+               lst::field_location::elements &current_field_location_elements,
+               lsu::ctl_field_quirks quirks)
 {
        if (current >= end) {
                LTTNG_THROW_PROTOCOL_ERROR(
@@ -553,60 +674,96 @@ lst::type::cuptr create_variant_field_from_ust_ctl_fields(const lttng_ust_ctl_fi
                tag_name = variant_uctl_field.type.u.variant_nestable.tag_name;
        }
 
-       /* Choices follow. next_ust_ctl_field is updated as needed. */
-       lst::variant_type::choices choices;
-       for (unsigned int i = 0; i < choice_count; i++) {
-               create_field_from_ust_ctl_fields(current, end, session_attributes,
-                               next_ust_ctl_field, [&choices](lst::field::cuptr field) {
-                                       choices.emplace_back(std::move(field));
-                               });
+       lst::field_location::elements selector_field_location_elements =
+                       current_field_location_elements;
+       selector_field_location_elements.emplace_back(tag_name);
 
-               current = *next_ust_ctl_field;
+       const lst::field_location selector_field_location{
+                       lookup_root, std::move(selector_field_location_elements)};
+
+       /* Validate existence of selector field (throws if not found). */
+       const auto &selector_field = lookup_field(selector_field_location);
+       const auto *enumeration_selector_type =
+                       dynamic_cast<const lst::enumeration_type *>(&selector_field.get_type());
+       if (!enumeration_selector_type) {
+               LTTNG_THROW_PROTOCOL_ERROR("Invalid selector field type referenced from variant: expected enumeration");
        }
 
-       return lttng::make_unique<lst::variant_type>(alignment, tag_name, std::move(choices));
+       const bool selector_is_signed = enumeration_selector_type->signedness_ ==
+                       lst::integer_type::signedness::SIGNED;
+
+       /* Choices follow. next_ust_ctl_field is updated as needed. */
+       if (selector_is_signed) {
+               lst::variant_type<lst::signed_enumeration_type::mapping::range_t::range_integer_t>::
+                               choices choices = create_typed_variant_choices<int64_t>(current,
+                                               end, session_attributes, next_ust_ctl_field,
+                                               lookup_field, lookup_root,
+                                               current_field_location_elements, choice_count,
+                                               selector_field, quirks);
+
+               return lttng::make_unique<lst::variant_type<int64_t>>(
+                               alignment, std::move(selector_field_location), std::move(choices));
+       } else {
+               lst::variant_type<lst::unsigned_enumeration_type::mapping::range_t::range_integer_t>::
+                               choices choices = create_typed_variant_choices<uint64_t>(current,
+                                               end, session_attributes, next_ust_ctl_field,
+                                               lookup_field, lookup_root,
+                                               current_field_location_elements, choice_count,
+                                               selector_field, quirks);
+
+               return lttng::make_unique<lst::variant_type<uint64_t>>(
+                               alignment, std::move(selector_field_location), std::move(choices));
+       }
 }
 
 lst::type::cuptr create_type_from_ust_ctl_fields(const lttng_ust_ctl_field *current,
                const lttng_ust_ctl_field *end,
                const session_attributes& session_attributes,
                const lttng_ust_ctl_field **next_ust_ctl_field,
-               publish_field_fn publish_field)
+               publish_field_fn publish_field,
+               lookup_field_fn lookup_field,
+               lst::field_location::root lookup_root,
+               lst::field_location::elements& current_field_location_elements,
+               lsu::ctl_field_quirks quirks)
 {
        switch (current->type.atype) {
        case lttng_ust_ctl_atype_integer:
                return create_integer_type_from_ust_ctl_fields(
-                               current, end, session_attributes, next_ust_ctl_field);
+                               current, end, session_attributes, next_ust_ctl_field, quirks);
        case lttng_ust_ctl_atype_enum:
        case lttng_ust_ctl_atype_enum_nestable:
                return create_enumeration_type_from_ust_ctl_fields(
-                               current, end, session_attributes, next_ust_ctl_field);
+                               current, end, session_attributes, next_ust_ctl_field, quirks);
        case lttng_ust_ctl_atype_float:
                return create_floating_point_type_from_ust_ctl_fields(
-                               current, end, session_attributes, next_ust_ctl_field);
+                               current, end, session_attributes, next_ust_ctl_field, quirks);
        case lttng_ust_ctl_atype_string:
                return create_string_type_from_ust_ctl_fields(
-                               current, end, session_attributes, next_ust_ctl_field);
+                               current, end, session_attributes, next_ust_ctl_field, quirks);
        case lttng_ust_ctl_atype_array:
-               return create_array_type_from_ust_ctl_fields(current, end, session_attributes,
-                               next_ust_ctl_field);
+               return create_array_type_from_ust_ctl_fields(
+                               current, end, session_attributes, next_ust_ctl_field, quirks);
        case lttng_ust_ctl_atype_array_nestable:
                return create_array_nestable_type_from_ust_ctl_fields(current, end,
-                               session_attributes, next_ust_ctl_field, publish_field);
+                               session_attributes, next_ust_ctl_field, publish_field, lookup_field,
+                               lookup_root, current_field_location_elements, quirks);
        case lttng_ust_ctl_atype_sequence:
                return create_sequence_type_from_ust_ctl_fields(current, end, session_attributes,
-                               next_ust_ctl_field, publish_field);
+                               next_ust_ctl_field, publish_field, lookup_root,
+                               current_field_location_elements, quirks);
        case lttng_ust_ctl_atype_sequence_nestable:
                return create_sequence_nestable_type_from_ust_ctl_fields(current, end,
-                               session_attributes, next_ust_ctl_field, publish_field);
+                               session_attributes, next_ust_ctl_field, publish_field, lookup_field,
+                               lookup_root, current_field_location_elements, quirks);
        case lttng_ust_ctl_atype_struct:
        case lttng_ust_ctl_atype_struct_nestable:
                return create_structure_field_from_ust_ctl_fields(
-                               current, end, session_attributes, next_ust_ctl_field);
+                               current, end, session_attributes, next_ust_ctl_field, quirks);
        case lttng_ust_ctl_atype_variant:
        case lttng_ust_ctl_atype_variant_nestable:
-               return create_variant_field_from_ust_ctl_fields(
-                               current, end, session_attributes, next_ust_ctl_field);
+               return create_variant_field_from_ust_ctl_fields(current, end, session_attributes,
+                               next_ust_ctl_field, lookup_field, lookup_root,
+                               current_field_location_elements, quirks);
        default:
                LTTNG_THROW_PROTOCOL_ERROR(fmt::format(
                                "Unknown {} value `{}` encountered while converting {} to {}",
@@ -619,7 +776,11 @@ void create_field_from_ust_ctl_fields(const lttng_ust_ctl_field *current,
                const lttng_ust_ctl_field *end,
                const session_attributes& session_attributes,
                const lttng_ust_ctl_field **next_ust_ctl_field,
-               publish_field_fn publish_field)
+               publish_field_fn publish_field,
+               lookup_field_fn lookup_field,
+               lst::field_location::root lookup_root,
+               lst::field_location::elements& current_field_location_elements,
+               lsu::ctl_field_quirks quirks)
 {
        LTTNG_ASSERT(current < end);
 
@@ -630,7 +791,37 @@ void create_field_from_ust_ctl_fields(const lttng_ust_ctl_field *current,
 
        publish_field(lttng::make_unique<lst::field>(current->name,
                        create_type_from_ust_ctl_fields(current, end, session_attributes,
-                                       next_ust_ctl_field, publish_field)));
+                                       next_ust_ctl_field, publish_field, lookup_field,
+                                       lookup_root, current_field_location_elements, quirks)));
+}
+
+std::vector<lst::field::cuptr>::iterator lookup_field_in_vector(
+               std::vector<lst::field::cuptr>& fields, const lst::field_location& location)
+{
+       if (location.elements_.size() != 1) {
+               LTTNG_THROW_ERROR(fmt::format(
+                               "Unexpected field location received during field look-up: location = {}",
+                               location));
+       }
+
+       /*
+        * In the context of fields received from LTTng-UST, field
+        * look-up is extremely naive as the protocol can only
+        * express empty structures. It is safe to assume that
+        * location has a depth of 1 and directly refers to a field
+        * in the 'fields' vector.
+        */
+       const auto field_it = std::find_if(fields.begin(), fields.end(),
+                       [location](lst::field::cuptr &field) {
+                               return field->name == location.elements_[0];
+                       });
+
+       if (field_it == fields.end()) {
+               LTTNG_THROW_PROTOCOL_ERROR(
+                               fmt::format("Failed to look-up field: location = {}", location));
+       }
+
+       return field_it;
 }
 
 /*
@@ -644,7 +835,9 @@ void create_field_from_ust_ctl_fields(const lttng_ust_ctl_field *current,
 std::vector<lst::field::cuptr> create_fields_from_ust_ctl_fields(
                const lsu::registry_session& session,
                const lttng_ust_ctl_field *current,
-               const lttng_ust_ctl_field *end)
+               const lttng_ust_ctl_field *end,
+               lst::field_location::root lookup_root,
+               lsu::ctl_field_quirks quirks)
 {
        std::vector<lst::field::cuptr> fields;
        const auto trace_native_byte_order = session.abi.byte_order;
@@ -653,6 +846,8 @@ std::vector<lst::field::cuptr> create_fields_from_ust_ctl_fields(
                                return session.get_enumeration(enum_name, enum_id);
                        },
                        trace_native_byte_order};
+       /* Location of field being created. */
+       lst::field_location::elements current_field_location_elements;
 
        while (current < end) {
                auto *next_field = current;
@@ -666,10 +861,19 @@ std::vector<lst::field::cuptr> create_fields_from_ust_ctl_fields(
                 * The lambda allows the factory functions to push as many fields as
                 * needed depending on the decoded field's type.
                 */
-               create_field_from_ust_ctl_fields(current, end, session_attributes, &next_field,
+               create_field_from_ust_ctl_fields(
+                               current, end, session_attributes, &next_field,
                                [&fields](lst::field::cuptr field) {
+                                       /* Publishing a field simply adds it to the converted
+                                        * fields. */
                                        fields.emplace_back(std::move(field));
-                               });
+                               },
+                               [&fields](const lst::field_location& location)
+                                               -> lookup_field_fn::result_type {
+                                       /* Resolve location to a previously-constructed field. */
+                                       return **lookup_field_in_vector(fields, location);
+                               },
+                               lookup_root, current_field_location_elements, quirks);
 
                current = next_field;
        }
@@ -681,7 +885,10 @@ std::vector<lst::field::cuptr> create_fields_from_ust_ctl_fields(
 std::vector<lst::field::cuptr> lsu::create_trace_fields_from_ust_ctl_fields(
                const lsu::registry_session& session,
                const lttng_ust_ctl_field *fields,
-               std::size_t field_count)
+               std::size_t field_count,
+               lst::field_location::root lookup_root,
+               lsu::ctl_field_quirks quirks)
 {
-       return create_fields_from_ust_ctl_fields(session, fields, fields + field_count);
+       return create_fields_from_ust_ctl_fields(
+                       session, fields, fields + field_count, lookup_root, quirks);
 }
This page took 0.029971 seconds and 4 git commands to generate.