Fix: sessiond: tsdl: don't prepend underscore for stream_id
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Mon, 11 Jul 2022 19:48:49 +0000 (15:48 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Thu, 8 Dec 2022 14:05:33 +0000 (09:05 -0500)
Although the CTF v1.8 specification recommends ignoring any leading
underscore, Some readers, such as Babeltrace 1.x, expect special
identifiers without a prepended underscore.

This causes problems in a follow-up patch since packet header, context,
and event headers become dynamically generated.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I0aeb24ab2e1c0ee1ea70d2fb9bb0eabbb2e9e035

src/bin/lttng-sessiond/tsdl-trace-class-visitor.cpp

index c6c9c93db7d3172a0ed3dd77a44b8578921f214d..b7777d203d2a5f2c0f3d654c4eaa871c4df7af7f 100644 (file)
@@ -14,8 +14,9 @@
 #include <common/uuid.hpp>
 
 #include <array>
-#include <queue>
 #include <locale>
+#include <queue>
+#include <set>
 
 namespace lst = lttng::sessiond::trace;
 namespace tsdl = lttng::sessiond::tsdl;
@@ -24,6 +25,12 @@ namespace {
 const auto ctf_spec_major = 1;
 const auto ctf_spec_minor = 8;
 
+/*
+ * Although the CTF v1.8 specification recommends ignoring any leading underscore, Some readers,
+ * such as Babeltrace 1.x, expect special identifiers without a prepended underscore.
+ */
+const std::set<std::string> safe_tsdl_identifiers = {"stream_id"};
+
 /*
  * A previous implementation always prepended '_' to the identifiers in order to
  * side-step the problem of escaping TSDL keywords and ensuring identifiers
@@ -38,6 +45,10 @@ std::string escape_tsdl_identifier(const std::string& original_identifier)
                LTTNG_THROW_ERROR("Invalid 0-length identifier used in trace description");
        }
 
+       if (safe_tsdl_identifiers.find(original_identifier) != safe_tsdl_identifiers.end()) {
+               return original_identifier;
+       }
+
        std::string new_identifier;
        /* Optimisticly assume most identifiers are valid and allocate the same length. */
        new_identifier.reserve(original_identifier.size());
This page took 0.025658 seconds and 4 git commands to generate.