- lst::type::cuptr context_fields = lttng::make_unique<lst::structure_type>(0,
- lsu::create_trace_fields_from_ust_ctl_fields(*locked_registry_session,
- ust_ctl_context_fields.get(), context_field_count));
+ try {
+ auto app_context_fields = lsu::create_trace_fields_from_ust_ctl_fields(
+ *locked_registry_session, ust_ctl_context_fields.get(),
+ context_field_count,
+ lst::field_location::root::EVENT_RECORD_COMMON_CONTEXT,
+ lsu::ctl_field_quirks::UNDERSCORE_PREFIXED_VARIANT_TAG_MAPPINGS);
+
+ if (!ust_reg_chan.is_registered()) {
+ lst::type::cuptr event_context = app_context_fields.size() ?
+ lttng::make_unique<lst::structure_type>(
+ 0, std::move(app_context_fields)) :
+ nullptr;
+
+ ust_reg_chan.set_event_context(std::move(event_context));
+ } else {
+ /*
+ * Validate that the context fields match between
+ * registry and newcoming application.
+ */
+ bool context_fields_match;
+ const auto *previous_event_context = ust_reg_chan.get_event_context();