/*
* 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 {
/* 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;
};
/*
: (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;
};
/*
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. */
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 */
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 */
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;
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 */
#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. */ \
};
#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, \
}),
#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, \
}),
#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, \
}),
#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, \
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, \
#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. */
};
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) */
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) */
/*
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. */
};
__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 */
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.
}
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;
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;
/* 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;
/* 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;
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:
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;
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;
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,
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);
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)
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;
* 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;
} else {
uf->name[0] = '\0';
}
- ret = serialize_integer_type(&ut->u.integer, <->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);
uf->name[0] = '\0';
}
uft = &ut->u._float;
- lft = <->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;
(*iter_output)++;
break;
}
- case atype_string:
+ case lttng_ust_type_string:
{
struct ustctl_field *uf = &fields[*iter_output];
struct ustctl_type *ut = &uf->type;
} 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;
(*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;
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;
}
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);
return -EINVAL;
break;
}
- case atype_struct_nestable:
+ case lttng_ust_type_struct:
{
struct ustctl_field *uf = &fields[*iter_output];
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;
} 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;
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;
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;
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;
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) */
{
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;
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:
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:
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;
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. */
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;
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;
}
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;
}
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;
}
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:
}
break;
default:
- ERR("Unknown type: %d", (int) field->type.atype);
+ ERR("Unknown type: %d", (int) field->type->type);
return -EINVAL;
}
return 0;
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;
}
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;
}
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);
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;
}
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;
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
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 {
}
}
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 {
}
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;
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)
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;
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:
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;
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;
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:
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:
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:
* 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,
* 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)
* 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;
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 */
};
size_t nr_elem;
/* Inner type. */
- const struct lttng_type *nested_type;
+ struct lttng_ust_type_common *nested_type;
} sequence;
} u;
};
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")))
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;
}
/*
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;
}
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;
}
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;
}
/*
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;
}
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;
}
/*
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;
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;
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;
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);
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;
}
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;
}
/*
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.
*/
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:
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;
}
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;
}
/*
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;
}
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;
}
/*
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
/*
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;
}
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.
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 */
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;
}
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]);
}
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;
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;
}
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;
}
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);
}
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);
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;
/* 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)
/* 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)
* 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;
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;
* 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;
}
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)
{
}
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;
}
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;
}
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) {
{
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;
* 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;
/* 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;
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;
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:
{
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;
.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)
[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;
}
* 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;
#include <lttng/ust-events.h>
+#include <ust-helper.h>
#include "ust-context-provider.h"
struct lttng_ust_abi_obj;
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 */
};
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 */
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)
* 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);
__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);