Refactoring: UST types public interfaces
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Wed, 17 Mar 2021 02:41:20 +0000 (22:41 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Wed, 17 Mar 2021 16:15:22 +0000 (12:15 -0400)
- Properly namespace public type interfaces with lttng_ust_ prefix,
- Move from union to parent embedding into children for inheritance.
- Introduce struct lttng_ust_type_common, which is fixed-size, to
  contain the type selector. Used as parent for each sub-type.
- Use compound literals on tracepoint probe definition rather than
  nesting into event field structure to allow each type to be extended
  with a struct_size scheme.
- The parent field is required to be the first field of each sub-type,
  allowing cast between parent and children types.
- Remove const-ness from various probe provider visible types to
  facilitate re-use of the code for eventual dynamically allocated
  structures.
- Remove "field_name" field from lttng_ust_ctx_field. Instead,
  dynamically allocate field names for each context.
- Introduce get_type_max_align() in lttng-context.c now used by
  lttng_context_update(). It performs a recursive traversal of the
  nested types rather than erroring out on recursive cases.
- Move "encoding" from integer type to array and sequences types.

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

40 files changed:
include/lttng/ust-events.h
include/lttng/ust-tracepoint-event.h
include/ust-comm.h
include/ust-context-provider.h
include/ust-dynamic-type.h
liblttng-ust-comm/lttng-ust-comm.c
liblttng-ust/event-notifier-notification.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-context-cgroup-ns.c
liblttng-ust/lttng-context-cpu-id.c
liblttng-ust/lttng-context-ip.c
liblttng-ust/lttng-context-ipc-ns.c
liblttng-ust/lttng-context-mnt-ns.c
liblttng-ust/lttng-context-net-ns.c
liblttng-ust/lttng-context-perf-counters.c
liblttng-ust/lttng-context-pid-ns.c
liblttng-ust/lttng-context-procname.c
liblttng-ust/lttng-context-provider.c
liblttng-ust/lttng-context-pthread-id.c
liblttng-ust/lttng-context-time-ns.c
liblttng-ust/lttng-context-user-ns.c
liblttng-ust/lttng-context-uts-ns.c
liblttng-ust/lttng-context-vegid.c
liblttng-ust/lttng-context-veuid.c
liblttng-ust/lttng-context-vgid.c
liblttng-ust/lttng-context-vpid.c
liblttng-ust/lttng-context-vsgid.c
liblttng-ust/lttng-context-vsuid.c
liblttng-ust/lttng-context-vtid.c
liblttng-ust/lttng-context-vuid.c
liblttng-ust/lttng-context.c
liblttng-ust/lttng-events.c
liblttng-ust/lttng-probes.c
liblttng-ust/lttng-ust-abi.c
liblttng-ust/lttng-ust-dynamic-type.c
liblttng-ust/ust-core.c
liblttng-ust/ust-events-internal.h

index 5025b1877f58d9e1e337b757a9bae6de54a6e6f4..946abe4b610d80fa2fb621d71a4404328d7cb4a1 100644 (file)
@@ -47,30 +47,28 @@ struct lttng_ust_event_field;
 
 /*
  * Data structures used by tracepoint event declarations, and by the
- * tracer. Those structures have padding for future extension.
+ * tracer.
  */
 
 /* Type description */
 
-/* Update the astract_types name table in lttng-types.c along with this enum */
-enum lttng_abstract_types {
-       atype_integer,
-       atype_string,
-       atype_float,
-       atype_dynamic,
-       atype_enum_nestable,
-       atype_array_nestable,
-       atype_sequence_nestable,
-       atype_struct_nestable,
-       NR_ABSTRACT_TYPES,
+enum lttng_ust_type {
+       lttng_ust_type_integer,
+       lttng_ust_type_string,
+       lttng_ust_type_float,
+       lttng_ust_type_dynamic,
+       lttng_ust_type_enum,
+       lttng_ust_type_array,
+       lttng_ust_type_sequence,
+       lttng_ust_type_struct,
+       NR_LTTNG_UST_TYPE,
 };
 
-/* Update the string_encodings name table in lttng-types.c along with this enum */
-enum lttng_string_encodings {
-       lttng_encode_none = 0,
-       lttng_encode_UTF8 = 1,
-       lttng_encode_ASCII = 2,
-       NR_STRING_ENCODINGS,
+enum lttng_ust_string_encoding {
+       lttng_ust_string_encoding_none = 0,
+       lttng_ust_string_encoding_UTF8 = 1,
+       lttng_ust_string_encoding_ASCII = 2,
+       NR_LTTNG_UST_STRING_ENCODING,
 };
 
 struct lttng_enum_value {
@@ -104,30 +102,44 @@ struct lttng_ust_enum_entry {
        /* End of base ABI. Fields below should be used after checking struct_size. */
 };
 
-#define __type_integer(_type, _byte_order, _base, _encoding)           \
-       {                                                               \
-               .atype = atype_integer,                                 \
-               .u = {                                                  \
-                       .integer = {                                    \
-                               .size = sizeof(_type) * CHAR_BIT,       \
-                               .alignment = lttng_alignof(_type) * CHAR_BIT, \
-                               .signedness = lttng_is_signed_type(_type), \
-                               .reverse_byte_order = _byte_order != BYTE_ORDER, \
-                               .base = _base,                  \
-                               .encoding = lttng_encode_##_encoding, \
-                       }                                       \
-               },                                              \
-       }                                                       \
-
-#define LTTNG_UST_INTEGER_TYPE_PADDING 24
-struct lttng_integer_type {
+/*
+ * struct lttng_ust_type_common is fixed-size. Its children inherits
+ * from it by embedding struct lttng_ust_type_common as its first field.
+ */
+struct lttng_ust_type_common {
+       enum lttng_ust_type type;
+};
+
+struct lttng_ust_type_integer {
+       struct lttng_ust_type_common parent;
+       uint32_t struct_size;
        unsigned int size;              /* in bits */
        unsigned short alignment;       /* in bits */
        unsigned int signedness:1;
        unsigned int reverse_byte_order:1;
        unsigned int base;              /* 2, 8, 10, 16, for pretty print */
-       enum lttng_string_encodings encoding;
-       char padding[LTTNG_UST_INTEGER_TYPE_PADDING];
+};
+
+#define lttng_ust_type_integer_define(_type, _byte_order, _base)       \
+       ((struct lttng_ust_type_common *) __LTTNG_COMPOUND_LITERAL(struct lttng_ust_type_integer, { \
+               .parent = {                                             \
+                       .type = lttng_ust_type_integer,                 \
+               },                                                      \
+               .struct_size = sizeof(struct lttng_ust_type_integer),   \
+               .size = sizeof(_type) * CHAR_BIT,                       \
+               .alignment = lttng_alignof(_type) * CHAR_BIT,           \
+               .signedness = lttng_is_signed_type(_type),              \
+               .reverse_byte_order = _byte_order != BYTE_ORDER,        \
+               .base = _base,                                          \
+       }))
+
+struct lttng_ust_type_float {
+       struct lttng_ust_type_common parent;
+       uint32_t struct_size;
+       unsigned int exp_dig;           /* exponent digits, in bits */
+       unsigned int mant_dig;          /* mantissa digits, in bits */
+       unsigned short alignment;       /* in bits */
+       unsigned int reverse_byte_order:1;
 };
 
 /*
@@ -139,61 +151,57 @@ struct lttng_integer_type {
                : (sizeof(_type) == sizeof(double) ? DBL_MANT_DIG       \
                : 0))
 
-#define __type_float(_type)                                            \
-       {                                                               \
-               .atype = atype_float,                                   \
-               .u = {                                                  \
-                       ._float = {                                     \
-                               .exp_dig = sizeof(_type) * CHAR_BIT     \
-                                       - _float_mant_dig(_type),       \
-                               .mant_dig = _float_mant_dig(_type),     \
-                               .alignment = lttng_alignof(_type) * CHAR_BIT, \
-                               .reverse_byte_order = BYTE_ORDER != FLOAT_WORD_ORDER,   \
-                       }                                               \
-               }                                                       \
-       }                                                               \
-
-#define LTTNG_UST_FLOAT_TYPE_PADDING   24
-struct lttng_float_type {
-       unsigned int exp_dig;           /* exponent digits, in bits */
-       unsigned int mant_dig;          /* mantissa digits, in bits */
-       unsigned short alignment;       /* in bits */
-       unsigned int reverse_byte_order:1;
-       char padding[LTTNG_UST_FLOAT_TYPE_PADDING];
+#define lttng_ust_type_float_define(_type)                             \
+       ((struct lttng_ust_type_common *) __LTTNG_COMPOUND_LITERAL(struct lttng_ust_type_float, { \
+               .parent = {                                             \
+                       .type = lttng_ust_type_float,                   \
+               },                                                      \
+               .struct_size = sizeof(struct lttng_ust_type_float),     \
+               .exp_dig = sizeof(_type) * CHAR_BIT                     \
+                       - _float_mant_dig(_type),                       \
+               .mant_dig = _float_mant_dig(_type),                     \
+               .alignment = lttng_alignof(_type) * CHAR_BIT,           \
+               .reverse_byte_order = BYTE_ORDER != FLOAT_WORD_ORDER,   \
+       }))
+
+
+struct lttng_ust_type_string {
+       struct lttng_ust_type_common parent;
+       uint32_t struct_size;
+       enum lttng_ust_string_encoding encoding;
 };
 
-#define LTTNG_UST_TYPE_PADDING 128
-struct lttng_type {
-       enum lttng_abstract_types atype;
-       union {
-               /* provider ABI 2.0 */
-               struct lttng_integer_type integer;
-               struct lttng_float_type _float;
-               struct {
-                       enum lttng_string_encodings encoding;
-               } string;
-               struct {
-                       const struct lttng_ust_enum_desc *desc; /* Enumeration mapping */
-                       struct lttng_type *container_type;
-               } enum_nestable;
-               struct {
-                       const struct lttng_type *elem_type;
-                       unsigned int length;                    /* Num. elems. */
-                       unsigned int alignment;
-               } array_nestable;
-               struct {
-                       const char *length_name;                /* Length field name. */
-                       const struct lttng_type *elem_type;
-                       unsigned int alignment;                 /* Alignment before elements. */
-               } sequence_nestable;
-               struct {
-                       unsigned int nr_fields;
-                       const struct lttng_ust_event_field **fields; /* Array of pointers to fields. */
-                       unsigned int alignment;
-               } struct_nestable;
-
-               char padding[LTTNG_UST_TYPE_PADDING];
-       } u;
+struct lttng_ust_type_enum {
+       struct lttng_ust_type_common parent;
+       uint32_t struct_size;
+       struct lttng_ust_enum_desc *desc;       /* Enumeration mapping */
+       struct lttng_ust_type_common *container_type;
+};
+
+struct lttng_ust_type_array {
+       struct lttng_ust_type_common parent;
+       uint32_t struct_size;
+       struct lttng_ust_type_common *elem_type;
+       unsigned int length;                    /* Num. elems. */
+       unsigned int alignment;
+       enum lttng_ust_string_encoding encoding;
+};
+
+struct lttng_ust_type_sequence {
+       struct lttng_ust_type_common parent;
+       uint32_t struct_size;
+       const char *length_name;        /* Length field name. */
+       struct lttng_ust_type_common *elem_type;
+       unsigned int alignment;         /* Alignment before elements. */
+       enum lttng_ust_string_encoding encoding;
+};
+
+struct lttng_ust_type_struct {
+       struct lttng_ust_type_common parent;
+       uint32_t struct_size;
+       unsigned int nr_fields;
+       struct lttng_ust_event_field **fields;  /* Array of pointers to fields. */
+       unsigned int alignment;
 };
 
 /*
@@ -212,7 +220,7 @@ struct lttng_ust_enum_desc {
        uint32_t struct_size;
 
        const char *name;
-       const struct lttng_ust_enum_entry **entries;
+       struct lttng_ust_enum_entry **entries;
        unsigned int nr_entries;
 
        /* End of base ABI. Fields below should be used after checking struct_size. */
@@ -234,7 +242,7 @@ struct lttng_ust_event_field {
        uint32_t struct_size;
 
        const char *name;
-       struct lttng_type type;
+       struct lttng_ust_type_common *type;
        unsigned int nowrite:1,         /* do not write into trace */
                nofilter:1;             /* do not consider for filter */
 
@@ -256,8 +264,8 @@ struct lttng_ust_event_desc {
 
        const char *name;
        void (*probe_callback)(void);
-       const struct lttng_event_ctx *ctx;      /* context */
-       const struct lttng_ust_event_field **fields;    /* event payload */
+       struct lttng_event_ctx *ctx;            /* context */
+       struct lttng_ust_event_field **fields;  /* event payload */
        unsigned int nr_fields;
        const int **loglevel;
        const char *signature;                  /* Argument types/names received */
@@ -279,7 +287,7 @@ struct lttng_ust_probe_desc {
        uint32_t struct_size;                   /* Size of this structure. */
 
        const char *provider;
-       const struct lttng_ust_event_desc **event_desc;
+       struct lttng_ust_event_desc **event_desc;
        unsigned int nr_events;
        struct cds_list_head head;              /* chain registered probes */
        struct cds_list_head lazy_init_head;
@@ -484,7 +492,7 @@ struct lttng_channel {
        struct lttng_ust_session *session;
        int objd;                       /* Object associated to channel */
        struct cds_list_head node;      /* Channel list in session */
-       const struct lttng_ust_channel_ops *ops;
+       struct lttng_ust_channel_ops *ops;
        int header_type;                /* 0: unset, 1: compact, 2: large */
        struct lttng_ust_shm_handle *handle;    /* shared-memory handle */
 
index c4e4f1ed5c655bc49daee568010c957565875cbd..5d84e0b26bb99d17aef99dd1c8ce711c223c455c 100644 (file)
@@ -203,7 +203,7 @@ void __event_template_proto___##_provider##___##_name(_TP_ARGS_DATA_PROTO(_args)
 
 #undef TRACEPOINT_ENUM
 #define TRACEPOINT_ENUM(_provider, _name, _values)                     \
-       const struct lttng_ust_enum_entry *__enum_values__##_provider##_##_name[] = { \
+       struct lttng_ust_enum_entry *__enum_values__##_provider##_##_name[] = { \
                _values                                                 \
                ctf_enum_value("", 0)   /* Dummy, 0-len array forbidden by C99. */ \
        };
@@ -254,20 +254,20 @@ void __event_template_proto___##_provider##___##_name(_TP_ARGS_DATA_PROTO(_args)
 
 #undef _ctf_integer_ext
 #define _ctf_integer_ext(_type, _item, _src, _byte_order, _base, _nowrite) \
-       __LTTNG_COMPOUND_LITERAL(struct lttng_ust_event_field, {        \
+       __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), \
+               .type = lttng_ust_type_integer_define(_type, _byte_order, _base), \
                .nowrite = _nowrite,                            \
                .nofilter = 0,                                  \
        }),
 
 #undef _ctf_float
 #define _ctf_float(_type, _item, _src, _nowrite)               \
-       __LTTNG_COMPOUND_LITERAL(struct lttng_ust_event_field, {        \
+       __LTTNG_COMPOUND_LITERAL(struct lttng_ust_event_field, { \
                .struct_size = sizeof(struct lttng_ust_event_field), \
                .name = #_item,                                 \
-               .type = __type_float(_type),                    \
+               .type = lttng_ust_type_float_define(_type),     \
                .nowrite = _nowrite,                            \
                .nofilter = 0,                                  \
        }),
@@ -276,20 +276,19 @@ void __event_template_proto___##_provider##___##_name(_TP_ARGS_DATA_PROTO(_args)
 #define _ctf_array_encoded(_type, _item, _src, _byte_order,    \
                        _length, _encoding, _nowrite,           \
                        _elem_type_base)                        \
-       __LTTNG_COMPOUND_LITERAL(struct lttng_ust_event_field, {        \
+       __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,         \
-                               }                               \
-                       }                                       \
-               },                                              \
+               .type = (struct lttng_ust_type_common *) __LTTNG_COMPOUND_LITERAL(struct lttng_ust_type_array, { \
+                       .parent = {                             \
+                               .type = lttng_ust_type_array,   \
+                       },                                      \
+                       .struct_size = sizeof(struct lttng_ust_type_array), \
+                       .elem_type = lttng_ust_type_integer_define(_type, _byte_order, _elem_type_base), \
+                       .length = _length,                      \
+                       .alignment = 0,                         \
+                       .encoding = lttng_ust_string_encoding_##_encoding, \
+               }),                                             \
                .nowrite = _nowrite,                            \
                .nofilter = 0,                                  \
        }),
@@ -298,61 +297,59 @@ void __event_template_proto___##_provider##___##_name(_TP_ARGS_DATA_PROTO(_args)
 #define _ctf_sequence_encoded(_type, _item, _src, _byte_order, \
                        _length_type, _src_length, _encoding, _nowrite, \
                        _elem_type_base)                        \
-       __LTTNG_COMPOUND_LITERAL(struct lttng_ust_event_field, {        \
+       __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), \
+               .type = lttng_ust_type_integer_define(_length_type, BYTE_ORDER, 10), \
                .nowrite = _nowrite,                            \
                .nofilter = 1,                                  \
        }),                                                     \
-       __LTTNG_COMPOUND_LITERAL(struct lttng_ust_event_field, {        \
+       __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,         \
-                               },                              \
+               .type = (struct lttng_ust_type_common *) __LTTNG_COMPOUND_LITERAL(struct lttng_ust_type_sequence, { \
+                       .parent = {                             \
+                               .type = lttng_ust_type_sequence, \
                        },                                      \
-               },                                              \
+                       .struct_size = sizeof(struct lttng_ust_type_sequence), \
+                       .length_name = "_" #_item "_length",    \
+                       .elem_type = lttng_ust_type_integer_define(_type, _byte_order, _elem_type_base), \
+                       .alignment = 0,                         \
+                       .encoding = lttng_ust_string_encoding_##_encoding, \
+               }),                                             \
                .nowrite = _nowrite,                            \
                .nofilter = 0,                                  \
        }),
 
 #undef _ctf_string
 #define _ctf_string(_item, _src, _nowrite)                     \
-       __LTTNG_COMPOUND_LITERAL(struct lttng_ust_event_field, {        \
+       __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 } \
+               .type = (struct lttng_ust_type_common *) __LTTNG_COMPOUND_LITERAL(struct lttng_ust_type_string, { \
+                       .parent = {                             \
+                               .type = lttng_ust_type_string,  \
                        },                                      \
-               },                                              \
+                       .struct_size = sizeof(struct lttng_ust_type_string), \
+                       .encoding = lttng_ust_string_encoding_UTF8, \
+               }),                                             \
                .nowrite = _nowrite,                            \
                .nofilter = 0,                                  \
        }),
 
 #undef _ctf_enum
 #define _ctf_enum(_provider, _name, _type, _item, _src, _nowrite) \
