Refactoring: struct lttng_event_field
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Mon, 15 Mar 2021 21:23:57 +0000 (17:23 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Tue, 16 Mar 2021 02:20:00 +0000 (22:20 -0400)
- Namespace this structure with lttng_ust_ prefix,
- Use struct_size extensibility scheme,
- Remove padding,
- Use an array of pointers to structure rather than array of event
  fields to allow easier handling of extensibility. This is achieved by
  using __LTTNG_COMPOUND_LITERAL().
- Move nofilter field into structure.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: Iaa0056ff2d67042d0b6fca156c8f8072ae1820ea

12 files changed:
include/lttng/ust-events.h
include/lttng/ust-tracepoint-event.h
include/ust-comm.h
include/ust-dynamic-type.h
liblttng-ust-comm/lttng-ust-comm.c
liblttng-ust/lttng-bytecode-interpreter.c
liblttng-ust/lttng-bytecode-specialize.c
liblttng-ust/lttng-bytecode.c
liblttng-ust/lttng-bytecode.h
liblttng-ust/lttng-events.c
liblttng-ust/lttng-probes.c
liblttng-ust/lttng-ust-dynamic-type.c

index b43b49e1a9f7ce7389f1f29aa6c28f8ab3e99db7..acea99105a86492646723732f930cc8fe250ab85 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;
 
 /*
@@ -183,7 +183,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;
 
@@ -205,19 +205,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 +252,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 +290,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 */
index 9fbe70e8d4f119e69ce22b9af7587c073e9f05ba..872dfa57bb5b3fa5ff1f6ce9992efb25baefc084 100644 (file)
@@ -254,120 +254,95 @@ void __event_template_proto___##_provider##___##_name(_TP_ARGS_DATA_PROTO(_args)
 #include <lttng/ust-tracepoint-event-nowrite.h>
 
 #undef _ctf_integer_ext
-#define _ctf_integer_ext(_type, _item, _src, _byte_order, _base, _nowrite)     \
-       {                                                       \
-         .name = #_item,                                       \
-         .type = __type_integer(_type, _byte_order, _base, none),\
-         .nowrite = _nowrite,                                  \
-         .u = {                                                \
-                 .ext = {                                      \
-                         .nofilter = 0,                        \
-                 },                                            \
-         },                                                    \
-       },
+#define _ctf_integer_ext(_type, _item, _src, _byte_order, _base, _nowrite) \
+       __LTTNG_COMPOUND_LITERAL(struct lttng_ust_event_field, {        \
+               .struct_size = sizeof(struct lttng_ust_event_field), \
+               .name = #_item,                                 \
+               .type = __type_integer(_type, _byte_order, _base, none), \
+               .nowrite = _nowrite,                            \
+               .nofilter = 0,                                  \
+       }),
 
 #undef _ctf_float
 #define _ctf_float(_type, _item, _src, _nowrite)               \
-       {                                                       \
-         .name = #_item,                                       \
-         .type = __type_float(_type),                          \
-         .nowrite = _nowrite,                                  \
-         .u = {                                                \
-                 .ext = {                                      \
-                         .nofilter = 0,                        \
-                 },                                            \
-         },                                                    \
-       },
+       __LTTNG_COMPOUND_LITERAL(struct lttng_ust_event_field, {        \
+               .struct_size = sizeof(struct lttng_ust_event_field), \
+               .name = #_item,                                 \
+               .type = __type_float(_type),                    \
+               .nowrite = _nowrite,                            \
+               .nofilter = 0,                                  \
+       }),
 
 #undef _ctf_array_encoded
 #define _ctf_array_encoded(_type, _item, _src, _byte_order,    \
                        _length, _encoding, _nowrite,           \
                        _elem_type_base)                        \
