+ 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;