Refactoring: struct lttng_enum_desc and lttng_enum_entry
[lttng-ust.git] / include / lttng / ust-events.h
index b43b49e1a9f7ce7389f1f29aa6c28f8ab3e99db7..164c82c4c8288617702a56edc5eec30ba341b6aa 100644 (file)
@@ -43,7 +43,7 @@ extern "C" {
 struct lttng_channel;
 struct lttng_session;
 struct lttng_ust_lib_ring_buffer_ctx;
-struct lttng_event_field;
+struct lttng_ust_event_field;
 struct lttng_event_notifier_group;
 
 /*
@@ -83,16 +83,26 @@ enum lttng_enum_entry_options {
        LTTNG_ENUM_ENTRY_OPTION_IS_AUTO = 1U << 0,
 };
 
-#define LTTNG_UST_ENUM_ENTRY_PADDING   16
-struct lttng_enum_entry {
+/*
+ * Enumeration entry description
+ *
+ * IMPORTANT: this structure is part of the ABI between the probe and
+ * UST. Fields need to be only added at the end, never reordered, never
+ * removed.
+ *
+ * The field @struct_size should be used to determine the size of the
+ * structure. It should be queried before using additional fields added
+ * at the end of the structure.
+ */
+
+struct lttng_ust_enum_entry {
+       uint32_t struct_size;
+
        struct lttng_enum_value start, end; /* start and end are inclusive */
        const char *string;
-       union {
-               struct {
-                       unsigned int options;
-               } LTTNG_PACKED extra;
-               char padding[LTTNG_UST_ENUM_ENTRY_PADDING];
-       } u;
+       unsigned int options;
+
+       /* End of base ABI. Fields below should be used after checking struct_size. */
 };
 
 #define __type_integer(_type, _byte_order, _base, _encoding)   \
@@ -168,7 +178,7 @@ struct lttng_type {
                        enum lttng_string_encodings encoding;
                } string;
                struct {
-                       const struct lttng_enum_desc *desc;     /* Enumeration mapping */
+                       const struct lttng_ust_enum_desc *desc; /* Enumeration mapping */
                        struct lttng_type *container_type;
                } enum_nestable;
                struct {
@@ -183,7 +193,7 @@ struct lttng_type {
                } sequence_nestable;
                struct {
                        unsigned int nr_fields;
-                       const struct lttng_event_field *fields; /* Array of fields. */
+                       const struct lttng_ust_event_field **fields; /* Array of pointers to fields. */
                        unsigned int alignment;
                } struct_nestable;
 
@@ -191,12 +201,26 @@ struct lttng_type {
        } u;
 };
 
-#define LTTNG_UST_ENUM_TYPE_PADDING    24
-struct lttng_enum_desc {
+/*
+ * Enumeration description
+ *
+ * IMPORTANT: this structure is part of the ABI between the probe and
+ * UST. Fields need to be only added at the end, never reordered, never
+ * removed.
+ *
+ * The field @struct_size should be used to determine the size of the
+ * structure. It should be queried before using additional fields added
+ * at the end of the structure.
+ */
+
+struct lttng_ust_enum_desc {
+       uint32_t struct_size;
+
        const char *name;
-       const struct lttng_enum_entry *entries;
+       const struct lttng_ust_enum_entry **entries;
        unsigned int nr_entries;
-       char padding[LTTNG_UST_ENUM_TYPE_PADDING];
+
+       /* End of base ABI. Fields below should be used after checking struct_size. */
 };
 
 /*
@@ -205,19 +229,21 @@ struct lttng_enum_desc {
  * IMPORTANT: this structure is part of the ABI between the probe and
  * UST. Fields need to be only added at the end, never reordered, never
  * removed.
+ *
+ * The field @struct_size should be used to determine the size of the
+ * structure. It should be queried before using additional fields added
+ * at the end of the structure.
  */
 
-#define LTTNG_UST_EVENT_FIELD_PADDING  28
-struct lttng_event_field {
+struct lttng_ust_event_field {
+       uint32_t struct_size;
+
        const char *name;
        struct lttng_type type;
-       unsigned int nowrite;   /* do not write into trace */
-       union {
-               struct {
-                       unsigned int nofilter:1;        /* do not consider for filter */
-               } ext;
-               char padding[LTTNG_UST_EVENT_FIELD_PADDING];
-       } u;
+       unsigned int nowrite:1,         /* do not write into trace */
+               nofilter:1;             /* do not consider for filter */
+
+       /* End of base ABI. Fields below should be used after checking struct_size. */
 };
 
 enum lttng_ust_dynamic_type {
@@ -250,7 +276,7 @@ struct lttng_perf_counter_field;
 
 #define LTTNG_UST_CTX_FIELD_PADDING    40
 struct lttng_ctx_field {
-       struct lttng_event_field event_field;
+       struct lttng_ust_event_field event_field;
        size_t (*get_size)(struct lttng_ctx_field *field, size_t offset);
        void (*record)(struct lttng_ctx_field *field,
                       struct lttng_ust_lib_ring_buffer_ctx *ctx,
@@ -288,7 +314,7 @@ struct lttng_ust_event_desc {
        const char *name;
        void (*probe_callback)(void);
        const struct lttng_event_ctx *ctx;      /* context */
-       const struct lttng_event_field *fields; /* event payload */
+       const struct lttng_ust_event_field **fields;    /* event payload */
        unsigned int nr_fields;
        const int **loglevel;
        const char *signature;                  /* Argument types/names received */
@@ -458,7 +484,7 @@ struct lttng_ust_event_notifier {
 };
 
 struct lttng_enum {
-       const struct lttng_enum_desc *desc;
+       const struct lttng_ust_enum_desc *desc;
        struct lttng_session *session;
        struct cds_list_head node;      /* Enum list in session */
        struct cds_hlist_node hlist;    /* Session ht of enums */
This page took 0.025824 seconds and 4 git commands to generate.