From: Jérémie Galarneau Date: Mon, 11 Jul 2022 19:48:49 +0000 (-0400) Subject: Fix: sessiond: tsdl: don't prepend underscore for stream_id X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=2f35b2f5e29f337ad7c780e41d1eaeae378c1bc2;p=lttng-tools.git Fix: sessiond: tsdl: don't prepend underscore for stream_id 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 --- 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());