X-Git-Url: https://git.liburcu.org/?a=blobdiff_plain;f=src%2Fbin%2Flttng-sessiond%2Ffield.hpp;h=f353adafbcc7d04e04e056144d53bb3c269b1b73;hb=24ed18f2ceda5023e4ad755547ad79466730cbd3;hp=bad66a39afe5a3bc8350b16c7d0b766a4be2ebe5;hpb=0220be14254fac4f7af642fd6630282b29776a70;p=lttng-tools.git diff --git a/src/bin/lttng-sessiond/field.hpp b/src/bin/lttng-sessiond/field.hpp index bad66a39a..f353adafb 100644 --- a/src/bin/lttng-sessiond/field.hpp +++ b/src/bin/lttng-sessiond/field.hpp @@ -8,8 +8,6 @@ #ifndef LTTNG_FIELD_H #define LTTNG_FIELD_H -#include "trace-class.hpp" - #include #include #include @@ -24,6 +22,11 @@ namespace trace { class field_visitor; class type_visitor; +enum class byte_order { + BIG_ENDIAN_, + LITTLE_ENDIAN_, +}; + /* * Field, and the various field types, represents fields as exposed by the * LTTng tracers. These classes do not attempt to describe the complete spectrum of the CTF @@ -76,18 +79,43 @@ public: HEXADECIMAL = 16, }; + enum class role { + DEFAULT_CLOCK_TIMESTAMP, + /* Packet header field class specific roles. */ + DATA_STREAM_CLASS_ID, + DATA_STREAM_ID, + PACKET_MAGIC_NUMBER, + /* Packet context field class specific roles. */ + DISCARDED_EVENT_RECORD_COUNTER_SNAPSHOT, + PACKET_CONTENT_LENGTH, + PACKET_END_DEFAULT_CLOCK_TIMESTAMP, + PACKET_SEQUENCE_NUMBER, + PACKET_TOTAL_LENGTH, + /* Event record field class roles. */ + EVENT_RECORD_CLASS_ID, + }; + + using roles = std::vector; + integer_type(unsigned int alignment, byte_order byte_order, unsigned int size, signedness signedness, - base base); + base base, + roles roles = {}); virtual void accept(type_visitor& visitor) const override; const enum byte_order byte_order; const unsigned int size; - const signedness signedness; - const base base; + /* + * signedness and base are suffixed with '_' to work-around a bug in older + * GCCs (before 6) that do not recognize hidden/shadowed enumeration as valid + * nested-name-specifiers. + */ + const signedness signedness_; + const base base_; + const roles roles_; protected: virtual bool _is_equal(const type& other) const noexcept override; @@ -116,7 +144,8 @@ protected: enum byte_order byte_order, unsigned int size, enum signedness signedness, - enum base base); + enum base base, + integer_type::roles roles = {}); virtual void accept(type_visitor& visitor) const = 0; }; @@ -187,14 +216,17 @@ public: typed_enumeration_type(unsigned int in_alignment, enum byte_order in_byte_order, unsigned int in_size, - enum signedness in_signedness, enum base in_base, - const std::shared_ptr& in_mappings) : + const std::shared_ptr& in_mappings, + integer_type::roles in_roles = {}) : enumeration_type(in_alignment, in_byte_order, in_size, - in_signedness, - in_base), + std::is_signed::value ? + integer_type::signedness::SIGNED : + integer_type::signedness::UNSIGNED, + in_base, + std::move(in_roles)), _mappings{std::move(in_mappings)} { } @@ -221,7 +253,7 @@ class array_type : public type { public: array_type(unsigned int alignment, type::cuptr element_type); - const type::cuptr element_type; + const type::cuptr element_type; protected: virtual bool _is_equal(const type& base_other) const noexcept override; @@ -255,6 +287,38 @@ private: virtual bool _is_equal(const type& base_other) const noexcept override final; }; +class static_length_blob_type : public type { +public: + enum class role { + /* Packet header field class specific role. */ + TRACE_CLASS_UUID, + }; + + using roles = std::vector; + + static_length_blob_type(unsigned int alignment, uint64_t in_length_bytes, roles roles = {}); + + virtual void accept(type_visitor& visitor) const override final; + + const uint64_t length_bytes; + const roles roles_; + +private: + virtual bool _is_equal(const type& base_other) const noexcept override final; +}; + +class dynamic_length_blob_type : public type { +public: + dynamic_length_blob_type(unsigned int alignment, std::string length_field_name); + + virtual void accept(type_visitor& visitor) const override final; + + const std::string length_field_name; + +private: + virtual bool _is_equal(const type& base_other) const noexcept override final; +}; + class string_type : public type { public: enum class encoding { @@ -264,7 +328,12 @@ public: string_type(unsigned int alignment, enum encoding encoding); - const encoding encoding; + /* + * encoding is suffixed with '_' to work-around a bug in older + * GCCs (before 6) that do not recognize hidden/shadowed enumeration as valid + * nested-name-specifiers. + */ + const encoding encoding_; protected: virtual bool _is_equal(const type& base_other) const noexcept override; @@ -348,6 +417,8 @@ public: virtual void visit(const unsigned_enumeration_type& type) = 0; virtual void visit(const static_length_array_type& type) = 0; virtual void visit(const dynamic_length_array_type& type) = 0; + virtual void visit(const static_length_blob_type& type) = 0; + virtual void visit(const dynamic_length_blob_type& type) = 0; virtual void visit(const null_terminated_string_type& type) = 0; virtual void visit(const static_length_string_type& type) = 0; virtual void visit(const dynamic_length_string_type& type) = 0;