-       __LTTNG_COMPOUND_LITERAL(struct lttng_ust_event_field, {        \
+       __LTTNG_COMPOUND_LITERAL(struct lttng_ust_event_field, { \
                .struct_size = sizeof(struct lttng_ust_event_field), \
                .name = #_item,                                 \
-               .type = {                                       \
-                       .atype = atype_enum_nestable,           \
-                       .u = {                                  \
-                               .enum_nestable = {              \
-                                       .desc = &__enum_##_provider##_##_name, \
-                                       .container_type = __LTTNG_COMPOUND_LITERAL(struct lttng_type, \
-                                                               __type_integer(_type, BYTE_ORDER, 10, none)), \
-                               },                              \
+               .type = (struct lttng_ust_type_common *) __LTTNG_COMPOUND_LITERAL(struct lttng_ust_type_enum, { \
+                       .parent = {                             \
+                               .type = lttng_ust_type_enum,    \
                        },                                      \
-               },                                              \
+                       .struct_size = sizeof(struct lttng_ust_type_enum), \
+                       .desc = &__enum_##_provider##_##_name, \
+                       .container_type = lttng_ust_type_integer_define(_type, BYTE_ORDER, 10), \
+               }),                                             \
                .nowrite = _nowrite,                            \
                .nofilter = 0,                                  \
        }),
@@ -362,15 +359,15 @@ void __event_template_proto___##_provider##___##_name(_TP_ARGS_DATA_PROTO(_args)
 
 #undef _TRACEPOINT_EVENT_CLASS
 #define _TRACEPOINT_EVENT_CLASS(_provider, _name, _args, _fields)                           \
-       static const struct lttng_ust_event_field *__event_fields___##_provider##___##_name[] = { \
+       static struct lttng_ust_event_field *__event_fields___##_provider##___##_name[] = { \
                _fields                                                                      \
                ctf_integer(int, dummy, 0)      /* Dummy, C99 forbids 0-len array. */        \
        };
 
 #undef TRACEPOINT_ENUM
 #define TRACEPOINT_ENUM(_provider, _name, _values)                                     \
-       static const struct lttng_ust_enum_desc __enum_##_provider##_##_name = {                \
-               .struct_size = sizeof(struct lttng_ust_enum_desc),                              \
+       static struct lttng_ust_enum_desc __enum_##_provider##_##_name = {              \
+               .struct_size = sizeof(struct lttng_ust_enum_desc),                      \
                .name = #_provider "_" #_name,                                          \
                .entries = __enum_values__##_provider##_##_name,                        \
                .nr_entries = _TP_ARRAY_SIZE(__enum_values__##_provider##_##_name) - 1, \
@@ -992,7 +989,7 @@ static const int *                                                         \
 static const char *                                                           \
        __ref_model_emf_uri___##_provider##___##_name                          \
        __attribute__((weakref ("_model_emf_uri___" #_provider "___" #_name)));\
-static const struct lttng_ust_event_desc __event_desc___##_provider##_##_name = { \
+static struct lttng_ust_event_desc __event_desc___##_provider##_##_name = {    \
        .struct_size = sizeof(struct lttng_ust_event_desc),                    \
        .name = #_provider ":" #_name,                                         \
        .probe_callback = (void (*)(void)) &__event_probe__##_provider##___##_template, \
@@ -1019,7 +1016,7 @@ static const struct lttng_ust_event_desc __event_desc___##_provider##_##_name =
 #define _TRACEPOINT_EVENT_INSTANCE(_provider, _template, _name, _args)        \
        &__event_desc___##_provider##_##_name,
 
-static const struct lttng_ust_event_desc *_TP_COMBINE_TOKENS(__event_desc___, TRACEPOINT_PROVIDER)[] = {
+static struct lttng_ust_event_desc *_TP_COMBINE_TOKENS(__event_desc___, TRACEPOINT_PROVIDER)[] = {
 #include TRACEPOINT_INCLUDE
        NULL,   /* Dummy, C99 forbids 0-len array. */
 };
index da4adc2fe6448cd7cb7e2f07e3d66648947c36ab..39496921fc8ed8832a97e188d0fb0aecdeb7cc41 100644 (file)
@@ -292,7 +292,7 @@ int ustcomm_register_event(int sock,
        int loglevel,
        const char *signature,          /* event signature (input) */
        size_t nr_fields,               /* fields */
-       const struct lttng_ust_event_field **fields,
+       struct lttng_ust_event_field **fields,
        const char *model_emf_uri,
        uint32_t *id);                  /* event id (output) */
 
@@ -305,7 +305,7 @@ int ustcomm_register_enum(int sock,
        int session_objd,               /* session descriptor */
        const char *enum_name,          /* enum name (input) */
        size_t nr_entries,              /* entries */
-       const struct lttng_ust_enum_entry **entries,
+       struct lttng_ust_enum_entry **entries,
        uint64_t *id);                  /* enum id (output) */
 
 /*
index e62950e1e81c7b9b7d7b77e9a62eb3ca7dd60356..637bc0c2a29329a93a6d6b5b9b09ef2fd20eab44 100644 (file)
@@ -61,7 +61,6 @@ struct lttng_ust_ctx_field {
        void (*get_value)(struct lttng_ust_ctx_field *field,
                         struct lttng_ust_ctx_value *value);
        void (*destroy)(struct lttng_ust_ctx_field *field);
-       char *field_name;       /* Has ownership, dynamically allocated. */
 
        /* End of base ABI. Fields below should be used after checking struct_size. */
 };
index cb628ad8a9e90b7b9ddfc9a178800de5e0f6fe49..80a80d0995cdbe3d6e2f83b32e743043ac2055f1 100644 (file)
@@ -27,12 +27,12 @@ enum lttng_ust_dynamic_type {
 
 __attribute__((visibility("hidden")))
 int lttng_ust_dynamic_type_choices(size_t *nr_choices,
-               const struct lttng_ust_event_field ***choices);
+               struct lttng_ust_event_field ***choices);
 
 __attribute__((visibility("hidden")))
-const struct lttng_ust_event_field *lttng_ust_dynamic_type_field(int64_t value);
+struct lttng_ust_event_field *lttng_ust_dynamic_type_field(int64_t value);
 
 __attribute__((visibility("hidden")))
-const struct lttng_ust_event_field *lttng_ust_dynamic_type_tag_field(void);
+struct lttng_ust_event_field *lttng_ust_dynamic_type_tag_field(void);
 
 #endif /* _LTTNG_UST_DYNAMIC_TYPE_H */
index e02aaeb63c99d34a85985aca15702969da1d8067..8e17e41726f60f499d81cc3ad6a0cdb2149cf438 100644 (file)
 
 static
 ssize_t count_fields_recursive(size_t nr_fields,
-               const struct lttng_ust_event_field **lttng_fields);
+               struct lttng_ust_event_field **lttng_fields);
 static
 int serialize_one_field(struct lttng_ust_session *session,
                struct ustctl_field *fields, size_t *iter_output,
-               const struct lttng_ust_event_field *lf);
+               struct lttng_ust_event_field *lf);
 static
 int serialize_fields(struct lttng_ust_session *session,
                struct ustctl_field *ustctl_fields,
                size_t *iter_output, size_t nr_lttng_fields,
-               const struct lttng_ust_event_field **lttng_fields);
+               struct lttng_ust_event_field **lttng_fields);
 
 /*
  * Human readable error message.
@@ -865,26 +865,26 @@ int ustcomm_send_reg_msg(int sock,
 }
 
 static
-ssize_t count_one_type(const struct lttng_type *lt)
+ssize_t count_one_type(struct lttng_ust_type_common *lt)
 {
-       switch (lt->atype) {
-       case atype_integer:
-       case atype_float:
-       case atype_string:
+       switch (lt->type) {
+       case lttng_ust_type_integer:
+       case lttng_ust_type_float:
+       case lttng_ust_type_string:
                return 1;
-       case atype_enum_nestable:
-               return count_one_type(lt->u.enum_nestable.container_type) + 1;
-       case atype_array_nestable:
-               return count_one_type(lt->u.array_nestable.elem_type) + 1;
-       case atype_sequence_nestable:
-               return count_one_type(lt->u.sequence_nestable.elem_type) + 1;
-       case atype_struct_nestable:
-               return count_fields_recursive(lt->u.struct_nestable.nr_fields,
-                               lt->u.struct_nestable.fields) + 1;
-
-       case atype_dynamic:
+       case lttng_ust_type_enum:
+               return count_one_type(lttng_ust_get_type_enum(lt)->container_type) + 1;
+       case lttng_ust_type_array:
+               return count_one_type(lttng_ust_get_type_array(lt)->elem_type) + 1;
+       case lttng_ust_type_sequence:
+               return count_one_type(lttng_ust_get_type_sequence(lt)->elem_type) + 1;
+       case lttng_ust_type_struct:
+               return count_fields_recursive(lttng_ust_get_type_struct(lt)->nr_fields,
+                               lttng_ust_get_type_struct(lt)->fields) + 1;
+
+       case lttng_ust_type_dynamic:
        {
-               const struct lttng_ust_event_field **choices;
+               struct lttng_ust_event_field **choices;
                size_t nr_choices;
                int ret;
 
@@ -907,7 +907,7 @@ ssize_t count_one_type(const struct lttng_type *lt)
 
 static
 ssize_t count_fields_recursive(size_t nr_fields,
-               const struct lttng_ust_event_field **lttng_fields)
+               struct lttng_ust_event_field **lttng_fields)
 {
        int i;
        ssize_t ret, count = 0;
@@ -919,7 +919,7 @@ ssize_t count_fields_recursive(size_t nr_fields,
                /* skip 'nowrite' fields */
                if (lf->nowrite)
                        continue;
-               ret = count_one_type(&lf->type);
+               ret = count_one_type(lf->type);
                if (ret < 0)
                        return ret;     /* error */
                count += ret;
@@ -941,7 +941,7 @@ ssize_t count_ctx_fields_recursive(size_t nr_fields,
                /* skip 'nowrite' fields */
                if (lf->nowrite)
                        continue;
-               ret = count_one_type(&lf->type);
+               ret = count_one_type(lf->type);
                if (ret < 0)
                        return ret;     /* error */
                count += ret;
@@ -951,16 +951,16 @@ ssize_t count_ctx_fields_recursive(size_t nr_fields,
 
 static
 int serialize_string_encoding(int32_t *ue,
-               enum lttng_string_encodings le)
+               enum lttng_ust_string_encoding le)
 {
        switch (le) {
-       case lttng_encode_none:
+       case lttng_ust_string_encoding_none:
                *ue = ustctl_encode_none;
                break;
-       case lttng_encode_UTF8:
+       case lttng_ust_string_encoding_UTF8:
                *ue = ustctl_encode_UTF8;
                break;
-       case lttng_encode_ASCII:
+       case lttng_ust_string_encoding_ASCII:
                *ue = ustctl_encode_ASCII;
                break;
        default:
@@ -971,7 +971,8 @@ int serialize_string_encoding(int32_t *ue,
 
 static
 int serialize_integer_type(struct ustctl_integer_type *uit,
-               const struct lttng_integer_type *lit)
+               const struct lttng_ust_type_integer *lit,
+               enum lttng_ust_string_encoding lencoding)
 {
        int32_t encoding;
 
@@ -979,7 +980,7 @@ int serialize_integer_type(struct ustctl_integer_type *uit,
        uit->signedness = lit->signedness;
        uit->reverse_byte_order = lit->reverse_byte_order;
        uit->base = lit->base;
-       if (serialize_string_encoding(&encoding, lit->encoding))
+       if (serialize_string_encoding(&encoding, lencoding))
                return -EINVAL;
        uit->encoding = encoding;
        uit->alignment = lit->alignment;
@@ -991,10 +992,10 @@ int serialize_dynamic_type(struct lttng_ust_session *session,
                struct ustctl_field *fields, size_t *iter_output,
                const char *field_name)
 {
-       const struct lttng_ust_event_field **choices;
+       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_ust_event_field *tag_field_generic;
+       struct lttng_ust_type_common *tag_type;
+       struct lttng_ust_event_field *tag_field_generic;
        struct lttng_ust_event_field tag_field = {
                .name = tag_field_name,
                .nowrite = 0,
@@ -1004,7 +1005,7 @@ int serialize_dynamic_type(struct lttng_ust_session *session,
        int ret;
 
        tag_field_generic = lttng_ust_dynamic_type_tag_field();
-       tag_type = &tag_field_generic->type;
+       tag_type = tag_field_generic->type;
 
        /* Serialize enum field. */
        strncpy(tag_field_name, field_name, LTTNG_UST_ABI_SYM_NAME_LEN);
@@ -1012,7 +1013,7 @@ int serialize_dynamic_type(struct lttng_ust_session *session,
        strncat(tag_field_name,
                "_tag",
                LTTNG_UST_ABI_SYM_NAME_LEN - strlen(tag_field_name) - 1);
-       tag_field.type = *tag_type;
+       tag_field.type = tag_type;
        ret = serialize_one_field(session, fields, iter_output,
                &tag_field);
        if (ret)
@@ -1048,7 +1049,8 @@ int serialize_dynamic_type(struct lttng_ust_session *session,
 static
 int serialize_one_type(struct lttng_ust_session *session,
                struct ustctl_field *fields, size_t *iter_output,
-               const char *field_name, const struct lttng_type *lt)
+               const char *field_name, struct lttng_ust_type_common *lt,
+               enum lttng_ust_string_encoding parent_encoding)
 {
        int ret;
 
@@ -1057,8 +1059,8 @@ int serialize_one_type(struct lttng_ust_session *session,
         * entry with 0-length name.
         */
 
-       switch (lt->atype) {
-       case atype_integer:
+       switch (lt->type) {
+       case lttng_ust_type_integer:
        {
                struct ustctl_field *uf = &fields[*iter_output];
                struct ustctl_type *ut = &uf->type;
@@ -1069,19 +1071,20 @@ int serialize_one_type(struct lttng_ust_session *session,
                } else {
                        uf->name[0] = '\0';
                }
-               ret = serialize_integer_type(&ut->u.integer, &lt->u.integer);
+               ret = serialize_integer_type(&ut->u.integer, lttng_ust_get_type_integer(lt),
+                               parent_encoding);
                if (ret)
                        return ret;
                ut->atype = ustctl_atype_integer;
                (*iter_output)++;
                break;
        }
-       case atype_float:
+       case lttng_ust_type_float:
        {
                struct ustctl_field *uf = &fields[*iter_output];
                struct ustctl_type *ut = &uf->type;
                struct ustctl_float_type *uft;
-               const struct lttng_float_type *lft;
+               struct lttng_ust_type_float *lft;
 
                if (field_name) {
                        strncpy(uf->name, field_name, LTTNG_UST_ABI_SYM_NAME_LEN);
@@ -1090,7 +1093,7 @@ int serialize_one_type(struct lttng_ust_session *session,
                        uf->name[0] = '\0';
                }
                uft = &ut->u._float;
-               lft = &lt->u._float;
+               lft = lttng_ust_get_type_float(lt);
                uft->exp_dig = lft->exp_dig;
                uft->mant_dig = lft->mant_dig;
                uft->alignment = lft->alignment;
@@ -1099,7 +1102,7 @@ int serialize_one_type(struct lttng_ust_session *session,
                (*iter_output)++;
                break;
        }
-       case atype_string:
+       case lttng_ust_type_string:
        {
                struct ustctl_field *uf = &fields[*iter_output];
                struct ustctl_type *ut = &uf->type;
@@ -1111,7 +1114,7 @@ int serialize_one_type(struct lttng_ust_session *session,
                } else {
                        uf->name[0] = '\0';
                }
-               ret = serialize_string_encoding(&encoding, lt->u.string.encoding);
+               ret = serialize_string_encoding(&encoding, lttng_ust_get_type_string(lt)->encoding);
                if (ret)
                        return ret;
                ut->u.string.encoding = encoding;
@@ -1119,7 +1122,7 @@ int serialize_one_type(struct lttng_ust_session *session,
                (*iter_output)++;
                break;
        }
-       case atype_array_nestable:
+       case lttng_ust_type_array:
        {
                struct ustctl_field *uf = &fields[*iter_output];
                struct ustctl_type *ut = &uf->type;
@@ -1131,17 +1134,18 @@ int serialize_one_type(struct lttng_ust_session *session,
                        uf->name[0] = '\0';
                }
                ut->atype = ustctl_atype_array_nestable;
-               ut->u.array_nestable.length = lt->u.array_nestable.length;
-               ut->u.array_nestable.alignment = lt->u.array_nestable.alignment;
+               ut->u.array_nestable.length = lttng_ust_get_type_array(lt)->length;
+               ut->u.array_nestable.alignment = lttng_ust_get_type_array(lt)->alignment;
                (*iter_output)++;
 
                ret = serialize_one_type(session, fields, iter_output, NULL,
-                               lt->u.array_nestable.elem_type);
+                               lttng_ust_get_type_array(lt)->elem_type,
+                               lttng_ust_get_type_array(lt)->encoding);
                if (ret)
                        return -EINVAL;
                break;
        }
-       case atype_sequence_nestable:
+       case lttng_ust_type_sequence:
        {
                struct ustctl_field *uf = &fields[*iter_output];
                struct ustctl_type *ut = &uf->type;
@@ -1154,19 +1158,20 @@ int serialize_one_type(struct lttng_ust_session *session,
                }
                ut->atype = ustctl_atype_sequence_nestable;
                strncpy(ut->u.sequence_nestable.length_name,
-                       lt->u.sequence_nestable.length_name,
+                       lttng_ust_get_type_sequence(lt)->length_name,
                        LTTNG_UST_ABI_SYM_NAME_LEN);
                ut->u.sequence_nestable.length_name[LTTNG_UST_ABI_SYM_NAME_LEN - 1] = '\0';
-               ut->u.sequence_nestable.alignment = lt->u.sequence_nestable.alignment;
+               ut->u.sequence_nestable.alignment = lttng_ust_get_type_sequence(lt)->alignment;
                (*iter_output)++;
 
                ret = serialize_one_type(session, fields, iter_output, NULL,
-                               lt->u.sequence_nestable.elem_type);
+                               lttng_ust_get_type_sequence(lt)->elem_type,
+                               lttng_ust_get_type_sequence(lt)->encoding);
                if (ret)
                        return -EINVAL;
                break;
        }
-       case atype_dynamic:
+       case lttng_ust_type_dynamic:
        {
                ret = serialize_dynamic_type(session, fields, iter_output,
                                field_name);
@@ -1174,7 +1179,7 @@ int serialize_one_type(struct lttng_ust_session *session,
                        return -EINVAL;
                break;
        }
-       case atype_struct_nestable:
+       case lttng_ust_type_struct:
        {
                struct ustctl_field *uf = &fields[*iter_output];
 
@@ -1185,18 +1190,18 @@ int serialize_one_type(struct lttng_ust_session *session,
                        uf->name[0] = '\0';
                }
                uf->type.atype = ustctl_atype_struct_nestable;
-               uf->type.u.struct_nestable.nr_fields = lt->u.struct_nestable.nr_fields;
-               uf->type.u.struct_nestable.alignment = lt->u.struct_nestable.alignment;
+               uf->type.u.struct_nestable.nr_fields = lttng_ust_get_type_struct(lt)->nr_fields;
+               uf->type.u.struct_nestable.alignment = lttng_ust_get_type_struct(lt)->alignment;
                (*iter_output)++;
 
                ret = serialize_fields(session, fields, iter_output,
-                               lt->u.struct_nestable.nr_fields,
-                               lt->u.struct_nestable.fields);
+                               lttng_ust_get_type_struct(lt)->nr_fields,
+                               lttng_ust_get_type_struct(lt)->fields);
                if (ret)
                        return -EINVAL;
                break;
        }
-       case atype_enum_nestable:
+       case lttng_ust_type_enum:
        {
                struct ustctl_field *uf = &fields[*iter_output];
                struct ustctl_type *ut = &uf->type;
@@ -1207,20 +1212,21 @@ int serialize_one_type(struct lttng_ust_session *session,
                } else {
                        uf->name[0] = '\0';
                }
-               strncpy(ut->u.enum_nestable.name, lt->u.enum_nestable.desc->name,
+               strncpy(ut->u.enum_nestable.name, lttng_ust_get_type_enum(lt)->desc->name,
                                LTTNG_UST_ABI_SYM_NAME_LEN);
                ut->u.enum_nestable.name[LTTNG_UST_ABI_SYM_NAME_LEN - 1] = '\0';
                ut->atype = ustctl_atype_enum_nestable;
                (*iter_output)++;
 
                ret = serialize_one_type(session, fields, iter_output, NULL,
-                               lt->u.enum_nestable.container_type);
+                               lttng_ust_get_type_enum(lt)->container_type,
+                               lttng_ust_string_encoding_none);
                if (ret)
                        return -EINVAL;
                if (session) {
                        const struct lttng_enum *_enum;
 
-                       _enum = lttng_ust_enum_get_from_desc(session, lt->u.enum_nestable.desc);
+                       _enum = lttng_ust_enum_get_from_desc(session, lttng_ust_get_type_enum(lt)->desc);
                        if (!_enum)
                                return -EINVAL;
                        ut->u.enum_nestable.id = _enum->id;
@@ -1238,20 +1244,20 @@ int serialize_one_type(struct lttng_ust_session *session,
 static
 int serialize_one_field(struct lttng_ust_session *session,
                struct ustctl_field *fields, size_t *iter_output,
-               const struct lttng_ust_event_field *lf)
+               struct lttng_ust_event_field *lf)
 {
        /* skip 'nowrite' fields */
        if (lf->nowrite)
                return 0;
 
-       return serialize_one_type(session, fields, iter_output, lf->name, &lf->type);
+       return serialize_one_type(session, fields, iter_output, lf->name, lf->type, lttng_ust_string_encoding_none);
 }
 
 static
 int serialize_fields(struct lttng_ust_session *session,
                struct ustctl_field *ustctl_fields,
                size_t *iter_output, size_t nr_lttng_fields,
-               const struct lttng_ust_event_field **lttng_fields)
+               struct lttng_ust_event_field **lttng_fields)
 {
        int ret;
        size_t i;
@@ -1270,7 +1276,7 @@ int alloc_serialize_fields(struct lttng_ust_session *session,
                size_t *_nr_write_fields,
                struct ustctl_field **ustctl_fields,
                size_t nr_fields,
-               const struct lttng_ust_event_field **lttng_fields)
+               struct lttng_ust_event_field **lttng_fields)
 {
        struct ustctl_field *fields;
        int ret;
@@ -1303,7 +1309,7 @@ error_type:
 static
 int serialize_entries(struct ustctl_enum_entry **_entries,
                size_t nr_entries,
-               const struct lttng_ust_enum_entry **lttng_entries)
+               struct lttng_ust_enum_entry **lttng_entries)
 {
        struct ustctl_enum_entry *entries;
        int i;
@@ -1384,7 +1390,7 @@ int ustcomm_register_event(int sock,
        int loglevel,
        const char *signature,          /* event signature (input) */
        size_t nr_fields,               /* fields */
-       const struct lttng_ust_event_field **lttng_fields,
+       struct lttng_ust_event_field **lttng_fields,
        const char *model_emf_uri,
        uint32_t *id)                   /* event id (output) */
 {
@@ -1523,7 +1529,7 @@ int ustcomm_register_enum(int sock,
        int session_objd,               /* session descriptor */
        const char *enum_name,          /* enum name (input) */
        size_t nr_entries,              /* entries */
-       const struct lttng_ust_enum_entry **lttng_entries,
+       struct lttng_ust_enum_entry **lttng_entries,
        uint64_t *id)
 {
        ssize_t len;
index eb3c0bce1da35436cec17a21bb72f470349195d8..199e615b15fe0e065d375b3a9991a0ba0c79fe0f 100644 (file)
@@ -60,11 +60,11 @@ void capture_enum(struct lttng_msgpack_writer *writer,
 
 static
 int64_t capture_sequence_element_signed(uint8_t *ptr,
-               const struct lttng_integer_type *type)
+               struct lttng_ust_type_integer *integer_type)
 {
        int64_t value;
-       unsigned int size = type->size;
-       bool byte_order_reversed = type->reverse_byte_order;
+       unsigned int size = integer_type->size;
+       bool byte_order_reversed = integer_type->reverse_byte_order;
 
        switch (size) {
        case 8:
@@ -109,11 +109,11 @@ int64_t capture_sequence_element_signed(uint8_t *ptr,
 
 static
 uint64_t capture_sequence_element_unsigned(uint8_t *ptr,
-               const struct lttng_integer_type *type)
+               struct lttng_ust_type_integer *integer_type)
 {
        uint64_t value;
-       unsigned int size = type->size;
-       bool byte_order_reversed = type->reverse_byte_order;
+       unsigned int size = integer_type->size;
+       bool byte_order_reversed = integer_type->reverse_byte_order;
 
        switch (size) {
        case 8:
@@ -160,8 +160,8 @@ static
 void capture_sequence(struct lttng_msgpack_writer *writer,
                struct lttng_interpreter_output *output)
 {
-       const struct lttng_integer_type *integer_type;
-       const struct lttng_type *nested_type;
+       struct lttng_ust_type_integer *integer_type;
+       struct lttng_ust_type_common *nested_type;
        uint8_t *ptr;
        bool signedness;
        int i;
@@ -170,13 +170,13 @@ void capture_sequence(struct lttng_msgpack_writer *writer,
 
        ptr = (uint8_t *) output->u.sequence.ptr;
        nested_type = output->u.sequence.nested_type;
-       switch (nested_type->atype) {
-       case atype_integer:
-               integer_type = &nested_type->u.integer;
+       switch (nested_type->type) {
+       case lttng_ust_type_integer:
+               integer_type = lttng_ust_get_type_integer(nested_type);
                break;
-       case atype_enum_nestable:
+       case lttng_ust_type_enum:
                /* Treat enumeration as an integer. */
-               integer_type = &nested_type->u.enum_nestable.container_type->u.integer;
+               integer_type = lttng_ust_get_type_integer(lttng_ust_get_type_enum(nested_type)->container_type);
                break;
        default:
                /* Capture of array of non-integer are not supported. */
index 947da3eede2d8f86293781c1e74132c50f4079ec..765955fd8dbb4dd918382bfe904600cde0b7ab13 100644 (file)
@@ -231,10 +231,10 @@ static int context_get_index(struct lttng_ust_ctx *ctx,
        ptr->type = LOAD_OBJECT;
        ptr->field = field;
 
-       switch (field->type.atype) {
-       case atype_integer:
+       switch (field->type->type) {
+       case lttng_ust_type_integer:
                ctx_field->get_value(ctx_field, &v);
-               if (field->type.u.integer.signedness) {
+               if (lttng_ust_get_type_integer(field->type)->signedness) {
                        ptr->object_type = OBJECT_TYPE_S64;
                        ptr->u.s64 = v.u.s64;
                        ptr->ptr = &ptr->u.s64;
@@ -244,11 +244,11 @@ static int context_get_index(struct lttng_ust_ctx *ctx,
                        ptr->ptr = &ptr->u.u64;
                }
                break;
-       case atype_enum_nestable:
+       case lttng_ust_type_enum:
        {
-               const struct lttng_integer_type *itype;
+               const struct lttng_ust_type_integer *itype;
 
-               itype = &field->type.u.enum_nestable.container_type->u.integer;
+               itype = lttng_ust_get_type_integer(lttng_ust_get_type_enum(field->type)->container_type);
                ctx_field->get_value(ctx_field, &v);
                if (itype->signedness) {
                        ptr->object_type = OBJECT_TYPE_SIGNED_ENUM;
@@ -261,12 +261,12 @@ static int context_get_index(struct lttng_ust_ctx *ctx,
                }
                break;
        }
-       case atype_array_nestable:
-               if (field->type.u.array_nestable.elem_type->atype != atype_integer) {
+       case lttng_ust_type_array:
+               if (lttng_ust_get_type_array(field->type)->elem_type->type != lttng_ust_type_integer) {
                        ERR("Array nesting only supports integer types.");
                        return -EINVAL;
                }
-               if (field->type.u.array_nestable.elem_type->u.integer.encoding == lttng_encode_none) {
+               if (lttng_ust_get_type_array(field->type)->encoding == lttng_ust_string_encoding_none) {
                        ERR("Only string arrays are supported for contexts.");
                        return -EINVAL;
                }
@@ -274,12 +274,12 @@ static int context_get_index(struct lttng_ust_ctx *ctx,
                ctx_field->get_value(ctx_field, &v);
                ptr->ptr = v.u.str;
                break;
-       case atype_sequence_nestable:
-               if (field->type.u.sequence_nestable.elem_type->atype != atype_integer) {
+       case lttng_ust_type_sequence:
+               if (lttng_ust_get_type_sequence(field->type)->elem_type->type != lttng_ust_type_integer) {
                        ERR("Sequence nesting only supports integer types.");
                        return -EINVAL;
                }
-               if (field->type.u.sequence_nestable.elem_type->u.integer.encoding == lttng_encode_none) {
+               if (lttng_ust_get_type_sequence(field->type)->encoding == lttng_ust_string_encoding_none) {
                        ERR("Only string sequences are supported for contexts.");
                        return -EINVAL;
                }
@@ -287,18 +287,18 @@ static int context_get_index(struct lttng_ust_ctx *ctx,
                ctx_field->get_value(ctx_field, &v);
                ptr->ptr = v.u.str;
                break;
-       case atype_string:
+       case lttng_ust_type_string:
                ptr->object_type = OBJECT_TYPE_STRING;
                ctx_field->get_value(ctx_field, &v);
                ptr->ptr = v.u.str;
                break;
-       case atype_float:
+       case lttng_ust_type_float:
                ptr->object_type = OBJECT_TYPE_DOUBLE;
                ctx_field->get_value(ctx_field, &v);
                ptr->u.d = v.u.d;
                ptr->ptr = &ptr->u.d;
                break;
-       case atype_dynamic:
+       case lttng_ust_type_dynamic:
                ctx_field->get_value(ctx_field, &v);
                switch (v.sel) {
                case LTTNG_UST_DYNAMIC_TYPE_NONE:
@@ -339,7 +339,7 @@ static int context_get_index(struct lttng_ust_ctx *ctx,
                }
                break;
        default:
-               ERR("Unknown type: %d", (int) field->type.atype);
+               ERR("Unknown type: %d", (int) field->type->type);
                return -EINVAL;
        }
        return 0;
@@ -367,7 +367,7 @@ static int dynamic_get_index(struct lttng_ust_ctx *ctx,
                        stack_top->u.ptr.ptr = ptr;
                        stack_top->u.ptr.object_type = gid->elem.type;
                        stack_top->u.ptr.rev_bo = gid->elem.rev_bo;
-                       assert(stack_top->u.ptr.field->type.atype == atype_array_nestable);
+                       assert(stack_top->u.ptr.field->type->type == lttng_ust_type_array);
                        stack_top->u.ptr.field = NULL;
                        break;
                }
@@ -386,7 +386,7 @@ static int dynamic_get_index(struct lttng_ust_ctx *ctx,
                        stack_top->u.ptr.ptr = ptr;
                        stack_top->u.ptr.object_type = gid->elem.type;
                        stack_top->u.ptr.rev_bo = gid->elem.rev_bo;
-                       assert(stack_top->u.ptr.field->type.atype == atype_sequence_nestable);
+                       assert(stack_top->u.ptr.field->type->type == lttng_ust_type_sequence);
                        stack_top->u.ptr.field = NULL;
                        break;
                }
@@ -664,14 +664,14 @@ again:
                        output->type = LTTNG_INTERPRETER_TYPE_SEQUENCE;
                        output->u.sequence.ptr = *(const char **) (ax->u.ptr.ptr + sizeof(unsigned long));
                        output->u.sequence.nr_elem = *(unsigned long *) ax->u.ptr.ptr;
-                       output->u.sequence.nested_type = ax->u.ptr.field->type.u.sequence_nestable.elem_type;
+                       output->u.sequence.nested_type = lttng_ust_get_type_sequence(ax->u.ptr.field->type)->elem_type;
                        break;
                case OBJECT_TYPE_ARRAY:
                        /* Skip count (unsigned long) */
                        output->type = LTTNG_INTERPRETER_TYPE_SEQUENCE;
                        output->u.sequence.ptr = *(const char **) (ax->u.ptr.ptr + sizeof(unsigned long));
-                       output->u.sequence.nr_elem = ax->u.ptr.field->type.u.array_nestable.length;
-                       output->u.sequence.nested_type = ax->u.ptr.field->type.u.array_nestable.elem_type;
+                       output->u.sequence.nr_elem = lttng_ust_get_type_array(ax->u.ptr.field->type)->length;
+                       output->u.sequence.nested_type = lttng_ust_get_type_array(ax->u.ptr.field->type)->elem_type;
                        break;
                case OBJECT_TYPE_SIGNED_ENUM:
                        ret = dynamic_load_field(ax);
index c546c8d6dc411688943e8804128721ef69325fc1..cb7480b3f9ccef3ac514c8b6a686dcf61a8d9dd6 100644 (file)
@@ -253,20 +253,20 @@ static int specialize_get_index(struct bytecode_runtime *runtime,
                switch (stack_top->load.object_type) {
                case OBJECT_TYPE_ARRAY:
                {
-                       const struct lttng_integer_type *integer_type;
-                       const struct lttng_ust_event_field *field;
+                       struct lttng_ust_type_integer *integer_type;
+                       struct lttng_ust_event_field *field;
                        uint32_t elem_len, num_elems;
                        int signedness;
 
                        field = stack_top->load.field;
-                       switch (field->type.atype) {
-                       case atype_array_nestable:
-                               if (field->type.u.array_nestable.elem_type->atype != atype_integer) {
+                       switch (field->type->type) {
+                       case lttng_ust_type_array:
+                               if (lttng_ust_get_type_array(field->type)->elem_type->type != lttng_ust_type_integer) {
                                        ret = -EINVAL;
                                        goto end;
                                }
-                               integer_type = &field->type.u.array_nestable.elem_type->u.integer;
-                               num_elems = field->type.u.array_nestable.length;
+                               integer_type = lttng_ust_get_type_integer(lttng_ust_get_type_array(field->type)->elem_type);
+                               num_elems = lttng_ust_get_type_array(field->type)->length;
                                break;
                        default:
                                ret = -EINVAL;
@@ -293,19 +293,19 @@ static int specialize_get_index(struct bytecode_runtime *runtime,
                }
                case OBJECT_TYPE_SEQUENCE:
                {
-                       const struct lttng_integer_type *integer_type;
-                       const struct lttng_ust_event_field *field;
+                       struct lttng_ust_type_integer *integer_type;
+                       struct lttng_ust_event_field *field;
                        uint32_t elem_len;
                        int signedness;
 
                        field = stack_top->load.field;
-                       switch (field->type.atype) {
-                       case atype_sequence_nestable:
-                               if (field->type.u.sequence_nestable.elem_type->atype != atype_integer) {
+                       switch (field->type->type) {
+                       case lttng_ust_type_sequence:
+                               if (lttng_ust_get_type_sequence(field->type)->elem_type->type != lttng_ust_type_integer) {
                                        ret = -EINVAL;
                                        goto end;
                                }
-                               integer_type = &field->type.u.sequence_nestable.elem_type->u.integer;
+                               integer_type = lttng_ust_get_type_integer(lttng_ust_get_type_sequence(field->type)->elem_type);
                                break;
                        default:
                                ret = -EINVAL;
@@ -378,24 +378,24 @@ static int specialize_context_lookup_name(struct lttng_ust_ctx *ctx,
        return lttng_get_context_index(ctx, name);
 }
 
-static int specialize_load_object(const struct lttng_ust_event_field *field,
+static int specialize_load_object(struct lttng_ust_event_field *field,
                struct vstack_load *load, bool is_context)
 {
        load->type = LOAD_OBJECT;
 
-       switch (field->type.atype) {
-       case atype_integer:
-               if (field->type.u.integer.signedness)
+       switch (field->type->type) {
+       case lttng_ust_type_integer:
+               if (lttng_ust_get_type_integer(field->type)->signedness)
                        load->object_type = OBJECT_TYPE_S64;
                else
                        load->object_type = OBJECT_TYPE_U64;
                load->rev_bo = false;
                break;
-       case atype_enum_nestable:
+       case lttng_ust_type_enum:
        {
-               const struct lttng_integer_type *itype;
+               struct lttng_ust_type_integer *itype;
 
-               itype = &field->type.u.enum_nestable.container_type->u.integer;
+               itype = lttng_ust_get_type_integer(lttng_ust_get_type_enum(field->type)->container_type);
                if (itype->signedness)
                        load->object_type = OBJECT_TYPE_SIGNED_ENUM;
                else
@@ -403,15 +403,15 @@ static int specialize_load_object(const struct lttng_ust_event_field *field,
                load->rev_bo = false;
                break;
        }
-       case atype_array_nestable:
-               if (field->type.u.array_nestable.elem_type->atype != atype_integer) {
+       case lttng_ust_type_array:
+               if (lttng_ust_get_type_array(field->type)->elem_type->type != lttng_ust_type_integer) {
                        ERR("Array nesting only supports integer types.");
                        return -EINVAL;
                }
                if (is_context) {
                        load->object_type = OBJECT_TYPE_STRING;
                } else {
-                       if (field->type.u.array_nestable.elem_type->u.integer.encoding == lttng_encode_none) {
+                       if (lttng_ust_get_type_array(field->type)->encoding == lttng_ust_string_encoding_none) {
                                load->object_type = OBJECT_TYPE_ARRAY;
                                load->field = field;
                        } else {
@@ -419,15 +419,15 @@ static int specialize_load_object(const struct lttng_ust_event_field *field,
                        }
                }
                break;
-       case atype_sequence_nestable:
-               if (field->type.u.sequence_nestable.elem_type->atype != atype_integer) {
+       case lttng_ust_type_sequence:
+               if (lttng_ust_get_type_sequence(field->type)->elem_type->type != lttng_ust_type_integer) {
                        ERR("Sequence nesting only supports integer types.");
                        return -EINVAL;
                }
                if (is_context) {
                        load->object_type = OBJECT_TYPE_STRING;
                } else {
-                       if (field->type.u.sequence_nestable.elem_type->u.integer.encoding == lttng_encode_none) {
+                       if (lttng_ust_get_type_sequence(field->type)->encoding == lttng_ust_string_encoding_none) {
                                load->object_type = OBJECT_TYPE_SEQUENCE;
                                load->field = field;
                        } else {
@@ -436,17 +436,17 @@ static int specialize_load_object(const struct lttng_ust_event_field *field,
                }
                break;
 
-       case atype_string:
+       case lttng_ust_type_string:
                load->object_type = OBJECT_TYPE_STRING;
                break;
-       case atype_float:
+       case lttng_ust_type_float:
                load->object_type = OBJECT_TYPE_DOUBLE;
                break;
-       case atype_dynamic:
+       case lttng_ust_type_dynamic:
                load->object_type = OBJECT_TYPE_DYNAMIC;
                break;
        default:
-               ERR("Unknown type: %d", (int) field->type.atype);
+               ERR("Unknown type: %d", (int) field->type->type);
                return -EINVAL;
        }
        return 0;
@@ -547,7 +547,7 @@ end:
        return ret;
 }
 
-static int specialize_payload_lookup(const struct lttng_ust_event_desc *event_desc,
+static int specialize_payload_lookup(struct lttng_ust_event_desc *event_desc,
                struct bytecode_runtime *runtime,
                struct load_op *insn,
                struct vstack_load *load)
@@ -557,7 +557,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_ust_event_field *field;
+       struct lttng_ust_event_field *field;
        int ret;
        struct bytecode_get_index_data gid;
        ssize_t data_offset;
@@ -575,20 +575,20 @@ static int specialize_payload_lookup(const struct lttng_ust_event_desc *event_de
                        break;
                }
                /* compute field offset on stack */
-               switch (field->type.atype) {
-               case atype_integer:
-               case atype_enum_nestable:
+               switch (field->type->type) {
+               case lttng_ust_type_integer:
+               case lttng_ust_type_enum:
                        field_offset += sizeof(int64_t);
                        break;
-               case atype_array_nestable:
-               case atype_sequence_nestable:
+               case lttng_ust_type_array:
+               case lttng_ust_type_sequence:
                        field_offset += sizeof(unsigned long);
                        field_offset += sizeof(void *);
                        break;
-               case atype_string:
+               case lttng_ust_type_string:
                        field_offset += sizeof(void *);
                        break;
-               case atype_float:
+               case lttng_ust_type_float:
                        field_offset += sizeof(double);
                        break;
                default:
@@ -624,7 +624,7 @@ end:
        return ret;
 }
 
-int lttng_bytecode_specialize(const struct lttng_ust_event_desc *event_desc,
+int lttng_bytecode_specialize(struct lttng_ust_event_desc *event_desc,
                struct bytecode_runtime *bytecode)
 {
        void *pc, *next_pc, *start_pc;
index f9ebc47645c2cf8d59b5b44bd296fe2b2ef0491c..d75600baee9a92e83e68cdae30a981bfd8c416f0 100644 (file)
@@ -179,7 +179,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_ust_event_field **fields, *field = NULL;
+       struct lttng_ust_event_field **fields, *field = NULL;
        unsigned int nr_fields, i;
        struct load_op *op;
        uint32_t field_offset = 0;
@@ -202,20 +202,20 @@ int apply_field_reloc(const struct lttng_ust_event_desc *event_desc,
                        break;
                }
                /* compute field offset */
-               switch (fields[i]->type.atype) {
-               case atype_integer:
-               case atype_enum_nestable:
+               switch (fields[i]->type->type) {
+               case lttng_ust_type_integer:
+               case lttng_ust_type_enum:
                        field_offset += sizeof(int64_t);
                        break;
-               case atype_array_nestable:
-               case atype_sequence_nestable:
+               case lttng_ust_type_array:
+               case lttng_ust_type_sequence:
                        field_offset += sizeof(unsigned long);
                        field_offset += sizeof(void *);
                        break;
-               case atype_string:
+               case lttng_ust_type_string:
                        field_offset += sizeof(void *);
                        break;
-               case atype_float:
+               case lttng_ust_type_float:
                        field_offset += sizeof(double);
                        break;
                default:
@@ -238,19 +238,19 @@ int apply_field_reloc(const struct lttng_ust_event_desc *event_desc,
                struct field_ref *field_ref;
 
                field_ref = (struct field_ref *) op->data;
-               switch (field->type.atype) {
-               case atype_integer:
-               case atype_enum_nestable:
+               switch (field->type->type) {
+               case lttng_ust_type_integer:
+               case lttng_ust_type_enum:
                        op->op = BYTECODE_OP_LOAD_FIELD_REF_S64;
                        break;
-               case atype_array_nestable:
-               case atype_sequence_nestable:
+               case lttng_ust_type_array:
+               case lttng_ust_type_sequence:
                        op->op = BYTECODE_OP_LOAD_FIELD_REF_SEQUENCE;
                        break;
-               case atype_string:
+               case lttng_ust_type_string:
                        op->op = BYTECODE_OP_LOAD_FIELD_REF_STRING;
                        break;
-               case atype_float:
+               case lttng_ust_type_float:
                        op->op = BYTECODE_OP_LOAD_FIELD_REF_DOUBLE;
                        break;
                default:
@@ -311,21 +311,21 @@ int apply_context_reloc(struct bytecode_runtime *runtime,
                struct field_ref *field_ref;
 
                field_ref = (struct field_ref *) op->data;
-               switch (ctx_field->event_field->type.atype) {
-               case atype_integer:
-               case atype_enum_nestable:
+               switch (ctx_field->event_field->type->type) {
+               case lttng_ust_type_integer:
+               case lttng_ust_type_enum:
                        op->op = BYTECODE_OP_GET_CONTEXT_REF_S64;
                        break;
                        /* Sequence and array supported as string */
-               case atype_string:
-               case atype_array_nestable:
-               case atype_sequence_nestable:
+               case lttng_ust_type_string:
+               case lttng_ust_type_array:
+               case lttng_ust_type_sequence:
                        op->op = BYTECODE_OP_GET_CONTEXT_REF_STRING;
                        break;
-               case atype_float:
+               case lttng_ust_type_float:
                        op->op = BYTECODE_OP_GET_CONTEXT_REF_DOUBLE;
                        break;
-               case atype_dynamic:
+               case lttng_ust_type_dynamic:
                        op->op = BYTECODE_OP_GET_CONTEXT_REF;
                        break;
                default:
@@ -396,7 +396,7 @@ int bytecode_is_linked(struct lttng_ust_bytecode_node *bytecode,
  * bytecode runtime.
  */
 static
-int link_bytecode(const struct lttng_ust_event_desc *event_desc,
+int link_bytecode(struct lttng_ust_event_desc *event_desc,
                struct lttng_ust_ctx **ctx,
                struct lttng_ust_bytecode_node *bytecode,
                struct cds_list_head *bytecode_runtime_head,
@@ -529,7 +529,7 @@ void lttng_bytecode_capture_sync_state(struct lttng_ust_bytecode_runtime *runtim
  * This function is called after we confirmed that name enabler and the
  * instance are name matching (or glob pattern matching).
  */
-void lttng_enabler_link_bytecode(const struct lttng_ust_event_desc *event_desc,
+void lttng_enabler_link_bytecode(struct lttng_ust_event_desc *event_desc,
                struct lttng_ust_ctx **ctx,
                struct cds_list_head *instance_bytecode_head,
                struct cds_list_head *enabler_bytecode_head)
index 180dfbda0934bf845d9e2f2259d0bcf7914c0996..04dd2520205e47c8e570b3c8b08e55bd286b9d72 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_ust_event_field *field;
+       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_ust_event_field *field;
+       struct lttng_ust_event_field *field;
        bool rev_bo;    /* reverse byte order */
 };
 
@@ -309,7 +309,7 @@ struct lttng_interpreter_output {
                        size_t nr_elem;
 
                        /* Inner type. */
-                       const struct lttng_type *nested_type;
+                       struct lttng_ust_type_common *nested_type;
                } sequence;
        } u;
 };
@@ -327,7 +327,7 @@ __attribute__((visibility("hidden")))
 int lttng_bytecode_validate(struct bytecode_runtime *bytecode);
 
 __attribute__((visibility("hidden")))
-int lttng_bytecode_specialize(const struct lttng_ust_event_desc *event_desc,
+int lttng_bytecode_specialize(struct lttng_ust_event_desc *event_desc,
                struct bytecode_runtime *bytecode);
 
 __attribute__((visibility("hidden")))
index 2ba495b3362032669ca8739e2c384420e92ba740..a6741fb1886c37e273dd22120d86fac7d9991c0f 100644 (file)
@@ -121,27 +121,42 @@ void cgroup_ns_get_value(struct lttng_ust_ctx_field *field,
 int lttng_add_cgroup_ns_to_ctx(struct lttng_ust_ctx **ctx)
 {
        struct lttng_ust_ctx_field *field;
-
-       field = lttng_append_context(ctx);
-       if (!field)
+       struct lttng_ust_type_common *type;
+       int ret;
+
+       type = lttng_ust_create_type_integer(sizeof(ino_t) * CHAR_BIT,
+                       lttng_alignof(ino_t) * CHAR_BIT,
+                       lttng_is_signed_type(ino_t),
+                       BYTE_ORDER, 10);
+       if (!type)
                return -ENOMEM;
+       field = lttng_append_context(ctx);
+       if (!field) {
+               ret = -ENOMEM;
+               goto error_context;
+       }
        if (lttng_find_context(*ctx, "cgroup_ns")) {
-               lttng_remove_context_field(ctx, field);
-               return -EEXIST;
+               ret = -EEXIST;
+               goto error_find_context;
+       }
+       field->event_field->name = strdup("cgroup_ns");
+       if (!field->event_field->name) {
+               ret = -ENOMEM;
+               goto error_name;
        }
-       field->event_field->name = "cgroup_ns";
-       field->event_field->type.atype = atype_integer;
-       field->event_field->type.u.integer.size = sizeof(ino_t) * CHAR_BIT;
-       field->event_field->type.u.integer.alignment = lttng_alignof(ino_t) * CHAR_BIT;
-       field->event_field->type.u.integer.signedness = lttng_is_signed_type(ino_t);
-       field->event_field->type.u.integer.reverse_byte_order = 0;
-       field->event_field->type.u.integer.base = 10;
-       field->event_field->type.u.integer.encoding = lttng_encode_none;
+       field->event_field->type = type;
        field->get_size = cgroup_ns_get_size;
        field->record = cgroup_ns_record;
        field->get_value = cgroup_ns_get_value;
        lttng_context_update(*ctx);
        return 0;
+
+error_name:
+error_find_context:
+       lttng_remove_context_field(ctx, field);
+error_context:
+       lttng_ust_destroy_type(type);
+       return ret;
 }
 
 /*
index 1221bf6cf687db73f56256201eeff026b5b26f24..cdcfe1a1574fe473ab1a4dd0c64dcd622188cc74 100644 (file)
@@ -55,25 +55,40 @@ void cpu_id_get_value(struct lttng_ust_ctx_field *field,
 int lttng_add_cpu_id_to_ctx(struct lttng_ust_ctx **ctx)
 {
        struct lttng_ust_ctx_field *field;
+       struct lttng_ust_type_common *type;
+       int ret;
 
-       field = lttng_append_context(ctx);
-       if (!field)
+       type = lttng_ust_create_type_integer(sizeof(int) * CHAR_BIT,
+                       lttng_alignof(int) * CHAR_BIT,
+                       lttng_is_signed_type(int),
+                       BYTE_ORDER, 10);
+       if (!type)
                return -ENOMEM;
+       field = lttng_append_context(ctx);
+       if (!field) {
+               ret = -ENOMEM;
+               goto error_context;
+       }
        if (lttng_find_context(*ctx, "cpu_id")) {
-               lttng_remove_context_field(ctx, field);
-               return -EEXIST;
+               ret = -EEXIST;
+               goto error_find_context;
        }
-       field->event_field->name = "cpu_id";
-       field->event_field->type.atype = atype_integer;
-       field->event_field->type.u.integer.size = sizeof(int) * CHAR_BIT;
-       field->event_field->type.u.integer.alignment = lttng_alignof(int) * CHAR_BIT;
-       field->event_field->type.u.integer.signedness = lttng_is_signed_type(int);
-       field->event_field->type.u.integer.reverse_byte_order = 0;
-       field->event_field->type.u.integer.base = 10;
-       field->event_field->type.u.integer.encoding = lttng_encode_none;
+       field->event_field->name = strdup("cpu_id");
+       if (!field->event_field->name) {
+               ret = -ENOMEM;
+               goto error_name;
+       }
+       field->event_field->type = type;
        field->get_size = cpu_id_get_size;
        field->record = cpu_id_record;
        field->get_value = cpu_id_get_value;
        lttng_context_update(*ctx);
        return 0;
+
+error_name:
+error_find_context:
+       lttng_remove_context_field(ctx, field);
+error_context:
+       lttng_ust_destroy_type(type);
+       return ret;
 }
index 20c6fef34b8efbf5aa56dea460a4e8e72d6ed4f7..4b32dc3983eea987fd8b9fd8929d7ee6a9c6fd1f 100644 (file)
@@ -41,24 +41,39 @@ void ip_record(struct lttng_ust_ctx_field *field,
 int lttng_add_ip_to_ctx(struct lttng_ust_ctx **ctx)
 {
        struct lttng_ust_ctx_field *field;
+       struct lttng_ust_type_common *type;
+       int ret;
 
-       field = lttng_append_context(ctx);
-       if (!field)
+       type = lttng_ust_create_type_integer(sizeof(void *) * CHAR_BIT,
+                       lttng_alignof(void *) * CHAR_BIT,
+                       lttng_is_signed_type(void *),
+                       BYTE_ORDER, 16);
+       if (!type)
                return -ENOMEM;
+       field = lttng_append_context(ctx);
+       if (!field) {
+               ret = -ENOMEM;
+               goto error_context;
+       }
        if (lttng_find_context(*ctx, "ip")) {
-               lttng_remove_context_field(ctx, field);
-               return -EEXIST;
+               ret = -EEXIST;
+               goto error_find_context;
        }
-       field->event_field->name = "ip";
-       field->event_field->type.atype = atype_integer;
-       field->event_field->type.u.integer.size = sizeof(void *) * CHAR_BIT;
-       field->event_field->type.u.integer.alignment = lttng_alignof(void *) * CHAR_BIT;
-       field->event_field->type.u.integer.signedness = lttng_is_signed_type(void *);
-       field->event_field->type.u.integer.reverse_byte_order = 0;
-       field->event_field->type.u.integer.base = 16;
-       field->event_field->type.u.integer.encoding = lttng_encode_none;
+       field->event_field->name = strdup("ip");
+       if (!field->event_field->name) {
+               ret = -ENOMEM;
+               goto error_name;
+       }
+       field->event_field->type = type;
        field->get_size = ip_get_size;
        field->record = ip_record;
        lttng_context_update(*ctx);
        return 0;
+
+error_name:
+error_find_context:
+       lttng_remove_context_field(ctx, field);
+error_context:
+       lttng_ust_destroy_type(type);
+       return ret;
 }
index a9d2024d37f95dff13afc9bb688d92e3c2eeb487..d0c4ecd6603a0a12c267463b160011a6329bdb24 100644 (file)
@@ -120,27 +120,42 @@ void ipc_ns_get_value(struct lttng_ust_ctx_field *field,
 int lttng_add_ipc_ns_to_ctx(struct lttng_ust_ctx **ctx)
 {
        struct lttng_ust_ctx_field *field;
-
-       field = lttng_append_context(ctx);
-       if (!field)
+       struct lttng_ust_type_common *type;
+       int ret;
+
+       type = lttng_ust_create_type_integer(sizeof(ino_t) * CHAR_BIT,
+                       lttng_alignof(ino_t) * CHAR_BIT,
+                       lttng_is_signed_type(ino_t),
+                       BYTE_ORDER, 10);
+       if (!type)
                return -ENOMEM;
+       field = lttng_append_context(ctx);
+       if (!field) {
+               ret = -ENOMEM;
+               goto error_context;
+       }
        if (lttng_find_context(*ctx, "ipc_ns")) {
-               lttng_remove_context_field(ctx, field);
-               return -EEXIST;
+               ret = -EEXIST;
+               goto error_find_context;
+       }
+       field->event_field->name = strdup("ipc_ns");
+       if (!field->event_field->name) {
+               ret = -ENOMEM;
+               goto error_name;
        }
-       field->event_field->name = "ipc_ns";
-       field->event_field->type.atype = atype_integer;
-       field->event_field->type.u.integer.size = sizeof(ino_t) * CHAR_BIT;
-       field->event_field->type.u.integer.alignment = lttng_alignof(ino_t) * CHAR_BIT;
-       field->event_field->type.u.integer.signedness = lttng_is_signed_type(ino_t);
-       field->event_field->type.u.integer.reverse_byte_order = 0;
-       field->event_field->type.u.integer.base = 10;
-       field->event_field->type.u.integer.encoding = lttng_encode_none;
+       field->event_field->type = type;
        field->get_size = ipc_ns_get_size;
        field->record = ipc_ns_record;
        field->get_value = ipc_ns_get_value;
        lttng_context_update(*ctx);
        return 0;
+
+error_name:
+error_find_context:
+       lttng_remove_context_field(ctx, field);
+error_context:
+       lttng_ust_destroy_type(type);
+       return ret;
 }
 
 /*
index 930bd61849a257d0002962ac887ecd15730f0eef..3535aacb26468390e70b72ac2fc060beaaa2c474 100644 (file)
@@ -103,25 +103,40 @@ void mnt_ns_get_value(struct lttng_ust_ctx_field *field,
 int lttng_add_mnt_ns_to_ctx(struct lttng_ust_ctx **ctx)
 {
        struct lttng_ust_ctx_field *field;
-
-       field = lttng_append_context(ctx);
-       if (!field)
+       struct lttng_ust_type_common *type;
+       int ret;
+
+       type = lttng_ust_create_type_integer(sizeof(ino_t) * CHAR_BIT,
+                       lttng_alignof(ino_t) * CHAR_BIT,
+                       lttng_is_signed_type(ino_t),
+                       BYTE_ORDER, 10);
+       if (!type)
                return -ENOMEM;
+       field = lttng_append_context(ctx);
+       if (!field) {
+               ret = -ENOMEM;
+               goto error_context;
+       }
        if (lttng_find_context(*ctx, "mnt_ns")) {
-               lttng_remove_context_field(ctx, field);
-               return -EEXIST;
+               ret = -EEXIST;
+               goto error_find_context;
+       }
+       field->event_field->name = strdup("mnt_ns");
+       if (!field->event_field->name) {
+               ret = -ENOMEM;
+               goto error_name;
        }
-       field->event_field->name = "mnt_ns";
-       field->event_field->type.atype = atype_integer;
-       field->event_field->type.u.integer.size = sizeof(ino_t) * CHAR_BIT;
-       field->event_field->type.u.integer.alignment = lttng_alignof(ino_t) * CHAR_BIT;
-       field->event_field->type.u.integer.signedness = lttng_is_signed_type(ino_t);
-       field->event_field->type.u.integer.reverse_byte_order = 0;
-       field->event_field->type.u.integer.base = 10;
-       field->event_field->type.u.integer.encoding = lttng_encode_none;
+       field->event_field->type = type;
        field->get_size = mnt_ns_get_size;
        field->record = mnt_ns_record;
        field->get_value = mnt_ns_get_value;
        lttng_context_update(*ctx);
        return 0;
+
+error_name:
+error_find_context:
+       lttng_remove_context_field(ctx, field);
+error_context:
+       lttng_ust_destroy_type(type);
+       return ret;
 }
index c7022b54a8f241fd37bd1d45f259815ba2afb03f..415c8ac3358dbb4adbaf393ea5fef6eaa49d62c0 100644 (file)
@@ -120,27 +120,42 @@ void net_ns_get_value(struct lttng_ust_ctx_field *field,
 int lttng_add_net_ns_to_ctx(struct lttng_ust_ctx **ctx)
 {
        struct lttng_ust_ctx_field *field;
-
-       field = lttng_append_context(ctx);
-       if (!field)
+       struct lttng_ust_type_common *type;
+       int ret;
+
+       type = lttng_ust_create_type_integer(sizeof(ino_t) * CHAR_BIT,
+                       lttng_alignof(ino_t) * CHAR_BIT,
+                       lttng_is_signed_type(ino_t),
+                       BYTE_ORDER, 10);
+       if (!type)
                return -ENOMEM;
+       field = lttng_append_context(ctx);
+       if (!field) {
+               ret = -ENOMEM;
+               goto error_context;
+       }
        if (lttng_find_context(*ctx, "net_ns")) {
-               lttng_remove_context_field(ctx, field);
-               return -EEXIST;
+               ret = -EEXIST;
+               goto error_find_context;
+       }
+       field->event_field->name = strdup("net_ns");
+       if (!field->event_field->name) {
+               ret = -ENOMEM;
+               goto error_name;
        }
-       field->event_field->name = "net_ns";
-       field->event_field->type.atype = atype_integer;
-       field->event_field->type.u.integer.size = sizeof(ino_t) * CHAR_BIT;
-       field->event_field->type.u.integer.alignment = lttng_alignof(ino_t) * CHAR_BIT;
-       field->event_field->type.u.integer.signedness = lttng_is_signed_type(ino_t);
-       field->event_field->type.u.integer.reverse_byte_order = 0;
-       field->event_field->type.u.integer.base = 10;
-       field->event_field->type.u.integer.encoding = lttng_encode_none;
+       field->event_field->type = type;
        field->get_size = net_ns_get_size;
        field->record = net_ns_record;
        field->get_value = net_ns_get_value;
        lttng_context_update(*ctx);
        return 0;
+
+error_name:
+error_find_context:
+       lttng_remove_context_field(ctx, field);
+error_context:
+       lttng_ust_destroy_type(type);
+       return ret;
 }
 
 /*
index fa2833240e4828c3bf8565cdeca5ecd9caa26f2f..725f4cf1c90f379e990588137d2abc046252fe0a 100644 (file)
@@ -529,6 +529,7 @@ int lttng_add_perf_counter_to_ctx(uint32_t type,
                                struct lttng_ust_ctx **ctx)
 {
        struct lttng_ust_ctx_field *field;
+       struct lttng_ust_type_common *ust_type;
        struct lttng_perf_counter_field *perf_field;
        char *name_alloc;
        int ret;
@@ -543,6 +544,14 @@ int lttng_add_perf_counter_to_ctx(uint32_t type,
                ret = -ENOMEM;
                goto perf_field_alloc_error;
        }
+       ust_type = lttng_ust_create_type_integer(sizeof(uint64_t) * CHAR_BIT,
+                       lttng_alignof(uint64_t) * CHAR_BIT,
+                       lttng_is_signed_type(uint64_t),
+                       BYTE_ORDER, 10);
+       if (!type) {
+               ret = -ENOMEM;
+               goto type_alloc_error;
+       }
        field = lttng_append_context(ctx);
        if (!field) {
                ret = -ENOMEM;
@@ -556,16 +565,7 @@ int lttng_add_perf_counter_to_ctx(uint32_t type,
        field->destroy = lttng_destroy_perf_counter_field;
 
        field->event_field->name = name_alloc;
-       field->event_field->type.atype = atype_integer;
-       field->event_field->type.u.integer.size =
-                       sizeof(uint64_t) * CHAR_BIT;
-       field->event_field->type.u.integer.alignment =
-                       lttng_alignof(uint64_t) * CHAR_BIT;
-       field->event_field->type.u.integer.signedness =
-                       lttng_is_signed_type(uint64_t);
-       field->event_field->type.u.integer.reverse_byte_order = 0;
-       field->event_field->type.u.integer.base = 10;
-       field->event_field->type.u.integer.encoding = lttng_encode_none;
+       field->event_field->type = ust_type;
        field->get_size = perf_counter_get_size;
        field->record = perf_counter_record;
        field->get_value = perf_counter_get_value;
@@ -597,6 +597,8 @@ setup_error:
 find_error:
        lttng_remove_context_field(ctx, field);
 append_context_error:
+       lttng_ust_destroy_type(ust_type);
+type_alloc_error:
        free(perf_field);
 perf_field_alloc_error:
        free(name_alloc);
index 4ab4246c37c5a08fa2c9e25eaf8afb61095aae91..d5c731c8fda23efe38114b33e02da94fbc6e5ade 100644 (file)
@@ -106,25 +106,40 @@ void pid_ns_get_value(struct lttng_ust_ctx_field *field,
 int lttng_add_pid_ns_to_ctx(struct lttng_ust_ctx **ctx)
 {
        struct lttng_ust_ctx_field *field;
-
-       field = lttng_append_context(ctx);
-       if (!field)
+       struct lttng_ust_type_common *type;
+       int ret;
+
+       type = lttng_ust_create_type_integer(sizeof(ino_t) * CHAR_BIT,
+                       lttng_alignof(ino_t) * CHAR_BIT,
+                       lttng_is_signed_type(ino_t),
+                       BYTE_ORDER, 10);
+       if (!type)
                return -ENOMEM;
+       field = lttng_append_context(ctx);
+       if (!field) {
+               ret = -ENOMEM;
+               goto error_context;
+       }
        if (lttng_find_context(*ctx, "pid_ns")) {
-               lttng_remove_context_field(ctx, field);
-               return -EEXIST;
+               ret = -EEXIST;
+               goto error_find_context;
+       }
+       field->event_field->name = strdup("pid_ns");
+       if (!field->event_field->name) {
+               ret = -ENOMEM;
+               goto error_name;
        }
-       field->event_field->name = "pid_ns";
-       field->event_field->type.atype = atype_integer;
-       field->event_field->type.u.integer.size = sizeof(ino_t) * CHAR_BIT;
-       field->event_field->type.u.integer.alignment = lttng_alignof(ino_t) * CHAR_BIT;
-       field->event_field->type.u.integer.signedness = lttng_is_signed_type(ino_t);
-       field->event_field->type.u.integer.reverse_byte_order = 0;
-       field->event_field->type.u.integer.base = 10;
-       field->event_field->type.u.integer.encoding = lttng_encode_none;
+       field->event_field->type = type;
        field->get_size = pid_ns_get_size;
        field->record = pid_ns_record;
        field->get_value = pid_ns_get_value;
        lttng_context_update(*ctx);
        return 0;
+
+error_name:
+error_find_context:
+       lttng_remove_context_field(ctx, field);
+error_context:
+       lttng_ust_destroy_type(type);
+       return ret;
 }
index 9e24cb0630d92b0cac74d2e64f88934f7b96f95f..5e3f9f8a84ce149225974712db0169e899213216 100644 (file)
@@ -88,30 +88,42 @@ void procname_get_value(struct lttng_ust_ctx_field *field,
        value->u.str = wrapper_getprocname();
 }
 
-static const struct lttng_type procname_array_elem_type =
-       __type_integer(char, BYTE_ORDER, 10, UTF8);
-
 int lttng_add_procname_to_ctx(struct lttng_ust_ctx **ctx)
 {
        struct lttng_ust_ctx_field *field;
+       struct lttng_ust_type_common *type;
+       int ret;
 
-       field = lttng_append_context(ctx);
-       if (!field)
+       type = lttng_ust_create_type_array_text(LTTNG_UST_ABI_PROCNAME_LEN);
+       if (!type)
                return -ENOMEM;
+       field = lttng_append_context(ctx);
+       if (!field) {
+               ret = -ENOMEM;
+               goto error_context;
+       }
        if (lttng_find_context(*ctx, "procname")) {
-               lttng_remove_context_field(ctx, field);
-               return -EEXIST;
+               ret = -EEXIST;
+               goto error_find_context;
+       }
+       field->event_field->name = strdup("procname");
+       if (!field->event_field->name) {
+               ret = -ENOMEM;
+               goto error_name;
        }
-       field->event_field->name = "procname";
-       field->event_field->type.atype = atype_array_nestable;
-       field->event_field->type.u.array_nestable.elem_type =
-               &procname_array_elem_type;
-       field->event_field->type.u.array_nestable.length = LTTNG_UST_ABI_PROCNAME_LEN;
+       field->event_field->type = type;
        field->get_size = procname_get_size;
        field->record = procname_record;
        field->get_value = procname_get_value;
        lttng_context_update(*ctx);
        return 0;
+
+error_name:
+error_find_context:
+       lttng_remove_context_field(ctx, field);
+error_context:
+       lttng_ust_destroy_type(type);
+       return ret;
 }
 
 /*
index fe67c2eef1871e6f71fa82e045ac975966cc5904..c3f50e80c0d3bd7177d7816addb8fa109921d6cc 100644 (file)
@@ -139,13 +139,17 @@ int lttng_ust_add_app_context_to_ctx_rcu(const char *name,
                ret = -ENOMEM;
                goto error_event_field_alloc;
        }
-       new_field->field_name = strdup(name);
-       if (!new_field->field_name) {
+       new_field->event_field->name = strdup(name);
+       if (!new_field->event_field->name) {
                ret = -ENOMEM;
                goto error_field_name_alloc;
        }
-       new_field->event_field->name = new_field->field_name;
-       new_field->event_field->type.atype = atype_dynamic;
+       new_field->event_field->type = zmalloc(sizeof(struct lttng_ust_type_common));
+       if (!new_field->event_field->type) {
+               ret = -ENOMEM;
+               goto error_field_type_alloc;
+       }
+       new_field->event_field->type->type = lttng_ust_type_dynamic;
        /*
         * If provider is not found, we add the context anyway, but
         * it will provide a dummy context.
@@ -167,13 +171,16 @@ int lttng_ust_add_app_context_to_ctx_rcu(const char *name,
         */
        ret = lttng_context_add_rcu(ctx, new_field);
        if (ret) {
-               free(new_field->field_name);
+               free(new_field->event_field->type);
+               free((char *) new_field->event_field->name);
                free(new_field->event_field);
                free(new_field);
                return ret;
        }
        return 0;
 
+error_field_type_alloc:
+       free((char *) new_field->event_field->name);
 error_field_name_alloc:
        free(new_field->event_field);
 error_event_field_alloc:
index 162b2cf4c78bb966a8c0c0bd688562b7d2a3ade8..d113f59523f9947b77dba87cdd36fe6ad31ccf86 100644 (file)
@@ -47,25 +47,40 @@ void pthread_id_get_value(struct lttng_ust_ctx_field *field,
 int lttng_add_pthread_id_to_ctx(struct lttng_ust_ctx **ctx)
 {
        struct lttng_ust_ctx_field *field;
+       struct lttng_ust_type_common *type;
+       int ret;
 
-       field = lttng_append_context(ctx);
-       if (!field)
+       type = lttng_ust_create_type_integer(sizeof(unsigned long) * CHAR_BIT,
+                       lttng_alignof(unsigned long) * CHAR_BIT,
+                       lttng_is_signed_type(unsigned long),
+                       BYTE_ORDER, 10);
+       if (!type)
                return -ENOMEM;
+       field = lttng_append_context(ctx);
+       if (!field) {
+               ret = -ENOMEM;
+               goto error_context;
+       }
        if (lttng_find_context(*ctx, "pthread_id")) {
-               lttng_remove_context_field(ctx, field);
-               return -EEXIST;
+               ret = -EEXIST;
+               goto error_find_context;
        }
-       field->event_field->name = "pthread_id";
-       field->event_field->type.atype = atype_integer;
-       field->event_field->type.u.integer.size = sizeof(unsigned long) * CHAR_BIT;
-       field->event_field->type.u.integer.alignment = lttng_alignof(unsigned long) * CHAR_BIT;
-       field->event_field->type.u.integer.signedness = lttng_is_signed_type(unsigned long);
-       field->event_field->type.u.integer.reverse_byte_order = 0;
-       field->event_field->type.u.integer.base = 10;
-       field->event_field->type.u.integer.encoding = lttng_encode_none;
+       field->event_field->name = strdup("pthread_id");
+       if (!field->event_field->name) {
+               ret = -ENOMEM;
+               goto error_name;
+       }
+       field->event_field->type = type;
        field->get_size = pthread_id_get_size;
        field->record = pthread_id_record;
        field->get_value = pthread_id_get_value;
        lttng_context_update(*ctx);
        return 0;
+
+error_name:
+error_find_context:
+       lttng_remove_context_field(ctx, field);
+error_context:
+       lttng_ust_destroy_type(type);
+       return ret;
 }
index 8edc1fae4462a844ca7705b47e83b8a09bb44ed7..dda556c61a9a4e3bf881828db54a9e57837181b5 100644 (file)
@@ -119,27 +119,42 @@ void time_ns_get_value(struct lttng_ust_ctx_field *field,
 int lttng_add_time_ns_to_ctx(struct lttng_ust_ctx **ctx)
 {
        struct lttng_ust_ctx_field *field;
-
-       field = lttng_append_context(ctx);
-       if (!field)
+       struct lttng_ust_type_common *type;
+       int ret;
+
+       type = lttng_ust_create_type_integer(sizeof(ino_t) * CHAR_BIT,
+                       lttng_alignof(ino_t) * CHAR_BIT,
+                       lttng_is_signed_type(ino_t),
+                       BYTE_ORDER, 10);
+       if (!type)
                return -ENOMEM;
+       field = lttng_append_context(ctx);
+       if (!field) {
+               ret = -ENOMEM;
+               goto error_context;
+       }
        if (lttng_find_context(*ctx, "time_ns")) {
-               lttng_remove_context_field(ctx, field);
-               return -EEXIST;
+               ret = -EEXIST;
+               goto error_find_context;
+       }
+       field->event_field->name = strdup("time_ns");
+       if (!field->event_field->name) {
+               ret = -ENOMEM;
+               goto error_name;
        }
-       field->event_field->name = "time_ns";
-       field->event_field->type.atype = atype_integer;
-       field->event_field->type.u.integer.size = sizeof(ino_t) * CHAR_BIT;
-       field->event_field->type.u.integer.alignment = lttng_alignof(ino_t) * CHAR_BIT;
-       field->event_field->type.u.integer.signedness = lttng_is_signed_type(ino_t);
-       field->event_field->type.u.integer.reverse_byte_order = 0;
-       field->event_field->type.u.integer.base = 10;
-       field->event_field->type.u.integer.encoding = lttng_encode_none;
+       field->event_field->type = type;
        field->get_size = time_ns_get_size;
        field->record = time_ns_record;
        field->get_value = time_ns_get_value;
        lttng_context_update(*ctx);
        return 0;
+
+error_name:
+error_find_context:
+       lttng_remove_context_field(ctx, field);
+error_context:
+       lttng_ust_destroy_type(type);
+       return ret;
 }
 
 /*
index fccf70f2491fc6c3133bd99159dd8e99a021fc0d..925b77b6bc3c5bac8153a24d36946a9760bb253f 100644 (file)
@@ -103,25 +103,40 @@ void user_ns_get_value(struct lttng_ust_ctx_field *field,
 int lttng_add_user_ns_to_ctx(struct lttng_ust_ctx **ctx)
 {
        struct lttng_ust_ctx_field *field;
-
-       field = lttng_append_context(ctx);
-       if (!field)
+       struct lttng_ust_type_common *type;
+       int ret;
+
+       type = lttng_ust_create_type_integer(sizeof(ino_t) * CHAR_BIT,
+                       lttng_alignof(ino_t) * CHAR_BIT,
+                       lttng_is_signed_type(ino_t),
+                       BYTE_ORDER, 10);
+       if (!type)
                return -ENOMEM;
+       field = lttng_append_context(ctx);
+       if (!field) {
+               ret = -ENOMEM;
+               goto error_context;
+       }
        if (lttng_find_context(*ctx, "user_ns")) {
-               lttng_remove_context_field(ctx, field);
-               return -EEXIST;
+               ret = -EEXIST;
+               goto error_find_context;
+       }
+       field->event_field->name = strdup("user_ns");
+       if (!field->event_field->name) {
+               ret = -ENOMEM;
+               goto error_name;
        }
-       field->event_field->name = "user_ns";
-       field->event_field->type.atype = atype_integer;
-       field->event_field->type.u.integer.size = sizeof(ino_t) * CHAR_BIT;
-       field->event_field->type.u.integer.alignment = lttng_alignof(ino_t) * CHAR_BIT;
-       field->event_field->type.u.integer.signedness = lttng_is_signed_type(ino_t);
-       field->event_field->type.u.integer.reverse_byte_order = 0;
-       field->event_field->type.u.integer.base = 10;
-       field->event_field->type.u.integer.encoding = lttng_encode_none;
+       field->event_field->type = type;
        field->get_size = user_ns_get_size;
        field->record = user_ns_record;
        field->get_value = user_ns_get_value;
        lttng_context_update(*ctx);
        return 0;
+
+error_name:
+error_find_context:
+       lttng_remove_context_field(ctx, field);
+error_context:
+       lttng_ust_destroy_type(type);
+       return ret;
 }
index af8aad464e18cd9fd4c1eab281d321f413d6eb99..55a228994cdb4ce971650bcb8e31aaab538746d7 100644 (file)
@@ -121,27 +121,42 @@ void uts_ns_get_value(struct lttng_ust_ctx_field *field,
 int lttng_add_uts_ns_to_ctx(struct lttng_ust_ctx **ctx)
 {
        struct lttng_ust_ctx_field *field;
-
-       field = lttng_append_context(ctx);
-       if (!field)
+       struct lttng_ust_type_common *type;
+       int ret;
+
+       type = lttng_ust_create_type_integer(sizeof(ino_t) * CHAR_BIT,
+                       lttng_alignof(ino_t) * CHAR_BIT,
+                       lttng_is_signed_type(ino_t),
+                       BYTE_ORDER, 10);
+       if (!type)
                return -ENOMEM;
+       field = lttng_append_context(ctx);
+       if (!field) {
+               ret = -ENOMEM;
+               goto error_context;
+       }
        if (lttng_find_context(*ctx, "uts_ns")) {
-               lttng_remove_context_field(ctx, field);
-               return -EEXIST;
+               ret = -EEXIST;
+               goto error_find_context;
+       }
+       field->event_field->name = strdup("uts_ns");
+       if (!field->event_field->name) {
+               ret = -ENOMEM;
+               goto error_name;
        }
-       field->event_field->name = "uts_ns";
-       field->event_field->type.atype = atype_integer;
-       field->event_field->type.u.integer.size = sizeof(ino_t) * CHAR_BIT;
-       field->event_field->type.u.integer.alignment = lttng_alignof(ino_t) * CHAR_BIT;
-       field->event_field->type.u.integer.signedness = lttng_is_signed_type(ino_t);
-       field->event_field->type.u.integer.reverse_byte_order = 0;
-       field->event_field->type.u.integer.base = 10;
-       field->event_field->type.u.integer.encoding = lttng_encode_none;
+       field->event_field->type = type;
        field->get_size = uts_ns_get_size;
        field->record = uts_ns_record;
        field->get_value = uts_ns_get_value;
        lttng_context_update(*ctx);
        return 0;
+
+error_name:
+error_find_context:
+       lttng_remove_context_field(ctx, field);
+error_context:
+       lttng_ust_destroy_type(type);
+       return ret;
 }
 
 /*
index a7bac4e2dd874f12ba0889abe2fc1cdb6fa20cae..d1a21a6e22ddb0505ef99dc4b642f477faf2cbe5 100644 (file)
@@ -92,25 +92,40 @@ void vegid_get_value(struct lttng_ust_ctx_field *field,
 int lttng_add_vegid_to_ctx(struct lttng_ust_ctx **ctx)
 {
        struct lttng_ust_ctx_field *field;
-
-       field = lttng_append_context(ctx);
-       if (!field)
+       struct lttng_ust_type_common *type;
+       int ret;
+
+       type = lttng_ust_create_type_integer(sizeof(gid_t) * CHAR_BIT,
+                       lttng_alignof(gid_t) * CHAR_BIT,
+                       lttng_is_signed_type(gid_t),
+                       BYTE_ORDER, 10);
+       if (!type)
                return -ENOMEM;
+       field = lttng_append_context(ctx);
+       if (!field) {
+               ret = -ENOMEM;
+               goto error_context;
+       }
        if (lttng_find_context(*ctx, "vegid")) {
-               lttng_remove_context_field(ctx, field);
-               return -EEXIST;
+               ret = -EEXIST;
+               goto error_find_context;
+       }
+       field->event_field->name = strdup("vegid");
+       if (!field->event_field->name) {
+               ret = -ENOMEM;
+               goto error_name;
        }
-       field->event_field->name = "vegid";
-       field->event_field->type.atype = atype_integer;
-       field->event_field->type.u.integer.size = sizeof(gid_t) * CHAR_BIT;
-       field->event_field->type.u.integer.alignment = lttng_alignof(gid_t) * CHAR_BIT;
-       field->event_field->type.u.integer.signedness = lttng_is_signed_type(gid_t);
-       field->event_field->type.u.integer.reverse_byte_order = 0;
-       field->event_field->type.u.integer.base = 10;
-       field->event_field->type.u.integer.encoding = lttng_encode_none;
+       field->event_field->type = type;
        field->get_size = vegid_get_size;
        field->record = vegid_record;
        field->get_value = vegid_get_value;
        lttng_context_update(*ctx);
        return 0;
+
+error_name:
+error_find_context:
+       lttng_remove_context_field(ctx, field);
+error_context:
+       lttng_ust_destroy_type(type);
+       return ret;
 }
index e21745039664a2e4223c96f8788489cc31d88d4f..159eb420593ee05e3a4d40dba10058e575b82b85 100644 (file)
@@ -92,25 +92,40 @@ void veuid_get_value(struct lttng_ust_ctx_field *field,
 int lttng_add_veuid_to_ctx(struct lttng_ust_ctx **ctx)
 {
        struct lttng_ust_ctx_field *field;
-
-       field = lttng_append_context(ctx);
-       if (!field)
+       struct lttng_ust_type_common *type;
+       int ret;
+
+       type = lttng_ust_create_type_integer(sizeof(uid_t) * CHAR_BIT,
+                       lttng_alignof(uid_t) * CHAR_BIT,
+                       lttng_is_signed_type(uid_t),
+                       BYTE_ORDER, 10);
+       if (!type)
                return -ENOMEM;
+       field = lttng_append_context(ctx);
+       if (!field) {
+               ret = -ENOMEM;
+               goto error_context;
+       }
        if (lttng_find_context(*ctx, "veuid")) {
-               lttng_remove_context_field(ctx, field);
-               return -EEXIST;
+               ret = -EEXIST;
+               goto error_find_context;
+       }
+       field->event_field->name = strdup("veuid");
+       if (!field->event_field->name) {
+               ret = -ENOMEM;
+               goto error_name;
        }
-       field->event_field->name = "veuid";
-       field->event_field->type.atype = atype_integer;
-       field->event_field->type.u.integer.size = sizeof(uid_t) * CHAR_BIT;
-       field->event_field->type.u.integer.alignment = lttng_alignof(uid_t) * CHAR_BIT;
-       field->event_field->type.u.integer.signedness = lttng_is_signed_type(uid_t);
-       field->event_field->type.u.integer.reverse_byte_order = 0;
-       field->event_field->type.u.integer.base = 10;
-       field->event_field->type.u.integer.encoding = lttng_encode_none;
+       field->event_field->type = type;
        field->get_size = veuid_get_size;
        field->record = veuid_record;
        field->get_value = veuid_get_value;
        lttng_context_update(*ctx);
        return 0;
+
+error_name:
+error_find_context:
+       lttng_remove_context_field(ctx, field);
+error_context:
+       lttng_ust_destroy_type(type);
+       return ret;
 }
index 7bc12544f9244c73b30afe0abddd826bc167c16c..5bfcd22e4c8091b2150b07ee63f680a67214860e 100644 (file)
@@ -92,25 +92,40 @@ void vgid_get_value(struct lttng_ust_ctx_field *field,
 int lttng_add_vgid_to_ctx(struct lttng_ust_ctx **ctx)
 {
        struct lttng_ust_ctx_field *field;
-
-       field = lttng_append_context(ctx);
-       if (!field)
+       struct lttng_ust_type_common *type;
+       int ret;
+
+       type = lttng_ust_create_type_integer(sizeof(gid_t) * CHAR_BIT,
+                       lttng_alignof(gid_t) * CHAR_BIT,
+                       lttng_is_signed_type(gid_t),
+                       BYTE_ORDER, 10);
+       if (!type)
                return -ENOMEM;
+       field = lttng_append_context(ctx);
+       if (!field) {
+               ret = -ENOMEM;
+               goto error_context;
+       }
        if (lttng_find_context(*ctx, "vgid")) {
-               lttng_remove_context_field(ctx, field);
-               return -EEXIST;
+               ret = -EEXIST;
+               goto error_find_context;
+       }
+       field->event_field->name = strdup("vgid");
+       if (!field->event_field->name) {
+               ret = -ENOMEM;
+               goto error_name;
        }
-       field->event_field->name = "vgid";
-       field->event_field->type.atype = atype_integer;
-       field->event_field->type.u.integer.size = sizeof(gid_t) * CHAR_BIT;
-       field->event_field->type.u.integer.alignment = lttng_alignof(gid_t) * CHAR_BIT;
-       field->event_field->type.u.integer.signedness = lttng_is_signed_type(gid_t);
-       field->event_field->type.u.integer.reverse_byte_order = 0;
-       field->event_field->type.u.integer.base = 10;
-       field->event_field->type.u.integer.encoding = lttng_encode_none;
+       field->event_field->type = type;
        field->get_size = vgid_get_size;
        field->record = vgid_record;
        field->get_value = vgid_get_value;
        lttng_context_update(*ctx);
        return 0;
+
+error_name:
+error_find_context:
+       lttng_remove_context_field(ctx, field);
+error_context:
+       lttng_ust_destroy_type(type);
+       return ret;
 }
index ddcfb8ad3bcf25ed98f15557945d65c4a73c14f2..78e1f0ceaaf6c223c2ec8d0bb9ffdd01e2d9c594 100644 (file)
@@ -75,25 +75,40 @@ void vpid_get_value(struct lttng_ust_ctx_field *field,
 int lttng_add_vpid_to_ctx(struct lttng_ust_ctx **ctx)
 {
        struct lttng_ust_ctx_field *field;
+       struct lttng_ust_type_common *type;
+       int ret;
 
-       field = lttng_append_context(ctx);
-       if (!field)
+       type = lttng_ust_create_type_integer(sizeof(pid_t) * CHAR_BIT,
+                       lttng_alignof(pid_t) * CHAR_BIT,
+                       lttng_is_signed_type(pid_t),
+                       BYTE_ORDER, 10);
+       if (!type)
                return -ENOMEM;
+       field = lttng_append_context(ctx);
+       if (!field) {
+               ret = -ENOMEM;
+               goto error_context;
+       }
        if (lttng_find_context(*ctx, "vpid")) {
-               lttng_remove_context_field(ctx, field);
-               return -EEXIST;
+               ret = -EEXIST;
+               goto error_find_context;
        }
-       field->event_field->name = "vpid";
-       field->event_field->type.atype = atype_integer;
-       field->event_field->type.u.integer.size = sizeof(pid_t) * CHAR_BIT;
-       field->event_field->type.u.integer.alignment = lttng_alignof(pid_t) * CHAR_BIT;
-       field->event_field->type.u.integer.signedness = lttng_is_signed_type(pid_t);
-       field->event_field->type.u.integer.reverse_byte_order = 0;
-       field->event_field->type.u.integer.base = 10;
-       field->event_field->type.u.integer.encoding = lttng_encode_none;
+       field->event_field->name = strdup("vpid");
+       if (!field->event_field->name) {
+               ret = -ENOMEM;
+               goto error_name;
+       }
+       field->event_field->type = type;
        field->get_size = vpid_get_size;
        field->record = vpid_record;
        field->get_value = vpid_get_value;
        lttng_context_update(*ctx);
        return 0;
+
+error_name:
+error_find_context:
+       lttng_remove_context_field(ctx, field);
+error_context:
+       lttng_ust_destroy_type(type);
+       return ret;
 }
index 0d7b0426d9f6c5b4c3606e500ae6ac7f6aa036b2..16a68a5c6206581698ec08b8f0ed5edb90ad37b3 100644 (file)
@@ -96,25 +96,40 @@ void vsgid_get_value(struct lttng_ust_ctx_field *field,
 int lttng_add_vsgid_to_ctx(struct lttng_ust_ctx **ctx)
 {
        struct lttng_ust_ctx_field *field;
-
-       field = lttng_append_context(ctx);
-       if (!field)
+       struct lttng_ust_type_common *type;
+       int ret;
+
+       type = lttng_ust_create_type_integer(sizeof(gid_t) * CHAR_BIT,
+                       lttng_alignof(gid_t) * CHAR_BIT,
+                       lttng_is_signed_type(gid_t),
+                       BYTE_ORDER, 10);
+       if (!type)
                return -ENOMEM;
+       field = lttng_append_context(ctx);
+       if (!field) {
+               ret = -ENOMEM;
+               goto error_context;
+       }
        if (lttng_find_context(*ctx, "vsgid")) {
-               lttng_remove_context_field(ctx, field);
-               return -EEXIST;
+               ret = -EEXIST;
+               goto error_find_context;
+       }
+       field->event_field->name = strdup("vsgid");
+       if (!field->event_field->name) {
+               ret = -ENOMEM;
+               goto error_name;
        }
-       field->event_field->name = "vsgid";
-       field->event_field->type.atype = atype_integer;
-       field->event_field->type.u.integer.size = sizeof(gid_t) * CHAR_BIT;
-       field->event_field->type.u.integer.alignment = lttng_alignof(gid_t) * CHAR_BIT;
-       field->event_field->type.u.integer.signedness = lttng_is_signed_type(gid_t);
-       field->event_field->type.u.integer.reverse_byte_order = 0;
-       field->event_field->type.u.integer.base = 10;
-       field->event_field->type.u.integer.encoding = lttng_encode_none;
+       field->event_field->type = type;
        field->get_size = vsgid_get_size;
        field->record = vsgid_record;
        field->get_value = vsgid_get_value;
        lttng_context_update(*ctx);
        return 0;
+
+error_name:
+error_find_context:
+       lttng_remove_context_field(ctx, field);
+error_context:
+       lttng_ust_destroy_type(type);
+       return ret;
 }
index 0428292a3e277fc7993cab731f0bf7cb697ddc69..c7d0815179e720149a716fcd53aef75f702fa021 100644 (file)
@@ -96,25 +96,40 @@ void vsuid_get_value(struct lttng_ust_ctx_field *field,
 int lttng_add_vsuid_to_ctx(struct lttng_ust_ctx **ctx)
 {
        struct lttng_ust_ctx_field *field;
-
-       field = lttng_append_context(ctx);
-       if (!field)
+       struct lttng_ust_type_common *type;
+       int ret;
+
+       type = lttng_ust_create_type_integer(sizeof(uid_t) * CHAR_BIT,
+                       lttng_alignof(uid_t) * CHAR_BIT,
+                       lttng_is_signed_type(uid_t),
+                       BYTE_ORDER, 10);
+       if (!type)
                return -ENOMEM;
+       field = lttng_append_context(ctx);
+       if (!field) {
+               ret = -ENOMEM;
+               goto error_context;
+       }
        if (lttng_find_context(*ctx, "vsuid")) {
-               lttng_remove_context_field(ctx, field);
-               return -EEXIST;
+               ret = -EEXIST;
+               goto error_find_context;
+       }
+       field->event_field->name = strdup("vsuid");
+       if (!field->event_field->name) {
+               ret = -ENOMEM;
+               goto error_name;
        }
-       field->event_field->name = "vsuid";
-       field->event_field->type.atype = atype_integer;
-       field->event_field->type.u.integer.size = sizeof(uid_t) * CHAR_BIT;
-       field->event_field->type.u.integer.alignment = lttng_alignof(uid_t) * CHAR_BIT;
-       field->event_field->type.u.integer.signedness = lttng_is_signed_type(uid_t);
-       field->event_field->type.u.integer.reverse_byte_order = 0;
-       field->event_field->type.u.integer.base = 10;
-       field->event_field->type.u.integer.encoding = lttng_encode_none;
+       field->event_field->type = type;
        field->get_size = vsuid_get_size;
        field->record = vsuid_record;
        field->get_value = vsuid_get_value;
        lttng_context_update(*ctx);
        return 0;
+
+error_name:
+error_find_context:
+       lttng_remove_context_field(ctx, field);
+error_context:
+       lttng_ust_destroy_type(type);
+       return ret;
 }
index 9b91e57c5dd962b7991a03e81978ff0e409177a7..432b8b0dd16dcc4163acbee3794a973caf57b24b 100644 (file)
@@ -79,27 +79,42 @@ void vtid_get_value(struct lttng_ust_ctx_field *field,
 int lttng_add_vtid_to_ctx(struct lttng_ust_ctx **ctx)
 {
        struct lttng_ust_ctx_field *field;
+       struct lttng_ust_type_common *type;
+       int ret;
 
-       field = lttng_append_context(ctx);
-       if (!field)
+       type = lttng_ust_create_type_integer(sizeof(pid_t) * CHAR_BIT,
+                       lttng_alignof(pid_t) * CHAR_BIT,
+                       lttng_is_signed_type(pid_t),
+                       BYTE_ORDER, 10);
+       if (!type)
                return -ENOMEM;
+       field = lttng_append_context(ctx);
+       if (!field) {
+               ret = -ENOMEM;
+               goto error_context;
+       }
        if (lttng_find_context(*ctx, "vtid")) {
-               lttng_remove_context_field(ctx, field);
-               return -EEXIST;
+               ret = -EEXIST;
+               goto error_find_context;
        }
-       field->event_field->name = "vtid";
-       field->event_field->type.atype = atype_integer;
-       field->event_field->type.u.integer.size = sizeof(pid_t) * CHAR_BIT;
-       field->event_field->type.u.integer.alignment = lttng_alignof(pid_t) * CHAR_BIT;
-       field->event_field->type.u.integer.signedness = lttng_is_signed_type(pid_t);
-       field->event_field->type.u.integer.reverse_byte_order = 0;
-       field->event_field->type.u.integer.base = 10;
-       field->event_field->type.u.integer.encoding = lttng_encode_none;
+       field->event_field->name = strdup("vtid");
+       if (!field->event_field->name) {
+               ret = -ENOMEM;
+               goto error_name;
+       }
+       field->event_field->type = type;
        field->get_size = vtid_get_size;
        field->record = vtid_record;
        field->get_value = vtid_get_value;
        lttng_context_update(*ctx);
        return 0;
+
+error_name:
+error_find_context:
+       lttng_remove_context_field(ctx, field);
+error_context:
+       lttng_ust_destroy_type(type);
+       return ret;
 }
 
 /*
index 754218d269e188421040a925f312d2c2f337b74d..e6f57e71ec747450be7c2efc8a6afd7dac3de57f 100644 (file)
@@ -92,25 +92,40 @@ void vuid_get_value(struct lttng_ust_ctx_field *field,
 int lttng_add_vuid_to_ctx(struct lttng_ust_ctx **ctx)
 {
        struct lttng_ust_ctx_field *field;
-
-       field = lttng_append_context(ctx);
-       if (!field)
+       struct lttng_ust_type_common *type;
+       int ret;
+
+       type = lttng_ust_create_type_integer(sizeof(uid_t) * CHAR_BIT,
+                       lttng_alignof(uid_t) * CHAR_BIT,
+                       lttng_is_signed_type(uid_t),
+                       BYTE_ORDER, 10);
+       if (!type)
                return -ENOMEM;
+       field = lttng_append_context(ctx);
+       if (!field) {
+               ret = -ENOMEM;
+               goto error_context;
+       }
        if (lttng_find_context(*ctx, "vuid")) {
-               lttng_remove_context_field(ctx, field);
-               return -EEXIST;
+               ret = -EEXIST;
+               goto error_find_context;
+       }
+       field->event_field->name = strdup("vuid");
+       if (!field->event_field->name) {
+               ret = -ENOMEM;
+               goto error_name;
        }
-       field->event_field->name = "vuid";
-       field->event_field->type.atype = atype_integer;
-       field->event_field->type.u.integer.size = sizeof(uid_t) * CHAR_BIT;
-       field->event_field->type.u.integer.alignment = lttng_alignof(uid_t) * CHAR_BIT;
-       field->event_field->type.u.integer.signedness = lttng_is_signed_type(uid_t);
-       field->event_field->type.u.integer.reverse_byte_order = 0;
-       field->event_field->type.u.integer.base = 10;
-       field->event_field->type.u.integer.encoding = lttng_encode_none;
+       field->event_field->type = type;
        field->get_size = vuid_get_size;
        field->record = vuid_record;
        field->get_value = vuid_get_value;
        lttng_context_update(*ctx);
        return 0;
+
+error_name:
+error_find_context:
+       lttng_remove_context_field(ctx, field);
+error_context:
+       lttng_ust_destroy_type(type);
+       return ret;
 }
index 8ed9bbd4f1db15b13d1d56daaeacbdddc5921b8c..e97b688ad8f74d282ae41a0031d64a62d524ba7c 100644 (file)
@@ -189,6 +189,42 @@ int lttng_context_add_rcu(struct lttng_ust_ctx **ctx_p,
        return 0;
 }
 
+static size_t get_type_max_align(struct lttng_ust_type_common *type)
+{
+       switch (type->type) {
+       case lttng_ust_type_integer:
+               return lttng_ust_get_type_integer(type)->alignment;
+       case lttng_ust_type_string:
+               return CHAR_BIT;
+       case lttng_ust_type_dynamic:
+               return 0;
+       case lttng_ust_type_enum:
+               return get_type_max_align(lttng_ust_get_type_enum(type)->container_type);
+       case lttng_ust_type_array:
+               return max_t(size_t, get_type_max_align(lttng_ust_get_type_array(type)->elem_type),
+                               lttng_ust_get_type_array(type)->alignment);
+       case lttng_ust_type_sequence:
+               return max_t(size_t, get_type_max_align(lttng_ust_get_type_sequence(type)->elem_type),
+                               lttng_ust_get_type_sequence(type)->alignment);
+       case lttng_ust_type_struct:
+       {
+               unsigned int i;
+               size_t field_align = 0;
+               struct lttng_ust_type_struct *struct_type = lttng_ust_get_type_struct(type);
+
+               for (i = 0; i < struct_type->nr_fields; i++) {
+                       field_align = max_t(size_t,
+                               get_type_max_align(struct_type->fields[i]->type),
+                               field_align);
+               }
+               return field_align;
+       }
+       default:
+               WARN_ON_ONCE(1);
+               return 0;
+       }
+}
+
 /*
  * lttng_context_update() should be called at least once between context
  * modification and trace start.
@@ -199,68 +235,9 @@ void lttng_context_update(struct lttng_ust_ctx *ctx)
        size_t largest_align = 8;       /* in bits */
 
        for (i = 0; i < ctx->nr_fields; i++) {
-               struct lttng_type *type;
                size_t field_align = 8;
 
-               type = &ctx->fields[i]->event_field->type;
-               switch (type->atype) {
-               case atype_integer:
-                       field_align = type->u.integer.alignment;
-                       break;
-               case atype_array_nestable:
-               {
-                       const struct lttng_type *nested_type;
-
-                       nested_type = type->u.array_nestable.elem_type;
-                       switch (nested_type->atype) {
-                       case atype_integer:
-                               field_align = nested_type->u.integer.alignment;
-                               break;
-                       case atype_string:
-                               break;
-
-                       case atype_array_nestable:
-                       case atype_sequence_nestable:
-                       default:
-                               WARN_ON_ONCE(1);
-                               break;
-                       }
-                       field_align = max_t(size_t, field_align,
-                                       type->u.array_nestable.alignment);
-                       break;
-               }
-               case atype_sequence_nestable:
-               {
-                       const struct lttng_type *nested_type;
-
-                       nested_type = type->u.sequence_nestable.elem_type;
-                       switch (nested_type->atype) {
-                       case atype_integer:
-                               field_align = nested_type->u.integer.alignment;
-                               break;
-
-                       case atype_string:
-                               break;
-
-                       case atype_array_nestable:
-                       case atype_sequence_nestable:
-                       default:
-                               WARN_ON_ONCE(1);
-                               break;
-                       }
-                       field_align = max_t(size_t, field_align,
-                                       type->u.sequence_nestable.alignment);
-                       break;
-               }
-               case atype_string:
-                       break;
-               case atype_dynamic:
-                       break;
-               case atype_enum_nestable:
-               default:
-                       WARN_ON_ONCE(1);
-                       break;
-               }
+               field_align = get_type_max_align(ctx->fields[i]->event_field->type);
                largest_align = max_t(size_t, largest_align, field_align);
        }
        ctx->largest_align = largest_align >> 3;        /* bits to bytes */
@@ -277,7 +254,10 @@ void lttng_remove_context_field(struct lttng_ust_ctx **ctx_p,
        ctx = *ctx_p;
        ctx->nr_fields--;
        assert(ctx->fields[ctx->nr_fields] == field);
-       assert(field->field_name == NULL);
+       lttng_ust_destroy_type(field->event_field->type);
+       free((char *) field->event_field->name);
+       free(field->event_field);
+       free(field);
        ctx->fields[ctx->nr_fields] = NULL;
 }
 
@@ -290,7 +270,8 @@ void lttng_destroy_context(struct lttng_ust_ctx *ctx)
        for (i = 0; i < ctx->nr_fields; i++) {
                if (ctx->fields[i]->destroy)
                        ctx->fields[i]->destroy(ctx->fields[i]);
-               free(ctx->fields[i]->field_name);
+               lttng_ust_destroy_type(ctx->fields[i]->event_field->type);
+               free((char *) ctx->fields[i]->event_field->name);
                free(ctx->fields[i]->event_field);
                free(ctx->fields[i]);
        }
index de4d97d10eee4fa332852829eada19ab5d5c4902..625d98af7e8a7d5549da43f0860a3a53fc97dd01 100644 (file)
@@ -250,7 +250,7 @@ static
 void register_event(struct lttng_ust_event_common *event)
 {
        int ret;
-       const struct lttng_ust_event_desc *desc;
+       struct lttng_ust_event_desc *desc;
 
        assert(event->priv->registered == 0);
        desc = event->priv->desc;
@@ -266,7 +266,7 @@ static
 void unregister_event(struct lttng_ust_event_common *event)
 {
        int ret;
-       const struct lttng_ust_event_desc *desc;
+       struct lttng_ust_event_desc *desc;
 
        assert(event->priv->registered == 1);
        desc = event->priv->desc;
@@ -398,7 +398,7 @@ void lttng_enabler_destroy(struct lttng_enabler *enabler)
 }
 
 static
-int lttng_enum_create(const struct lttng_ust_enum_desc *desc,
+int lttng_enum_create(struct lttng_ust_enum_desc *desc,
                struct lttng_ust_session *session)
 {
        const char *enum_name = desc->name;
@@ -456,16 +456,16 @@ exist:
 }
 
 static
-int lttng_create_enum_check(const struct lttng_type *type,
+int lttng_create_enum_check(struct lttng_ust_type_common *type,
                struct lttng_ust_session *session)
 {
-       switch (type->atype) {
-       case atype_enum_nestable:
+       switch (type->type) {
+       case lttng_ust_type_enum:
        {
-               const struct lttng_ust_enum_desc *enum_desc;
+               struct lttng_ust_enum_desc *enum_desc;
                int ret;
 
-               enum_desc = type->u.enum_nestable.desc;
+               enum_desc = lttng_ust_get_type_enum(type)->desc;
                ret = lttng_enum_create(enum_desc, session);
                if (ret && ret != -EEXIST) {
                        DBG("Unable to create enum error: (%d)", ret);
@@ -473,14 +473,14 @@ int lttng_create_enum_check(const struct lttng_type *type,
                }
                break;
        }
-       case atype_dynamic:
+       case lttng_ust_type_dynamic:
        {
-               const struct lttng_ust_event_field *tag_field_generic;
-               const struct lttng_ust_enum_desc *enum_desc;
+               struct lttng_ust_event_field *tag_field_generic;
+               struct lttng_ust_enum_desc *enum_desc;
                int ret;
 
                tag_field_generic = lttng_ust_dynamic_type_tag_field();
-               enum_desc = tag_field_generic->type.u.enum_nestable.desc;
+               enum_desc = lttng_ust_get_type_enum(tag_field_generic->type)->desc;
                ret = lttng_enum_create(enum_desc, session);
                if (ret && ret != -EEXIST) {
                        DBG("Unable to create enum error: (%d)", 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_ust_event_field **event_fields,
+               struct lttng_ust_event_field **event_fields,
                struct lttng_ust_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;
+               struct lttng_ust_type_common *type = event_fields[i]->type;
 
                ret = lttng_create_enum_check(type, session);
                if (ret)
@@ -524,7 +524,7 @@ int lttng_create_all_ctx_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 = &ctx_fields[i]->event_field->type;
+               struct lttng_ust_type_common *type = ctx_fields[i]->event_field->type;
 
                ret = lttng_create_enum_check(type, session);
                if (ret)
@@ -570,7 +570,7 @@ int lttng_session_enable(struct lttng_ust_session *session)
         * we need to use.
         */
        cds_list_for_each_entry(chan, &session->priv->chan_head, node) {
-               const struct lttng_ust_ctx *ctx;
+               struct lttng_ust_ctx *ctx;
                struct lttng_ust_ctx_field **fields = NULL;
                size_t nr_fields = 0;
                uint32_t chan_id;
@@ -675,7 +675,7 @@ static inline
 struct cds_hlist_head *borrow_hash_table_bucket(
                struct cds_hlist_head *hash_table,
                unsigned int hash_table_size,
-               const struct lttng_ust_event_desc *desc)
+               struct lttng_ust_event_desc *desc)
 {
        const char *event_name;
        size_t name_len;
@@ -692,7 +692,7 @@ struct cds_hlist_head *borrow_hash_table_bucket(
  * Supports event creation while tracing session is active.
  */
 static
-int lttng_event_recorder_create(const struct lttng_ust_event_desc *desc,
+int lttng_event_recorder_create(struct lttng_ust_event_desc *desc,
                struct lttng_channel *chan)
 {
        struct lttng_ust_event_recorder *event_recorder;
@@ -800,7 +800,7 @@ socket_error:
 }
 
 static
-int lttng_event_notifier_create(const struct lttng_ust_event_desc *desc,
+int lttng_event_notifier_create(struct lttng_ust_event_desc *desc,
                uint64_t token, uint64_t error_counter_index,
                struct lttng_event_notifier_group *event_notifier_group)
 {
@@ -872,7 +872,7 @@ error:
 }
 
 static
-int lttng_desc_match_star_glob_enabler(const struct lttng_ust_event_desc *desc,
+int lttng_desc_match_star_glob_enabler(struct lttng_ust_event_desc *desc,
                struct lttng_enabler *enabler)
 {
        int loglevel = 0;
@@ -895,7 +895,7 @@ int lttng_desc_match_star_glob_enabler(const struct lttng_ust_event_desc *desc,
 }
 
 static
-int lttng_desc_match_event_enabler(const struct lttng_ust_event_desc *desc,
+int lttng_desc_match_event_enabler(struct lttng_ust_event_desc *desc,
                struct lttng_enabler *enabler)
 {
        int loglevel = 0;
@@ -917,7 +917,7 @@ int lttng_desc_match_event_enabler(const struct lttng_ust_event_desc *desc,
 }
 
 static
-int lttng_desc_match_enabler(const struct lttng_ust_event_desc *desc,
+int lttng_desc_match_enabler(struct lttng_ust_event_desc *desc,
                struct lttng_enabler *enabler)
 {
        switch (enabler->format_type) {
@@ -1006,7 +1006,7 @@ void lttng_create_event_recorder_if_missing(struct lttng_event_enabler *event_en
 {
        struct lttng_ust_session *session = event_enabler->chan->session;
        struct lttng_ust_probe_desc *probe_desc;
-       const struct lttng_ust_event_desc *desc;
+       struct lttng_ust_event_desc *desc;
        struct lttng_ust_event_recorder_private *event_recorder_priv;
        int i;
        struct cds_list_head *probe_list;
@@ -1073,7 +1073,7 @@ void probe_provider_event_for_each(struct lttng_ust_probe_desc *provider_desc,
         * sessions to queue the unregistration of the events.
         */
        for (i = 0; i < provider_desc->nr_events; i++) {
-               const struct lttng_ust_event_desc *event_desc;
+               struct lttng_ust_event_desc *event_desc;
                struct lttng_event_notifier_group *event_notifier_group;
                struct lttng_ust_event_recorder_private *event_recorder_priv;
                struct lttng_ust_event_notifier_private *event_notifier_priv;
@@ -1140,14 +1140,14 @@ 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_ust_enum_desc *enum_desc;
-                       const struct lttng_ust_event_field *field;
+                       struct lttng_ust_enum_desc *enum_desc;
+                       struct lttng_ust_event_field *field;
                        struct lttng_enum *curr_enum;
 
                        field = event_recorder->parent->priv->desc->fields[i];
-                       switch (field->type.atype) {
-                       case atype_enum_nestable:
-                               enum_desc = field->type.u.enum_nestable.desc;
+                       switch (field->type->type) {
+                       case lttng_ust_type_enum:
+                               enum_desc = lttng_ust_get_type_enum(field->type)->desc;
                                break;
                        default:
                                continue;
@@ -1728,7 +1728,7 @@ void lttng_create_event_notifier_if_missing(
                for (i = 0; i < probe_desc->nr_events; i++) {
                        int ret;
                        bool found = false;
-                       const struct lttng_ust_event_desc *desc;
+                       struct lttng_ust_event_desc *desc;
                        struct lttng_ust_event_notifier_private *event_notifier_priv;
                        struct cds_hlist_head *head;
                        struct cds_hlist_node *node;
index 98998b0fae9cbd37e449a0a0b9db2676785ad418..00ce54cb36a9117338cecf4cc1bc3496f0b94227 100644 (file)
@@ -354,31 +354,29 @@ int lttng_probes_get_field_list(struct lttng_ust_field_list *list)
                                        event_field->name,
                                        LTTNG_UST_ABI_SYM_NAME_LEN);
                                list_entry->field.field_name[LTTNG_UST_ABI_SYM_NAME_LEN - 1] = '\0';
-                               switch (event_field->type.atype) {
-                               case atype_integer:
+                               switch (event_field->type->type) {
+                               case lttng_ust_type_integer:
                                        list_entry->field.type = LTTNG_UST_ABI_FIELD_INTEGER;
                                        break;
-                               case atype_string:
+                               case lttng_ust_type_string:
                                        list_entry->field.type = LTTNG_UST_ABI_FIELD_STRING;
                                        break;
-                               case atype_array_nestable:
-                                       if (event_field->type.u.array_nestable.elem_type->atype != atype_integer
-                                               || event_field->type.u.array_nestable.elem_type->u.integer.encoding == lttng_encode_none)
+                               case lttng_ust_type_array:
+                                       if (lttng_ust_get_type_array(event_field->type)->encoding == lttng_ust_string_encoding_none)
                                                list_entry->field.type = LTTNG_UST_ABI_FIELD_OTHER;
                                        else
                                                list_entry->field.type = LTTNG_UST_ABI_FIELD_STRING;
                                        break;
-                               case atype_sequence_nestable:
-                                       if (event_field->type.u.sequence_nestable.elem_type->atype != atype_integer
-                                               || event_field->type.u.sequence_nestable.elem_type->u.integer.encoding == lttng_encode_none)
+                               case lttng_ust_type_sequence:
+                                       if (lttng_ust_get_type_sequence(event_field->type)->encoding == lttng_ust_string_encoding_none)
                                                list_entry->field.type = LTTNG_UST_ABI_FIELD_OTHER;
                                        else
                                                list_entry->field.type = LTTNG_UST_ABI_FIELD_STRING;
                                        break;
-                               case atype_float:
+                               case lttng_ust_type_float:
                                        list_entry->field.type = LTTNG_UST_ABI_FIELD_FLOAT;
                                        break;
-                               case atype_enum_nestable:
+                               case lttng_ust_type_enum:
                                        list_entry->field.type = LTTNG_UST_ABI_FIELD_ENUM;
                                        break;
                                default:
index 428061295de57168e37a53e3ddcf25ce66a6f006..12cb91f736a59143bc1a73b79c8682a64d37be86 100644 (file)
@@ -444,7 +444,7 @@ int lttng_abi_map_channel(int session_objd,
 {
        struct lttng_ust_session *session = objd_private(session_objd);
        const char *transport_name;
-       const struct lttng_transport *transport;
+       struct lttng_transport *transport;
        const char *chan_name;
        int chan_objd;
        struct lttng_ust_shm_handle *channel_handle;
index ccda6475d7a773793aeaaee05f44f8b27cb5b605..4b58d82cde474a2990b5f07021075ee83bb1284c 100644 (file)
@@ -31,7 +31,7 @@
                .string = (_string),                                    \
        }),
 
-static const struct lttng_ust_enum_entry *dt_enum[_NR_LTTNG_UST_DYNAMIC_TYPES] = {
+static struct lttng_ust_enum_entry *dt_enum[_NR_LTTNG_UST_DYNAMIC_TYPES] = {
        [LTTNG_UST_DYNAMIC_TYPE_NONE] = ctf_enum_value("_none", 0)
        [LTTNG_UST_DYNAMIC_TYPE_S8] = ctf_enum_value("_int8", 1)
        [LTTNG_UST_DYNAMIC_TYPE_S16] = ctf_enum_value("_int16", 2)
@@ -46,119 +46,129 @@ static const struct lttng_ust_enum_entry *dt_enum[_NR_LTTNG_UST_DYNAMIC_TYPES] =
        [LTTNG_UST_DYNAMIC_TYPE_STRING] = ctf_enum_value("_string", 11)
 };
 
-static const struct lttng_ust_enum_desc dt_enum_desc = {
+static struct lttng_ust_enum_desc dt_enum_desc = {
        .name = "dynamic_type_enum",
        .entries = dt_enum,
        .nr_entries = LTTNG_ARRAY_SIZE(dt_enum),
 };
 
-const struct lttng_ust_event_field *dt_var_fields[_NR_LTTNG_UST_DYNAMIC_TYPES] = {
+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,
-                       .u.struct_nestable.nr_fields = 0,       /* empty struct. */
-                       .u.struct_nestable.alignment = 0,
-               },
+               .type = (struct lttng_ust_type_common *) __LTTNG_COMPOUND_LITERAL(struct lttng_ust_type_struct, {
+                       .parent = {
+                               .type = lttng_ust_type_struct,
+                       },
+                       .struct_size = sizeof(struct lttng_ust_type_struct),
+                       .nr_fields = 0, /* empty struct */
+                       .alignment = 0,
+               }),
                .nowrite = 0,
        }),
        [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),
+               .type = lttng_ust_type_integer_define(int8_t, BYTE_ORDER, 10),
                .nowrite = 0,
        }),
        [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),
+               .type = lttng_ust_type_integer_define(int16_t, BYTE_ORDER, 10),
                .nowrite = 0,
        }),
        [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),
+               .type = lttng_ust_type_integer_define(int32_t, BYTE_ORDER, 10),
                .nowrite = 0,
        }),
        [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),
+               .type = lttng_ust_type_integer_define(int64_t, BYTE_ORDER, 10),
                .nowrite = 0,
        }),
        [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),
+               .type = lttng_ust_type_integer_define(uint8_t, BYTE_ORDER, 10),
                .nowrite = 0,
        }),
        [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),
+               .type = lttng_ust_type_integer_define(uint16_t, BYTE_ORDER, 10),
                .nowrite = 0,
        }),
        [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),
+               .type = lttng_ust_type_integer_define(uint32_t, BYTE_ORDER, 10),
                .nowrite = 0,
        }),
        [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),
+               .type = lttng_ust_type_integer_define(uint64_t, BYTE_ORDER, 10),
                .nowrite = 0,
        }),
        [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),
+               .type = lttng_ust_type_float_define(float),
                .nowrite = 0,
        }),
        [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),
+               .type = lttng_ust_type_float_define(double),
                .nowrite = 0,
        }),
        [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,
-               },
+               .type = (struct lttng_ust_type_common *) __LTTNG_COMPOUND_LITERAL(struct lttng_ust_type_string, {
+                       .parent = {
+                               .type = lttng_ust_type_string,
+                       },
+                       .struct_size = sizeof(struct lttng_ust_type_string),
+                       .encoding = lttng_ust_string_encoding_UTF8,
+               }),
                .nowrite = 0,
        }),
 };
 
-static const struct lttng_ust_event_field dt_enum_field = {
+static struct lttng_ust_event_field dt_enum_field = {
+       .struct_size = sizeof(struct lttng_ust_event_field),
        .name = NULL,
-       .type.atype = atype_enum_nestable,
-       .type.u.enum_nestable.desc = &dt_enum_desc,
-       .type.u.enum_nestable.container_type =
-               __LTTNG_COMPOUND_LITERAL(struct lttng_type,
-                       __type_integer(char, BYTE_ORDER, 10, none)),
+       .type = (struct lttng_ust_type_common *) __LTTNG_COMPOUND_LITERAL(struct lttng_ust_type_enum, {
+               .parent = {
+                       .type = lttng_ust_type_enum,
+               },
+               .struct_size = sizeof(struct lttng_ust_type_enum),
+               .desc = &dt_enum_desc,
+               .container_type = lttng_ust_type_integer_define(char, BYTE_ORDER, 10),
+       }),
        .nowrite = 0,
 };
 
-const struct lttng_ust_event_field *lttng_ust_dynamic_type_field(int64_t value)
+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];
 }
 
-int lttng_ust_dynamic_type_choices(size_t *nr_choices, const struct lttng_ust_event_field ***choices)
+int lttng_ust_dynamic_type_choices(size_t *nr_choices, struct lttng_ust_event_field ***choices)
 {
        *nr_choices = _NR_LTTNG_UST_DYNAMIC_TYPES;
        *choices = dt_var_fields;
        return 0;
 }
 
-const struct lttng_ust_event_field *lttng_ust_dynamic_type_tag_field(void)
+struct lttng_ust_event_field *lttng_ust_dynamic_type_tag_field(void)
 {
        return &dt_enum_field;
 }
index ca44c8f04dd7fa3677d461861b2634286d683ddb..0b1fcf0b787724781e3dc855f00b41e6393e1ed1 100644 (file)
@@ -87,7 +87,7 @@ void lttng_counter_transport_unregister(struct lttng_counter_transport *transpor
  * Needed by comm layer.
  */
 struct lttng_enum *lttng_ust_enum_get_from_desc(struct lttng_ust_session *session,
-               const struct lttng_ust_enum_desc *enum_desc)
+               struct lttng_ust_enum_desc *enum_desc)
 {
        struct lttng_enum *_enum;
        struct cds_hlist_head *head;
index 44d605c666141071e87aa4b947aeb4b804603908..5466f25e2216e9eefc961a14e7dd1463e2858e44 100644 (file)
@@ -14,6 +14,7 @@
 
 #include <lttng/ust-events.h>
 
+#include <ust-helper.h>
 #include "ust-context-provider.h"
 
 struct lttng_ust_abi_obj;
@@ -244,7 +245,7 @@ struct lttng_counter_transport {
 struct lttng_ust_event_common_private {
        struct lttng_ust_event_common *pub;     /* Public event interface */
 
-       const struct lttng_ust_event_desc *desc;
+       struct lttng_ust_event_desc *desc;
        /* Backward references: list of lttng_enabler_ref (ref to enablers) */
        struct cds_list_head enablers_ref_head;
        int registered;                 /* has reg'd tracepoint probe */
@@ -308,7 +309,7 @@ struct lttng_ust_session_private {
 };
 
 struct lttng_enum {
-       const struct lttng_ust_enum_desc *desc;
+       struct lttng_ust_enum_desc *desc;
        struct lttng_ust_session *session;
        struct cds_list_head node;      /* Enum list in session */
        struct cds_hlist_node hlist;    /* Session ht of enums */
@@ -341,6 +342,160 @@ struct lttng_ust_channel_ops_private {
                            struct lttng_ust_shm_handle *handle);
 };
 
+static inline
+struct lttng_ust_type_integer *lttng_ust_get_type_integer(struct lttng_ust_type_common *type)
+{
+       if (type->type != lttng_ust_type_integer)
+               return NULL;
+       return caa_container_of(type, struct lttng_ust_type_integer, parent);
+}
+
+static inline
+struct lttng_ust_type_float *lttng_ust_get_type_float(struct lttng_ust_type_common *type)
+{
+       if (type->type != lttng_ust_type_float)
+               return NULL;
+       return caa_container_of(type, struct lttng_ust_type_float, parent);
+}
+
+static inline
+struct lttng_ust_type_string *lttng_ust_get_type_string(struct lttng_ust_type_common *type)
+{
+       if (type->type != lttng_ust_type_string)
+               return NULL;
+       return caa_container_of(type, struct lttng_ust_type_string, parent);
+}
+
+static inline
+struct lttng_ust_type_enum *lttng_ust_get_type_enum(struct lttng_ust_type_common *type)
+{
+       if (type->type != lttng_ust_type_enum)
+               return NULL;
+       return caa_container_of(type, struct lttng_ust_type_enum, parent);
+}
+
+static inline
+struct lttng_ust_type_array *lttng_ust_get_type_array(struct lttng_ust_type_common *type)
+{
+       if (type->type != lttng_ust_type_array)
+               return NULL;
+       return caa_container_of(type, struct lttng_ust_type_array, parent);
+}
+
+static inline
+struct lttng_ust_type_sequence *lttng_ust_get_type_sequence(struct lttng_ust_type_common *type)
+{
+       if (type->type != lttng_ust_type_sequence)
+               return NULL;
+       return caa_container_of(type, struct lttng_ust_type_sequence, parent);
+}
+
+static inline
+struct lttng_ust_type_struct *lttng_ust_get_type_struct(struct lttng_ust_type_common *type)
+{
+       if (type->type != lttng_ust_type_struct)
+               return NULL;
+       return caa_container_of(type, struct lttng_ust_type_struct, parent);
+}
+
+/* Create dynamically allocated types. */
+static inline
+struct lttng_ust_type_common *lttng_ust_create_type_integer(unsigned int size,
+               unsigned short alignment, bool signedness, unsigned int byte_order,
+               unsigned int base)
+{
+       struct lttng_ust_type_integer *integer_type;
+
+       integer_type = zmalloc(sizeof(struct lttng_ust_type_integer));
+       if (!integer_type)
+               return NULL;
+       integer_type->parent.type = lttng_ust_type_integer;
+       integer_type->struct_size = sizeof(struct lttng_ust_type_integer);
+       integer_type->size = size;
+       integer_type->alignment = alignment;
+       integer_type->signedness = signedness;
+       integer_type->reverse_byte_order = byte_order != BYTE_ORDER;
+       integer_type->base = base;
+       return (struct lttng_ust_type_common *) integer_type;
+}
+
+static inline
+struct lttng_ust_type_common *lttng_ust_create_type_array_text(unsigned int length)
+{
+       struct lttng_ust_type_array *array_type;
+
+       array_type = zmalloc(sizeof(struct lttng_ust_type_array));
+       if (!array_type)
+               return NULL;
+       array_type->parent.type = lttng_ust_type_array;
+       array_type->struct_size = sizeof(struct lttng_ust_type_array);
+       array_type->length = length;
+       array_type->alignment = 0;
+       array_type->encoding = lttng_ust_string_encoding_UTF8;
+       array_type->elem_type = lttng_ust_create_type_integer(sizeof(char) * CHAR_BIT,
+                       lttng_alignof(char) * CHAR_BIT, lttng_is_signed_type(char),
+                       BYTE_ORDER, 10);
+       if (!array_type->elem_type)
+               goto error_elem;
+       return (struct lttng_ust_type_common *) array_type;
+
+error_elem:
+       free(array_type);
+       return NULL;
+}
+
+/*
+ * Destroy dynamically allocated types, including nested types.
+ * For enumerations, it does not free the enumeration mapping description.
+ */
+static inline
+void lttng_ust_destroy_type(struct lttng_ust_type_common *type)
+{
+       if (!type)
+               return;
+
+       switch (type->type) {
+       case lttng_ust_type_integer:
+       case lttng_ust_type_string:
+       case lttng_ust_type_float:
+       case lttng_ust_type_dynamic:
+               free(type);
+               break;
+       case lttng_ust_type_enum:
+       {
+               struct lttng_ust_type_enum *enum_type = (struct lttng_ust_type_enum *) type;
+
+               lttng_ust_destroy_type(enum_type->container_type);
+               break;
+       }
+       case lttng_ust_type_array:
+       {
+               struct lttng_ust_type_array *array_type = (struct lttng_ust_type_array *) type;
+
+               lttng_ust_destroy_type(array_type->elem_type);
+               break;
+       }
+       case lttng_ust_type_sequence:
+       {
+               struct lttng_ust_type_sequence *sequence_type = (struct lttng_ust_type_sequence *) type;
+
+               lttng_ust_destroy_type(sequence_type->elem_type);
+               break;
+       }
+       case lttng_ust_type_struct:
+       {
+               struct lttng_ust_type_struct *struct_type = (struct lttng_ust_type_struct *) type;
+               unsigned int i;
+
+               for (i = 0; i < struct_type->nr_fields; i++)
+                       lttng_ust_destroy_type(struct_type->fields[i]->type);
+               break;
+       }
+       default:
+               abort();
+       }
+}
+
 static inline
 struct lttng_enabler *lttng_event_enabler_as_enabler(
                struct lttng_event_enabler *event_enabler)
@@ -421,7 +576,7 @@ int lttng_event_enabler_attach_exclusion(struct lttng_event_enabler *enabler,
  * event_notifier enabler) to ensure each is linked to the provided instance.
  */
 __attribute__((visibility("hidden")))
-void lttng_enabler_link_bytecode(const struct lttng_ust_event_desc *event_desc,
+void lttng_enabler_link_bytecode(struct lttng_ust_event_desc *event_desc,
                struct lttng_ust_ctx **ctx,
                struct cds_list_head *instance_bytecode_runtime_head,
                struct cds_list_head *enabler_bytecode_runtime_head);
@@ -641,7 +796,7 @@ struct cds_list_head *lttng_get_probe_list_head(void);
 
 __attribute__((visibility("hidden")))
 struct lttng_enum *lttng_ust_enum_get_from_desc(struct lttng_ust_session *session,
-               const struct lttng_ust_enum_desc *enum_desc);
+               struct lttng_ust_enum_desc *enum_desc);
 
 __attribute__((visibility("hidden")))
 int lttng_abi_create_root_handle(void);
This page took 0.0822349999999999 seconds and 4 git commands to generate.