From 2f35b2f5e29f337ad7c780e41d1eaeae378c1bc2 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Galarneau?= Date: Mon, 11 Jul 2022 15:48:49 -0400 Subject: [PATCH] Fix: sessiond: tsdl: don't prepend underscore for stream_id MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 Change-Id: I0aeb24ab2e1c0ee1ea70d2fb9bb0eabbb2e9e035 --- src/bin/lttng-sessiond/tsdl-trace-class-visitor.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/bin/lttng-sessiond/tsdl-trace-class-visitor.cpp b/src/bin/lttng-sessiond/tsdl-trace-class-visitor.cpp index c6c9c93db..b7777d203 100644 --- a/src/bin/lttng-sessiond/tsdl-trace-class-visitor.cpp +++ b/src/bin/lttng-sessiond/tsdl-trace-class-visitor.cpp @@ -14,8 +14,9 @@ #include #include -#include #include +#include +#include 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 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()); -- 2.34.1