sessiond: ust: conditionally enable the underscore prefix variant quirk
[lttng-tools.git] / src / bin / lttng-sessiond / ust-app.cpp
index 3f39b02e4d9ee3d0e6faf65fa1d243ddf242f2e0..11d604ea9a463e7c32126b5189e46707e74f7ce1 100644 (file)
@@ -6429,7 +6429,9 @@ static int handle_app_register_channel_notification(int sock,
        try {
                auto app_context_fields = lsu::create_trace_fields_from_ust_ctl_fields(
                                *locked_registry_session, ust_ctl_context_fields.get(),
-                               context_field_count);
+                               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() ?
@@ -6563,12 +6565,16 @@ static int add_event_ust_registry(int sock, int sobjd, int cobjd, const char *na
                                channel.add_event(sobjd, cobjd, name, signature.get(),
                                                lsu::create_trace_fields_from_ust_ctl_fields(
                                                                *locked_registry, fields.get(),
-                                                               nr_fields),
+                                                               nr_fields,
+                                                               lst::field_location::root::
+                                                                               EVENT_RECORD_PAYLOAD,
+                                                               lsu::ctl_field_quirks::
+                                                                               UNDERSCORE_PREFIXED_VARIANT_TAG_MAPPINGS),
                                                loglevel_value,
                                                model_emf_uri.get() ?
                                                                nonstd::optional<std::string>(
                                                                                model_emf_uri.get()) :
-                                                                     nonstd::nullopt,
+                                                               nonstd::nullopt,
                                                ua_sess->buffer_type, *app, event_id);
                                ret_code = 0;
                        } catch (const std::exception& ex) {
@@ -7889,3 +7895,30 @@ error:
        rcu_read_unlock();
        return ret;
 }
+
+lsu::ctl_field_quirks ust_app::ctl_field_quirks() const
+{
+       /*
+        * Application contexts are expressed as variants. LTTng-UST announces
+        * those by registering an enumeration named `..._tag`. It then registers a
+        * variant as part of the event context that contains the various possible
+        * types.
+        *
+        * Unfortunately, the names used in the enumeration and variant don't
+        * match: the enumeration names are all prefixed with an underscore while
+        * the variant type tag fields aren't.
+        *
+        * While the CTF 1.8.3 specification mentions that
+        * underscores *should* (not *must*) be removed by CTF readers. Babeltrace
+        * 1.x (and possibly others) expect a perfect match between the names used
+        * by tags and variants.
+        *
+        * When the UNDERSCORE_PREFIXED_VARIANT_TAG_MAPPINGS quirk is enabled,
+        * the variant's fields are modified to match the mappings of its tag.
+        *
+        * From ABI version >= 10.x, the variant fields and tag mapping names
+        * correctly match, making this quirk unnecessary.
+        */
+       return v_major <= 9 ? lsu::ctl_field_quirks::UNDERSCORE_PREFIXED_VARIANT_TAG_MAPPINGS :
+               lsu::ctl_field_quirks::NONE;
+}
\ No newline at end of file
This page took 0.024339 seconds and 4 git commands to generate.