-       {                                                       \
-         .name = #_item,                                       \
-         .type =                                               \
-               {                                               \
-                 .atype = atype_array_nestable,                \
-                 .u =                                          \
-                       {                                       \
-                         .array_nestable =                     \
-                               {                               \
-                                 .elem_type = __LTTNG_COMPOUND_LITERAL(struct lttng_type, \
+       __LTTNG_COMPOUND_LITERAL(struct lttng_ust_event_field, {        \
+               .struct_size = sizeof(struct lttng_ust_event_field), \
+               .name = #_item,                                 \
+               .type = {                                       \
+                       .atype = atype_array_nestable,          \
+                       .u = {                                  \
+                               .array_nestable = {             \
+                                       .elem_type = __LTTNG_COMPOUND_LITERAL(struct lttng_type, \
                                        __type_integer(_type, _byte_order, _elem_type_base, _encoding)), \
-                                 .length = _length,            \
-                                 .alignment = 0,               \
+                                       .length = _length,      \
+                                       .alignment = 0,         \
                                }                               \
                        }                                       \
                },                                              \
-         .nowrite = _nowrite,                                  \
-         .u = {                                                \
-                 .ext = {                                      \
-                         .nofilter = 0,                        \
-                 },                                            \
-         },                                                    \
-       },
+               .nowrite = _nowrite,                            \
+               .nofilter = 0,                                  \
+       }),
 
 #undef _ctf_sequence_encoded
 #define _ctf_sequence_encoded(_type, _item, _src, _byte_order, \
                        _length_type, _src_length, _encoding, _nowrite, \
                        _elem_type_base)                        \
-       {                                                       \
-         .name = "_" #_item "_length",                         \
-         .type = __type_integer(_length_type, BYTE_ORDER, 10, none), \
-         .nowrite = _nowrite,                                  \
-         .u = {                                                \
-                 .ext = {                                      \
-                         .nofilter = 1,                        \
-                 },                                            \
-         },                                                    \
-       },                                                      \
-       {                                                       \
-         .name = #_item,                                       \
-         .type =                                               \
-               {                                               \
-                 .atype = atype_sequence_nestable,             \
-                 .u =                                          \
-                       {                                       \
-                         .sequence_nestable =                  \
-                               {                               \
-                                 .length_name = "_" #_item "_length", \
-                                 .elem_type = __LTTNG_COMPOUND_LITERAL(struct lttng_type, \
-                                       __type_integer(_type, _byte_order, _elem_type_base, _encoding)), \
-                                 .alignment = 0,               \
+       __LTTNG_COMPOUND_LITERAL(struct lttng_ust_event_field, {        \
+               .struct_size = sizeof(struct lttng_ust_event_field), \
+               .name = "_" #_item "_length",                   \
+               .type = __type_integer(_length_type, BYTE_ORDER, 10, none), \
+               .nowrite = _nowrite,                            \
+               .nofilter = 1,                                  \
+       }),                                                     \
+       __LTTNG_COMPOUND_LITERAL(struct lttng_ust_event_field, {        \
+               .struct_size = sizeof(struct lttng_ust_event_field), \
+               .name = #_item,                                 \
+               .type = {                                       \
+                       .atype = atype_sequence_nestable,       \
+                       .u = {                                  \
+                               .sequence_nestable = {          \
+                                       .length_name = "_" #_item "_length", \
+                                       .elem_type = __LTTNG_COMPOUND_LITERAL(struct lttng_type, \
+                                               __type_integer(_type, _byte_order, _elem_type_base, _encoding)), \
+                                       .alignment = 0,         \
                                },                              \
                        },                                      \
                },                                              \
-         .nowrite = _nowrite,                                  \
-         .u = {                                                \
-                 .ext = {                                      \
-                         .nofilter = 0,                        \
-                 },                                            \
-         },                                                    \
-       },
+               .nowrite = _nowrite,                            \
+               .nofilter = 0,                                  \
+       }),
 
 #undef _ctf_string
 #define _ctf_string(_item, _src, _nowrite)                     \
-       {                                                       \
-         .name = #_item,                                       \
-         .type =                                               \
-               {                                               \
-                 .atype = atype_string,                        \
-                 .u =                                          \
-                       {                                       \
-                         .string = { .encoding = lttng_encode_UTF8 } \
+       __LTTNG_COMPOUND_LITERAL(struct lttng_ust_event_field, {        \
+               .struct_size = sizeof(struct lttng_ust_event_field), \
+               .name = #_item,                                 \
+               .type = {                                       \
+                       .atype = atype_string,                  \
+                       .u = {                                  \
+                               .string = { .encoding = lttng_encode_UTF8 } \
                        },                                      \
                },                                              \
-         .nowrite = _nowrite,                                  \
-         .u = {                                                \
-                 .ext = {                                      \
-                         .nofilter = 0,                        \
-                 },                                            \
-         },                                                    \
-       },
+               .nowrite = _nowrite,                            \
+               .nofilter = 0,                                  \
+       }),
 
 #undef _ctf_enum
 #define _ctf_enum(_provider, _name, _type, _item, _src, _nowrite) \
-       {                                                       \
+       __LTTNG_COMPOUND_LITERAL(struct lttng_ust_event_field, {        \
+               .struct_size = sizeof(struct lttng_ust_event_field), \
                .name = #_item,                                 \
                .type = {                                       \
                        .atype = atype_enum_nestable,           \
@@ -380,19 +355,15 @@ void __event_template_proto___##_provider##___##_name(_TP_ARGS_DATA_PROTO(_args)
                        },                                      \
                },                                              \
                .nowrite = _nowrite,                            \
-               .u = {                                          \
-                       .ext = {                                \
-                               .nofilter = 0,                  \
-                       },                                      \
-               },                                              \
-       },
+               .nofilter = 0,                                  \
+       }),
 
 #undef TP_FIELDS
 #define TP_FIELDS(...) __VA_ARGS__     /* Only one used in this phase */
 
 #undef _TRACEPOINT_EVENT_CLASS
 #define _TRACEPOINT_EVENT_CLASS(_provider, _name, _args, _fields)                           \
-       static const struct lttng_event_field __event_fields___##_provider##___##_name[] = { \
+       static const struct lttng_ust_event_field *__event_fields___##_provider##___##_name[] = { \
                _fields                                                                      \
                ctf_integer(int, dummy, 0)      /* Dummy, C99 forbids 0-len array. */        \
        };
index bc185669301a5fb0f36fa5e501c55fe2ff17aa1f..3d1ba3729c173a40b2d28b3713cec5ed137582bf 100644 (file)
@@ -42,7 +42,7 @@
 #define LTTNG_UST_COMM_MAX_LISTEN                      10
 #define LTTNG_UST_COMM_REG_MSG_PADDING                 64
 
-struct lttng_event_field;
+struct lttng_ust_event_field;
 struct lttng_ctx_field;
 struct lttng_enum_entry;
 struct lttng_integer_type;
@@ -279,7 +279,7 @@ int ustcomm_register_event(int sock,
        int loglevel,
        const char *signature,          /* event signature (input) */
        size_t nr_fields,               /* fields */
-       const struct lttng_event_field *fields,
+       const struct lttng_ust_event_field **fields,
        const char *model_emf_uri,
        uint32_t *id);                  /* event id (output) */
 
index d88e3c09b9ac6ad3c431efd771f80e23b30faafd..e74250485ff192930f2cd9ca92d9b0d5eba42428 100644 (file)
 
 LTTNG_HIDDEN
 int lttng_ust_dynamic_type_choices(size_t *nr_choices,
-               const struct lttng_event_field **choices);
+               const struct lttng_ust_event_field ***choices);
 LTTNG_HIDDEN
-const struct lttng_event_field *lttng_ust_dynamic_type_field(int64_t value);
+const struct lttng_ust_event_field *lttng_ust_dynamic_type_field(int64_t value);
 LTTNG_HIDDEN
-const struct lttng_event_field *lttng_ust_dynamic_type_tag_field(void);
+const struct lttng_ust_event_field *lttng_ust_dynamic_type_tag_field(void);
 
 #endif /* _LTTNG_UST_DYNAMIC_TYPE_H */
index cfd4ddf6da1a2790b4370034ee447f70c6a4e411..e0b7d73bf9c33e763e6c2232eb31fd6e8a70e9e5 100644 (file)
 
 static
 ssize_t count_fields_recursive(size_t nr_fields,
-               const struct lttng_event_field *lttng_fields);
+               const struct lttng_ust_event_field **lttng_fields);
 static
 int serialize_one_field(struct lttng_session *session,
                struct ustctl_field *fields, size_t *iter_output,
-               const struct lttng_event_field *lf);
+               const struct lttng_ust_event_field *lf);
 static
 int serialize_fields(struct lttng_session *session,
                struct ustctl_field *ustctl_fields,
                size_t *iter_output, size_t nr_lttng_fields,
-               const struct lttng_event_field *lttng_fields);
+               const struct lttng_ust_event_field **lttng_fields);
 
 /*
  * Human readable error message.
@@ -884,7 +884,7 @@ ssize_t count_one_type(const struct lttng_type *lt)
 
        case atype_dynamic:
        {
-               const struct lttng_event_field *choices;
+               const struct lttng_ust_event_field **choices;
                size_t nr_choices;
                int ret;
 
@@ -907,15 +907,15 @@ ssize_t count_one_type(const struct lttng_type *lt)
 
 static
 ssize_t count_fields_recursive(size_t nr_fields,
-               const struct lttng_event_field *lttng_fields)
+               const struct lttng_ust_event_field **lttng_fields)
 {
        int i;
        ssize_t ret, count = 0;
 
        for (i = 0; i < nr_fields; i++) {
-               const struct lttng_event_field *lf;
+               const struct lttng_ust_event_field *lf;
 
-               lf = &lttng_fields[i];
+               lf = lttng_fields[i];
                /* skip 'nowrite' fields */
                if (lf->nowrite)
                        continue;
@@ -935,7 +935,7 @@ ssize_t count_ctx_fields_recursive(size_t nr_fields,
        ssize_t ret, count = 0;
 
        for (i = 0; i < nr_fields; i++) {
-               const struct lttng_event_field *lf;
+               const struct lttng_ust_event_field *lf;
 
                lf = &lttng_fields[i].event_field;
                /* skip 'nowrite' fields */
@@ -991,11 +991,11 @@ int serialize_dynamic_type(struct lttng_session *session,
                struct ustctl_field *fields, size_t *iter_output,
                const char *field_name)
 {
-       const struct lttng_event_field *choices;
+       const struct lttng_ust_event_field **choices;
        char tag_field_name[LTTNG_UST_ABI_SYM_NAME_LEN];
        const struct lttng_type *tag_type;
-       const struct lttng_event_field *tag_field_generic;
-       struct lttng_event_field tag_field = {
+       const struct lttng_ust_event_field *tag_field_generic;
+       struct lttng_ust_event_field tag_field = {
                .name = tag_field_name,
                .nowrite = 0,
        };
@@ -1038,7 +1038,7 @@ int serialize_dynamic_type(struct lttng_session *session,
        /* Serialize choice fields after variant. */
        for (i = 0; i < nr_choices; i++) {
                ret = serialize_one_field(session, fields,
-                       iter_output, &choices[i]);
+                       iter_output, choices[i]);
                if (ret)
                        return ret;
        }
@@ -1238,7 +1238,7 @@ int serialize_one_type(struct lttng_session *session,
 static
 int serialize_one_field(struct lttng_session *session,
                struct ustctl_field *fields, size_t *iter_output,
-               const struct lttng_event_field *lf)
+               const struct lttng_ust_event_field *lf)
 {
        /* skip 'nowrite' fields */
        if (lf->nowrite)
@@ -1251,14 +1251,14 @@ static
 int serialize_fields(struct lttng_session *session,
                struct ustctl_field *ustctl_fields,
                size_t *iter_output, size_t nr_lttng_fields,
-               const struct lttng_event_field *lttng_fields)
+               const struct lttng_ust_event_field **lttng_fields)
 {
        int ret;
        size_t i;
 
        for (i = 0; i < nr_lttng_fields; i++) {
                ret = serialize_one_field(session, ustctl_fields,
-                               iter_output, &lttng_fields[i]);
+                               iter_output, lttng_fields[i]);
                if (ret)
                        return ret;
        }
@@ -1270,7 +1270,7 @@ int alloc_serialize_fields(struct lttng_session *session,
                size_t *_nr_write_fields,
                struct ustctl_field **ustctl_fields,
                size_t nr_fields,
-               const struct lttng_event_field *lttng_fields)
+               const struct lttng_ust_event_field **lttng_fields)
 {
        struct ustctl_field *fields;
        int ret;
@@ -1384,7 +1384,7 @@ int ustcomm_register_event(int sock,
        int loglevel,
        const char *signature,          /* event signature (input) */
        size_t nr_fields,               /* fields */
-       const struct lttng_event_field *lttng_fields,
+       const struct lttng_ust_event_field **lttng_fields,
        const char *model_emf_uri,
        uint32_t *id)                   /* event id (output) */
 {
index 65d06576b199ed1d512499af3bb6ccb9fd038fb2..46351a25f3ed4e23cd68a6edc7deafa7327794cc 100644 (file)
@@ -223,7 +223,7 @@ static int context_get_index(struct lttng_ctx *ctx,
 {
 
        struct lttng_ctx_field *ctx_field;
-       struct lttng_event_field *field;
+       struct lttng_ust_event_field *field;
        struct lttng_ctx_value v;
 
        ctx_field = &ctx->fields[idx];
index 2982a7930ccdc9cb0e215c1c7e32d0d975a7219e..3cb31ba26b634c0f4ce504d621e68876174403f1 100644 (file)
@@ -253,7 +253,7 @@ static int specialize_get_index(struct bytecode_runtime *runtime,
                case OBJECT_TYPE_ARRAY:
                {
                        const struct lttng_integer_type *integer_type;
-                       const struct lttng_event_field *field;
+                       const struct lttng_ust_event_field *field;
                        uint32_t elem_len, num_elems;
                        int signedness;
 
@@ -293,7 +293,7 @@ static int specialize_get_index(struct bytecode_runtime *runtime,
                case OBJECT_TYPE_SEQUENCE:
                {
                        const struct lttng_integer_type *integer_type;
-                       const struct lttng_event_field *field;
+                       const struct lttng_ust_event_field *field;
                        uint32_t elem_len;
                        int signedness;
 
@@ -377,7 +377,7 @@ static int specialize_context_lookup_name(struct lttng_ctx *ctx,
        return lttng_get_context_index(ctx, name);
 }
 
-static int specialize_load_object(const struct lttng_event_field *field,
+static int specialize_load_object(const struct lttng_ust_event_field *field,
                struct vstack_load *load, bool is_context)
 {
        load->type = LOAD_OBJECT;
@@ -458,7 +458,7 @@ static int specialize_context_lookup(struct lttng_ctx *ctx,
 {
        int idx, ret;
        struct lttng_ctx_field *ctx_field;
-       struct lttng_event_field *field;
+       struct lttng_ust_event_field *field;
        struct bytecode_get_index_data gid;
        ssize_t data_offset;
 
@@ -497,7 +497,7 @@ static int specialize_app_context_lookup(struct lttng_ctx **pctx,
        char *name = NULL;
        int idx, ret;
        struct lttng_ctx_field *ctx_field;
-       struct lttng_event_field *field;
+       struct lttng_ust_event_field *field;
        struct bytecode_get_index_data gid;
        ssize_t data_offset;
 
@@ -556,7 +556,7 @@ static int specialize_payload_lookup(const struct lttng_ust_event_desc *event_de
        unsigned int i, nr_fields;
        bool found = false;
        uint32_t field_offset = 0;
-       const struct lttng_event_field *field;
+       const struct lttng_ust_event_field *field;
        int ret;
        struct bytecode_get_index_data gid;
        ssize_t data_offset;
@@ -565,8 +565,8 @@ static int specialize_payload_lookup(const struct lttng_ust_event_desc *event_de
        offset = ((struct get_symbol *) insn->data)->offset;
        name = runtime->p.priv->bc->bc.data + runtime->p.priv->bc->bc.reloc_offset + offset;
        for (i = 0; i < nr_fields; i++) {
-               field = &event_desc->fields[i];
-               if (field->u.ext.nofilter) {
+               field = event_desc->fields[i];
+               if (field->nofilter) {
                        continue;
                }
                if (!strcmp(field->name, name)) {
index ef458055f14f7eec51f2a74c1acf9c8e107ebf60..39881be021d896420c97b45aa074da227a1a0cfd 100644 (file)
@@ -178,7 +178,7 @@ int apply_field_reloc(const struct lttng_ust_event_desc *event_desc,
                const char *field_name,
                enum bytecode_op bytecode_op)
 {
-       const struct lttng_event_field *fields, *field = NULL;
+       const struct lttng_ust_event_field **fields, *field = NULL;
        unsigned int nr_fields, i;
        struct load_op *op;
        uint32_t field_offset = 0;
@@ -193,15 +193,15 @@ int apply_field_reloc(const struct lttng_ust_event_desc *event_desc,
                return -EINVAL;
        nr_fields = event_desc->nr_fields;
        for (i = 0; i < nr_fields; i++) {
-               if (fields[i].u.ext.nofilter) {
+               if (fields[i]->nofilter) {
                        continue;
                }
-               if (!strcmp(fields[i].name, field_name)) {
-                       field = &fields[i];
+               if (!strcmp(fields[i]->name, field_name)) {
+                       field = fields[i];
                        break;
                }
                /* compute field offset */
-               switch (fields[i].type.atype) {
+               switch (fields[i]->type.atype) {
                case atype_integer:
                case atype_enum_nestable:
                        field_offset += sizeof(int64_t);
index 8caf15ecd43d2eb1e2c7d470e49029b6b9f45fba..90b4c332d7b6879786db2f7187ffce152ffb37a7 100644 (file)
@@ -119,7 +119,7 @@ struct bytecode_get_index_data {
         * interpreter needs to find it from the event fields and types to
         * support variants.
         */
-       const struct lttng_event_field *field;
+       const struct lttng_ust_event_field *field;
        struct {
                size_t len;
                enum object_type type;
@@ -131,7 +131,7 @@ struct bytecode_get_index_data {
 struct vstack_load {
        enum load_type type;
        enum object_type object_type;
-       const struct lttng_event_field *field;
+       const struct lttng_ust_event_field *field;
        bool rev_bo;    /* reverse byte order */
 };
 
@@ -208,7 +208,7 @@ struct load_ptr {
                uint64_t u64;
                double d;
        } u;
-       const struct lttng_event_field *field;
+       const struct lttng_ust_event_field *field;
 };
 
 struct estack_entry {
index 7dfe6b7a6d46a5a6fa62eaffa5f72a8f37aae665..3c78734fe22bb1e433add84861e0ae5012cecc27 100644 (file)
@@ -475,7 +475,7 @@ int lttng_create_enum_check(const struct lttng_type *type,
        }
        case atype_dynamic:
        {
-               const struct lttng_event_field *tag_field_generic;
+               const struct lttng_ust_event_field *tag_field_generic;
                const struct lttng_enum_desc *enum_desc;
                int ret;
 
@@ -497,7 +497,7 @@ int lttng_create_enum_check(const struct lttng_type *type,
 
 static
 int lttng_create_all_event_enums(size_t nr_fields,
-               const struct lttng_event_field *event_fields,
+               const struct lttng_ust_event_field **event_fields,
                struct lttng_session *session)
 {
        size_t i;
@@ -505,7 +505,7 @@ int lttng_create_all_event_enums(size_t nr_fields,
 
        /* For each field, ensure enum is part of the session. */
        for (i = 0; i < nr_fields; i++) {
-               const struct lttng_type *type = &event_fields[i].type;
+               const struct lttng_type *type = &event_fields[i]->type;
 
                ret = lttng_create_enum_check(type, session);
                if (ret)
@@ -1141,10 +1141,10 @@ void _event_enum_destroy(struct lttng_ust_event_common *event)
                /* Destroy enums of the current event. */
                for (i = 0; i < event_recorder->parent->priv->desc->nr_fields; i++) {
                        const struct lttng_enum_desc *enum_desc;
-                       const struct lttng_event_field *field;
+                       const struct lttng_ust_event_field *field;
                        struct lttng_enum *curr_enum;
 
-                       field = &(event_recorder->parent->priv->desc->fields[i]);
+                       field = event_recorder->parent->priv->desc->fields[i];
                        switch (field->type.atype) {
                        case atype_enum_nestable:
                                enum_desc = field->type.u.enum_nestable.desc;
index d009a87461108661f01dfca78021095f0eb4baed..98998b0fae9cbd37e449a0a0b9db2676785ad418 100644 (file)
@@ -338,8 +338,8 @@ int lttng_probes_get_field_list(struct lttng_ust_field_list *list)
                        }
 
                        for (j = 0; j < event_desc->nr_fields; j++) {
-                               const struct lttng_event_field *event_field =
-                                       &event_desc->fields[j];
+                               const struct lttng_ust_event_field *event_field =
+                                       event_desc->fields[j];
                                struct tp_field_list_entry *list_entry;
 
                                list_entry = zmalloc(sizeof(*list_entry));
index 6913ca4b1d1877a82844abaa70eeb46acb60a7ba..1647094f4f6256c38d458150ebea23dfb605794c 100644 (file)
@@ -51,8 +51,9 @@ static const struct lttng_enum_desc dt_enum_desc = {
        .nr_entries = LTTNG_ARRAY_SIZE(dt_enum),
 };
 
-const struct lttng_event_field dt_var_fields[_NR_LTTNG_UST_DYNAMIC_TYPES] = {
-       [LTTNG_UST_DYNAMIC_TYPE_NONE] = {
+const struct lttng_ust_event_field *dt_var_fields[_NR_LTTNG_UST_DYNAMIC_TYPES] = {
+       [LTTNG_UST_DYNAMIC_TYPE_NONE] = __LTTNG_COMPOUND_LITERAL(struct lttng_ust_event_field, {
+               .struct_size = sizeof(struct lttng_ust_event_field),
                .name = "none",
                .type = {
                        .atype = atype_struct_nestable,
@@ -60,68 +61,79 @@ const struct lttng_event_field dt_var_fields[_NR_LTTNG_UST_DYNAMIC_TYPES] = {
                        .u.struct_nestable.alignment = 0,
                },
                .nowrite = 0,
-       },
-       [LTTNG_UST_DYNAMIC_TYPE_S8] = {
+       }),
+       [LTTNG_UST_DYNAMIC_TYPE_S8] = __LTTNG_COMPOUND_LITERAL(struct lttng_ust_event_field, {
+               .struct_size = sizeof(struct lttng_ust_event_field),
                .name = "int8",
                .type = __type_integer(int8_t, BYTE_ORDER, 10, none),
                .nowrite = 0,
-       },
-       [LTTNG_UST_DYNAMIC_TYPE_S16] = {
+       }),
+       [LTTNG_UST_DYNAMIC_TYPE_S16] = __LTTNG_COMPOUND_LITERAL(struct lttng_ust_event_field, {
+               .struct_size = sizeof(struct lttng_ust_event_field),
                .name = "int16",
                .type = __type_integer(int16_t, BYTE_ORDER, 10, none),
                .nowrite = 0,
-       },
-       [LTTNG_UST_DYNAMIC_TYPE_S32] = {
+       }),
+       [LTTNG_UST_DYNAMIC_TYPE_S32] = __LTTNG_COMPOUND_LITERAL(struct lttng_ust_event_field, {
+               .struct_size = sizeof(struct lttng_ust_event_field),
                .name = "int32",
                .type = __type_integer(int32_t, BYTE_ORDER, 10, none),
                .nowrite = 0,
-       },
-       [LTTNG_UST_DYNAMIC_TYPE_S64] = {
+       }),
+       [LTTNG_UST_DYNAMIC_TYPE_S64] = __LTTNG_COMPOUND_LITERAL(struct lttng_ust_event_field, {
+               .struct_size = sizeof(struct lttng_ust_event_field),
                .name = "int64",
                .type = __type_integer(int64_t, BYTE_ORDER, 10, none),
                .nowrite = 0,
-       },
-       [LTTNG_UST_DYNAMIC_TYPE_U8] = {
+       }),
+       [LTTNG_UST_DYNAMIC_TYPE_U8] = __LTTNG_COMPOUND_LITERAL(struct lttng_ust_event_field, {
+               .struct_size = sizeof(struct lttng_ust_event_field),
                .name = "uint8",
                .type = __type_integer(uint8_t, BYTE_ORDER, 10, none),
                .nowrite = 0,
-       },
-       [LTTNG_UST_DYNAMIC_TYPE_U16] = {
+       }),
+       [LTTNG_UST_DYNAMIC_TYPE_U16] = __LTTNG_COMPOUND_LITERAL(struct lttng_ust_event_field, {
+               .struct_size = sizeof(struct lttng_ust_event_field),
                .name = "uint16",
                .type = __type_integer(uint16_t, BYTE_ORDER, 10, none),
                .nowrite = 0,
-       },
-       [LTTNG_UST_DYNAMIC_TYPE_U32] = {
+       }),
+       [LTTNG_UST_DYNAMIC_TYPE_U32] = __LTTNG_COMPOUND_LITERAL(struct lttng_ust_event_field, {
+               .struct_size = sizeof(struct lttng_ust_event_field),
                .name = "uint32",
                .type = __type_integer(uint32_t, BYTE_ORDER, 10, none),
                .nowrite = 0,
-       },
-       [LTTNG_UST_DYNAMIC_TYPE_U64] = {
+       }),
+       [LTTNG_UST_DYNAMIC_TYPE_U64] = __LTTNG_COMPOUND_LITERAL(struct lttng_ust_event_field, {
+               .struct_size = sizeof(struct lttng_ust_event_field),
                .name = "uint64",
                .type = __type_integer(uint64_t, BYTE_ORDER, 10, none),
                .nowrite = 0,
-       },
-       [LTTNG_UST_DYNAMIC_TYPE_FLOAT] = {
+       }),
+       [LTTNG_UST_DYNAMIC_TYPE_FLOAT] = __LTTNG_COMPOUND_LITERAL(struct lttng_ust_event_field, {
+               .struct_size = sizeof(struct lttng_ust_event_field),
                .name = "float",
                .type = __type_float(float),
                .nowrite = 0,
-       },
-       [LTTNG_UST_DYNAMIC_TYPE_DOUBLE] = {
+       }),
+       [LTTNG_UST_DYNAMIC_TYPE_DOUBLE] = __LTTNG_COMPOUND_LITERAL(struct lttng_ust_event_field, {
+               .struct_size = sizeof(struct lttng_ust_event_field),
                .name = "double",
                .type = __type_float(double),
                .nowrite = 0,
-       },
-       [LTTNG_UST_DYNAMIC_TYPE_STRING] = {
+       }),
+       [LTTNG_UST_DYNAMIC_TYPE_STRING] = __LTTNG_COMPOUND_LITERAL(struct lttng_ust_event_field, {
+               .struct_size = sizeof(struct lttng_ust_event_field),
                .name = "string",
                .type = {
                        .atype = atype_string,
                        .u.string.encoding = lttng_encode_UTF8,
                },
                .nowrite = 0,
-       },
+       }),
 };
 
-static const struct lttng_event_field dt_enum_field = {
+static const struct lttng_ust_event_field dt_enum_field = {
        .name = NULL,
        .type.atype = atype_enum_nestable,
        .type.u.enum_nestable.desc = &dt_enum_desc,
@@ -131,21 +143,21 @@ static const struct lttng_event_field dt_enum_field = {
        .nowrite = 0,
 };
 
-const struct lttng_event_field *lttng_ust_dynamic_type_field(int64_t value)
+const struct lttng_ust_event_field *lttng_ust_dynamic_type_field(int64_t value)
 {
        if (value >= _NR_LTTNG_UST_DYNAMIC_TYPES || value < 0)
                return NULL;
-       return &dt_var_fields[value];
+       return dt_var_fields[value];
 }
 
-int lttng_ust_dynamic_type_choices(size_t *nr_choices, const struct lttng_event_field **choices)
+int lttng_ust_dynamic_type_choices(size_t *nr_choices, const struct lttng_ust_event_field ***choices)
 {
        *nr_choices = _NR_LTTNG_UST_DYNAMIC_TYPES;
        *choices = dt_var_fields;
        return 0;
 }
 
-const struct lttng_event_field *lttng_ust_dynamic_type_tag_field(void)
+const struct lttng_ust_event_field *lttng_ust_dynamic_type_tag_field(void)
 {
        return &dt_enum_field;
 }
This page took 0.041438 seconds and 4 git commands to generate.