/* Update the astract_types name table in lttng-types.c along with this enum */
enum lttng_abstract_types {
atype_integer,
- atype_enum, /* legacy */
- atype_array, /* legacy */
- atype_sequence, /* legacy */
atype_string,
atype_float,
atype_dynamic,
- atype_struct, /* legacy */
atype_enum_nestable,
atype_array_nestable,
atype_sequence_nestable,
char padding[LTTNG_UST_FLOAT_TYPE_PADDING];
};
-/* legacy */
-#define LTTNG_UST_BASIC_TYPE_PADDING 128
-union _lttng_basic_type {
- struct lttng_integer_type integer; /* legacy */
- struct {
- const struct lttng_enum_desc *desc; /* Enumeration mapping */
- struct lttng_integer_type container_type;
- } enumeration; /* legacy */
- struct {
- enum lttng_string_encodings encoding;
- } string; /* legacy */
- struct lttng_float_type _float; /* legacy */
- char padding[LTTNG_UST_BASIC_TYPE_PADDING];
-};
-
-/* legacy */
-struct lttng_basic_type {
- enum lttng_abstract_types atype;
- union {
- union _lttng_basic_type basic;
- } u;
-};
-
#define LTTNG_UST_TYPE_PADDING 128
struct lttng_type {
enum lttng_abstract_types atype;
unsigned int alignment;
} struct_nestable;
- union {
- /* legacy provider ABI 1.0 */
- union _lttng_basic_type basic; /* legacy */
- struct {
- struct lttng_basic_type elem_type;
- unsigned int length; /* Num. elems. */
- } array; /* legacy */
- struct {
- struct lttng_basic_type length_type;
- struct lttng_basic_type elem_type;
- } sequence; /* legacy */
- struct {
- unsigned int nr_fields;
- struct lttng_event_field *fields; /* Array of fields. */
- } _struct; /* legacy */
- } legacy;
char padding[LTTNG_UST_TYPE_PADDING];
} u;
};
case atype_integer:
case atype_float:
case atype_string:
- case atype_enum:
- case atype_array:
- case atype_sequence:
return 1;
- case atype_struct:
- return count_fields_recursive(lt->u.legacy._struct.nr_fields,
- lt->u.legacy._struct.fields) + 1;
case atype_enum_nestable:
return count_one_type(lt->u.enum_nestable.container_type) + 1;
case atype_array_nestable:
return count;
}
-static
-int serialize_string_encoding(int32_t *ue,
- enum lttng_string_encodings le)
-{
- switch (le) {
- case lttng_encode_none:
- *ue = ustctl_encode_none;
- break;
- case lttng_encode_UTF8:
- *ue = ustctl_encode_UTF8;
- break;
- case lttng_encode_ASCII:
- *ue = ustctl_encode_ASCII;
- break;
- default:
- return -EINVAL;
- }
- return 0;
-}
-
-static
-int serialize_integer_type(struct ustctl_integer_type *uit,
- const struct lttng_integer_type *lit)
-{
- int32_t encoding;
-
- uit->size = lit->size;
- uit->signedness = lit->signedness;
- uit->reverse_byte_order = lit->reverse_byte_order;
- uit->base = lit->base;
- if (serialize_string_encoding(&encoding, lit->encoding))
- return -EINVAL;
- uit->encoding = encoding;
- uit->alignment = lit->alignment;
- return 0;
-}
-
-static
-int serialize_basic_type(struct lttng_session *session,
- enum ustctl_abstract_types *uatype,
- enum lttng_abstract_types atype,
- union _ustctl_basic_type *ubt,
- const union _lttng_basic_type *lbt)
-{
- switch (atype) {
- case atype_integer:
- {
- if (serialize_integer_type(&ubt->integer, &lbt->integer))
- return -EINVAL;
- *uatype = ustctl_atype_integer;
- break;
- }
- case atype_string:
- {
- int32_t encoding;
-
- if (serialize_string_encoding(&encoding, lbt->string.encoding))
- return -EINVAL;
- ubt->string.encoding = encoding;
- *uatype = ustctl_atype_string;
- break;
- }
- case atype_float:
- {
- struct ustctl_float_type *uft;
- const struct lttng_float_type *lft;
-
- uft = &ubt->_float;
- lft = &lbt->_float;
- uft->exp_dig = lft->exp_dig;
- uft->mant_dig = lft->mant_dig;
- uft->alignment = lft->alignment;
- uft->reverse_byte_order = lft->reverse_byte_order;
- *uatype = ustctl_atype_float;
- break;
- }
- case atype_enum:
- {
- strncpy(ubt->enumeration.name, lbt->enumeration.desc->name,
- LTTNG_UST_SYM_NAME_LEN);
- ubt->enumeration.name[LTTNG_UST_SYM_NAME_LEN - 1] = '\0';
- if (serialize_integer_type(&ubt->enumeration.container_type,
- &lbt->enumeration.container_type))
- return -EINVAL;
- if (session) {
- const struct lttng_enum *_enum;
-
- _enum = lttng_ust_enum_get_from_desc(session, lbt->enumeration.desc);
- if (!_enum)
- return -EINVAL;
- ubt->enumeration.id = _enum->id;
- } else {
- ubt->enumeration.id = -1ULL;
- }
- *uatype = ustctl_atype_enum;
- break;
- }
- case atype_array:
- case atype_array_nestable:
- case atype_sequence:
- case atype_sequence_nestable:
- case atype_enum_nestable:
- default:
- return -EINVAL;
- }
- return 0;
-}
-
static
int serialize_dynamic_type(struct lttng_session *session,
struct ustctl_field *fields, size_t *iter_output,
case atype_integer:
case atype_float:
case atype_string:
- case atype_enum:
- {
- struct ustctl_field *uf = &fields[*iter_output];
- struct ustctl_type *ut = &uf->type;
- enum ustctl_abstract_types atype;
-
- if (field_name) {
- strncpy(uf->name, field_name, LTTNG_UST_SYM_NAME_LEN);
- uf->name[LTTNG_UST_SYM_NAME_LEN - 1] = '\0';
- } else {
- uf->name[0] = '\0';
- }
- ret = serialize_basic_type(session, &atype, lt->atype,
- &ut->u.legacy.basic, <->u.legacy.basic);
- if (ret)
- return ret;
- ut->atype = atype;
- (*iter_output)++;
- break;
- }
- case atype_array:
- {
- struct ustctl_field *uf = &fields[*iter_output];
- struct ustctl_type *ut = &uf->type;
- struct ustctl_basic_type *ubt;
- const struct lttng_basic_type *lbt;
- enum ustctl_abstract_types atype;
-
- if (field_name) {
- strncpy(uf->name, field_name, LTTNG_UST_SYM_NAME_LEN);
- uf->name[LTTNG_UST_SYM_NAME_LEN - 1] = '\0';
- } else {
- uf->name[0] = '\0';
- }
- ut->atype = ustctl_atype_array;
- ubt = &ut->u.legacy.array.elem_type;
- lbt = <->u.legacy.array.elem_type;
- ut->u.legacy.array.length = lt->u.legacy.array.length;
- ret = serialize_basic_type(session, &atype, lbt->atype,
- &ubt->u.basic, &lbt->u.basic);
- if (ret)
- return -EINVAL;
- ubt->atype = atype;
- (*iter_output)++;
- break;
- }
case atype_array_nestable:
{
struct ustctl_field *uf = &fields[*iter_output];
return -EINVAL;
break;
}
- case atype_sequence:
- {
- struct ustctl_field *uf = &fields[*iter_output];
- struct ustctl_type *ut = &uf->type;
- struct ustctl_basic_type *ubt;
- const struct lttng_basic_type *lbt;
- enum ustctl_abstract_types atype;
-
- if (field_name) {
- strncpy(uf->name, field_name, LTTNG_UST_SYM_NAME_LEN);
- uf->name[LTTNG_UST_SYM_NAME_LEN - 1] = '\0';
- } else {
- uf->name[0] = '\0';
- }
- uf->type.atype = ustctl_atype_sequence;
- ubt = &ut->u.legacy.sequence.length_type;
- lbt = <->u.legacy.sequence.length_type;
- ret = serialize_basic_type(session, &atype, lbt->atype,
- &ubt->u.basic, &lbt->u.basic);
- if (ret)
- return -EINVAL;
- ubt->atype = atype;
- ubt = &ut->u.legacy.sequence.elem_type;
- lbt = <->u.legacy.sequence.elem_type;
- ret = serialize_basic_type(session, &atype, lbt->atype,
- &ubt->u.basic, &lbt->u.basic);
- if (ret)
- return -EINVAL;
- ubt->atype = atype;
- (*iter_output)++;
- break;
- }
case atype_sequence_nestable:
{
struct ustctl_field *uf = &fields[*iter_output];
return -EINVAL;
break;
}
- case atype_struct:
- {
- struct ustctl_field *uf = &fields[*iter_output];
-
- if (field_name) {
- strncpy(uf->name, field_name, LTTNG_UST_SYM_NAME_LEN);
- uf->name[LTTNG_UST_SYM_NAME_LEN - 1] = '\0';
- } else {
- uf->name[0] = '\0';
- }
- uf->type.atype = ustctl_atype_struct;
- uf->type.u.legacy._struct.nr_fields = lt->u.legacy._struct.nr_fields;
- (*iter_output)++;
-
- ret = serialize_fields(session, fields, iter_output,
- lt->u.legacy._struct.nr_fields,
- lt->u.legacy._struct.fields);
- if (ret)
- return -EINVAL;
- break;
- }
case atype_struct_nestable:
{
struct ustctl_field *uf = &fields[*iter_output];
case atype_integer:
integer_type = &nested_type->u.integer;
break;
- case atype_enum:
+ case atype_enum_nestable:
/* Treat enumeration as an integer. */
integer_type = &nested_type->u.enum_nestable.container_type->u.integer;
break;
ptr->ptr = &ptr->u.u64;
}
break;
- case atype_enum: /* Fall-through */
case atype_enum_nestable:
{
const struct lttng_integer_type *itype;
- if (field->type.atype == atype_enum) {
- itype = &field->type.u.legacy.basic.enumeration.container_type;
- } else {
- itype = &field->type.u.enum_nestable.container_type->u.integer;
- }
+ itype = &field->type.u.enum_nestable.container_type->u.integer;
ctx_field->get_value(ctx_field, &v);
if (itype->signedness) {
ptr->object_type = OBJECT_TYPE_SIGNED_ENUM;
}
break;
}
- case atype_array:
- if (field->type.u.legacy.array.elem_type.atype != atype_integer) {
- ERR("Array nesting only supports integer types.");
- return -EINVAL;
- }
- if (field->type.u.legacy.array.elem_type.u.basic.integer.encoding == lttng_encode_none) {
- ERR("Only string arrays are supported for contexts.");
- return -EINVAL;
- }
- ptr->object_type = OBJECT_TYPE_STRING;
- ctx_field->get_value(ctx_field, &v);
- ptr->ptr = v.u.str;
- break;
case atype_array_nestable:
if (field->type.u.array_nestable.elem_type->atype != atype_integer) {
ERR("Array nesting only supports integer types.");
ctx_field->get_value(ctx_field, &v);
ptr->ptr = v.u.str;
break;
- case atype_sequence:
- if (field->type.u.legacy.sequence.elem_type.atype != atype_integer) {
- ERR("Sequence nesting only supports integer types.");
- return -EINVAL;
- }
- if (field->type.u.legacy.sequence.elem_type.u.basic.integer.encoding == lttng_encode_none) {
- ERR("Only string sequences are supported for contexts.");
- return -EINVAL;
- }
- ptr->object_type = OBJECT_TYPE_STRING;
- 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) {
ERR("Sequence nesting only supports integer types.");
return -EINVAL;
}
break;
- case atype_struct:
- ERR("Structure type cannot be loaded.");
- return -EINVAL;
default:
ERR("Unknown type: %d", (int) field->type.atype);
return -EINVAL;
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 ||
- stack_top->u.ptr.field->type.atype == atype_array_nestable);
+ assert(stack_top->u.ptr.field->type.atype == atype_array_nestable);
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 ||
- stack_top->u.ptr.field->type.atype == atype_sequence_nestable);
+ assert(stack_top->u.ptr.field->type.atype == atype_sequence_nestable);
stack_top->u.ptr.field = NULL;
break;
}
field = stack_top->load.field;
switch (field->type.atype) {
- case atype_array:
- integer_type = &field->type.u.legacy.array.elem_type.u.basic.integer;
- num_elems = field->type.u.legacy.array.length;
- break;
case atype_array_nestable:
if (field->type.u.array_nestable.elem_type->atype != atype_integer) {
ret = -EINVAL;
field = stack_top->load.field;
switch (field->type.atype) {
- case atype_sequence:
- integer_type = &field->type.u.legacy.sequence.elem_type.u.basic.integer;
- break;
case atype_sequence_nestable:
if (field->type.u.sequence_nestable.elem_type->atype != atype_integer) {
ret = -EINVAL;
load->object_type = OBJECT_TYPE_U64;
load->rev_bo = false;
break;
- case atype_enum:
case atype_enum_nestable:
{
const struct lttng_integer_type *itype;
- if (field->type.atype == atype_enum) {
- itype = &field->type.u.legacy.basic.enumeration.container_type;
- } else {
- itype = &field->type.u.enum_nestable.container_type->u.integer;
- }
+ itype = &field->type.u.enum_nestable.container_type->u.integer;
if (itype->signedness)
load->object_type = OBJECT_TYPE_SIGNED_ENUM;
else
load->rev_bo = false;
break;
}
- case atype_array:
- if (field->type.u.legacy.array.elem_type.atype != atype_integer) {
- ERR("Array nesting only supports integer types.");
- return -EINVAL;
- }
- if (is_context) {
- load->object_type = OBJECT_TYPE_STRING;
- } else {
- if (field->type.u.legacy.array.elem_type.u.basic.integer.encoding == lttng_encode_none) {
- load->object_type = OBJECT_TYPE_ARRAY;
- load->field = field;
- } else {
- load->object_type = OBJECT_TYPE_STRING_SEQUENCE;
- }
- }
- break;
case atype_array_nestable:
if (field->type.u.array_nestable.elem_type->atype != atype_integer) {
ERR("Array nesting only supports integer types.");
}
}
break;
- case atype_sequence:
- if (field->type.u.legacy.sequence.elem_type.atype != atype_integer) {
- ERR("Sequence nesting only supports integer types.");
- return -EINVAL;
- }
- if (is_context) {
- load->object_type = OBJECT_TYPE_STRING;
- } else {
- if (field->type.u.legacy.sequence.elem_type.u.basic.integer.encoding == lttng_encode_none) {
- load->object_type = OBJECT_TYPE_SEQUENCE;
- load->field = field;
- } else {
- load->object_type = OBJECT_TYPE_STRING_SEQUENCE;
- }
- }
- break;
case atype_sequence_nestable:
if (field->type.u.sequence_nestable.elem_type->atype != atype_integer) {
ERR("Sequence nesting only supports integer types.");
case atype_dynamic:
load->object_type = OBJECT_TYPE_DYNAMIC;
break;
- case atype_struct:
- ERR("Structure type cannot be loaded.");
- return -EINVAL;
default:
ERR("Unknown type: %d", (int) field->type.atype);
return -EINVAL;
/* compute field offset on stack */
switch (field->type.atype) {
case atype_integer:
- case atype_enum:
case atype_enum_nestable:
field_offset += sizeof(int64_t);
break;
- case atype_array:
case atype_array_nestable:
- case atype_sequence:
case atype_sequence_nestable:
field_offset += sizeof(unsigned long);
field_offset += sizeof(void *);
/* compute field offset */
switch (fields[i].type.atype) {
case atype_integer:
- case atype_enum:
case atype_enum_nestable:
field_offset += sizeof(int64_t);
break;
- case atype_array:
case atype_array_nestable:
- case atype_sequence:
case atype_sequence_nestable:
field_offset += sizeof(unsigned long);
field_offset += sizeof(void *);
field_ref = (struct field_ref *) op->data;
switch (field->type.atype) {
case atype_integer:
- case atype_enum:
case atype_enum_nestable:
op->op = BYTECODE_OP_LOAD_FIELD_REF_S64;
break;
- case atype_array:
case atype_array_nestable:
- case atype_sequence:
case atype_sequence_nestable:
op->op = BYTECODE_OP_LOAD_FIELD_REF_SEQUENCE;
break;
field_ref = (struct field_ref *) op->data;
switch (ctx_field->event_field.type.atype) {
case atype_integer:
- case atype_enum:
case atype_enum_nestable:
op->op = BYTECODE_OP_GET_CONTEXT_REF_S64;
break;
/* Sequence and array supported as string */
case atype_string:
- case atype_array:
case atype_array_nestable:
- case atype_sequence:
case atype_sequence_nestable:
op->op = BYTECODE_OP_GET_CONTEXT_REF_STRING;
break;
case atype_integer:
field_align = type->u.integer.alignment;
break;
- case atype_array:
- {
- struct lttng_basic_type *btype;
-
- btype = &type->u.legacy.array.elem_type;
- switch (btype->atype) {
- case atype_integer:
- field_align = btype->u.basic.integer.alignment;
- break;
- case atype_string:
- break;
-
- case atype_array:
- case atype_array_nestable:
- case atype_sequence:
- case atype_sequence_nestable:
- default:
- WARN_ON_ONCE(1);
- break;
- }
- break;
- }
case atype_array_nestable:
{
const struct lttng_type *nested_type;
case atype_string:
break;
- case atype_array:
case atype_array_nestable:
- case atype_sequence:
case atype_sequence_nestable:
default:
WARN_ON_ONCE(1);
type->u.array_nestable.alignment);
break;
}
- case atype_sequence:
- {
- struct lttng_basic_type *btype;
-
- btype = &type->u.legacy.sequence.length_type;
- switch (btype->atype) {
- case atype_integer:
- field_align = btype->u.basic.integer.alignment;
- break;
-
- case atype_string:
- case atype_array:
- case atype_array_nestable:
- case atype_sequence:
- case atype_sequence_nestable:
- default:
- WARN_ON_ONCE(1);
- break;
- }
-
- btype = &type->u.legacy.sequence.elem_type;
- switch (btype->atype) {
- case atype_integer:
- field_align = max_t(size_t,
- field_align,
- btype->u.basic.integer.alignment);
- break;
-
- case atype_string:
- break;
-
- case atype_array:
- case atype_array_nestable:
- case atype_sequence:
- case atype_sequence_nestable:
- default:
- WARN_ON_ONCE(1);
- break;
- }
- break;
- }
case atype_sequence_nestable:
{
const struct lttng_type *nested_type;
case atype_string:
break;
- case atype_array:
case atype_array_nestable:
- case atype_sequence:
case atype_sequence_nestable:
default:
WARN_ON_ONCE(1);
break;
case atype_dynamic:
break;
- case atype_enum:
case atype_enum_nestable:
default:
WARN_ON_ONCE(1);
struct lttng_session *session)
{
switch (type->atype) {
- case atype_enum:
- {
- const struct lttng_enum_desc *enum_desc;
- int ret;
-
- enum_desc = type->u.legacy.basic.enumeration.desc;
- ret = lttng_enum_create(enum_desc, session);
- if (ret && ret != -EEXIST) {
- DBG("Unable to create enum error: (%d)", ret);
- return ret;
- }
- break;
- }
case atype_enum_nestable:
{
const struct lttng_enum_desc *enum_desc;
field = &(event->priv->desc->fields[i]);
switch (field->type.atype) {
- case atype_enum:
- enum_desc = field->type.u.legacy.basic.enumeration.desc;
- break;
case atype_enum_nestable:
enum_desc = field->type.u.enum_nestable.desc;
break;
case atype_string:
list_entry->field.type = LTTNG_UST_FIELD_STRING;
break;
- case atype_array:
- if (event_field->type.u.legacy.array.elem_type.atype != atype_integer
- || event_field->type.u.legacy.array.elem_type.u.basic.integer.encoding == lttng_encode_none)
- list_entry->field.type = LTTNG_UST_FIELD_OTHER;
- else
- list_entry->field.type = LTTNG_UST_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)
else
list_entry->field.type = LTTNG_UST_FIELD_STRING;
break;
- case atype_sequence:
- if (event_field->type.u.legacy.sequence.elem_type.atype != atype_integer
- || event_field->type.u.legacy.sequence.elem_type.u.basic.integer.encoding == lttng_encode_none)
- list_entry->field.type = LTTNG_UST_FIELD_OTHER;
- else
- list_entry->field.type = LTTNG_UST_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 atype_float:
list_entry->field.type = LTTNG_UST_FIELD_FLOAT;
break;
- case atype_enum: /* Fall-through */
case atype_enum_nestable:
list_entry->field.type = LTTNG_UST_FIELD_ENUM;
break;