X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=blobdiff_plain;f=src%2Fbin%2Flttng-sessiond%2Ftsdl-trace-class-visitor.hpp;fp=src%2Fbin%2Flttng-sessiond%2Ftsdl-trace-class-visitor.hpp;h=1b8bd642de9b885614972a19250da54824b05e2b;hp=d06ea9983afd4871d306fde9f56ed92e7670f48f;hb=b6bbb1d666531bf061f29884da1b0d7c10f59aa0;hpb=88277a52069ed0135254ce29da617ebb6ecddbb8 diff --git a/src/bin/lttng-sessiond/tsdl-trace-class-visitor.hpp b/src/bin/lttng-sessiond/tsdl-trace-class-visitor.hpp index d06ea9983..1b8bd642d 100644 --- a/src/bin/lttng-sessiond/tsdl-trace-class-visitor.hpp +++ b/src/bin/lttng-sessiond/tsdl-trace-class-visitor.hpp @@ -15,6 +15,7 @@ #include #include +#include namespace lttng { namespace sessiond { @@ -22,6 +23,36 @@ namespace tsdl { using append_metadata_fragment_function = std::function; +namespace details { +/* + * Register types to be overriden. For example, a TSDL-safe copy of a type can + * be added to be overriden whenever the original type is encountered. + * + * Note that this class assumes no ownership of the original types. It assumes + * that the original types live as long as the original trace. + */ +class type_overrider { +public: + type_overrider() = default; + + void publish(const lttng::sessiond::trace::type& original, + lttng::sessiond::trace::type::cuptr new_type_override); + const lttng::sessiond::trace::type& type( + const lttng::sessiond::trace::type& original) const noexcept; + +private: + std::unordered_map + _overriden_types; +}; +} /* namespace details. */ + +/* + * TSDL-producing trace class visitor. + * + * An instance of this class must not be used on multiple trace class instances. + * The `append_metadata` callback is automatically invoked when a coherent + * fragment of TSDL is available. + */ class trace_class_visitor : public lttng::sessiond::trace::trace_class_visitor { public: trace_class_visitor(const lttng::sessiond::trace::abi& trace_abi, @@ -35,9 +66,30 @@ public: private: /* Coherent (parseable) fragments must be appended. */ void append_metadata_fragment(const std::string& fragment) const; + const lttng::sessiond::trace::type& _lookup_field_type( + const lttng::sessiond::trace::field_location& field_location) const; const lttng::sessiond::trace::abi& _trace_abi; const append_metadata_fragment_function _append_metadata_fragment; + details::type_overrider _sanitized_types_overrides; + + /* + * Current visit context. + * + * The members of a trace class hierarchy do not provide back-references + * up the hierarchy (e.g. stream class to its parent trace class). + * + * This context allows the visitor to evaluate a "field location". + * + * _current_trace_class is set the first time a trace class is visited and + * remains valid until the destruction of this object. + * + * _current_stream_class and _current_event_class are set only in the + * context of the visit of a stream class and of its event class(es). + */ + const lttng::sessiond::trace::trace_class *_current_trace_class = nullptr; + const lttng::sessiond::trace::stream_class *_current_stream_class = nullptr; + const lttng::sessiond::trace::event_class *_current_event_class = nullptr; }; } /* namespace tsdl */