LTTNG_ENUM_ENTRY_OPTION_IS_AUTO = 1U << 0,
};
-#define LTTNG_UST_ENUM_ENTRY_PADDING 16
-struct lttng_enum_entry {
+/*
+ * Enumeration entry description
+ *
+ * IMPORTANT: this structure is part of the ABI between the probe and
+ * UST. Fields need to be only added at the end, never reordered, never
+ * removed.
+ *
+ * The field @struct_size should be used to determine the size of the
+ * structure. It should be queried before using additional fields added
+ * at the end of the structure.
+ */
+
+struct lttng_ust_enum_entry {
+ uint32_t struct_size;
+
struct lttng_enum_value start, end; /* start and end are inclusive */
const char *string;
- union {
- struct {
- unsigned int options;
- } LTTNG_PACKED extra;
- char padding[LTTNG_UST_ENUM_ENTRY_PADDING];
- } u;
+ unsigned int options;
+
+ /* End of base ABI. Fields below should be used after checking struct_size. */
};
#define __type_integer(_type, _byte_order, _base, _encoding) \
enum lttng_string_encodings encoding;
} string;
struct {
- const struct lttng_enum_desc *desc; /* Enumeration mapping */
+ const struct lttng_ust_enum_desc *desc; /* Enumeration mapping */
struct lttng_type *container_type;
} enum_nestable;
struct {
} u;
};
-#define LTTNG_UST_ENUM_TYPE_PADDING 24
-struct lttng_enum_desc {
+/*
+ * Enumeration description
+ *
+ * IMPORTANT: this structure is part of the ABI between the probe and
+ * UST. Fields need to be only added at the end, never reordered, never
+ * removed.
+ *
+ * The field @struct_size should be used to determine the size of the
+ * structure. It should be queried before using additional fields added
+ * at the end of the structure.
+ */
+
+struct lttng_ust_enum_desc {
+ uint32_t struct_size;
+
const char *name;
- const struct lttng_enum_entry *entries;
+ const struct lttng_ust_enum_entry **entries;
unsigned int nr_entries;
- char padding[LTTNG_UST_ENUM_TYPE_PADDING];
+
+ /* End of base ABI. Fields below should be used after checking struct_size. */
};
/*
};
struct lttng_enum {
- const struct lttng_enum_desc *desc;
+ const struct lttng_ust_enum_desc *desc;
struct lttng_session *session;
struct cds_list_head node; /* Enum list in session */
struct cds_hlist_node hlist; /* Session ht of enums */
/* Enumeration entry (single value) */
#undef ctf_enum_value
#define ctf_enum_value(_string, _value) \
- { \
+ __LTTNG_COMPOUND_LITERAL(struct lttng_ust_enum_entry, { \
+ .struct_size = sizeof(struct lttng_ust_enum_entry), \
.start = { \
.value = lttng_is_signed_type(__typeof__(_value)) ? \
(long long) (_value) : (_value), \
.signedness = lttng_is_signed_type(__typeof__(_value)), \
}, \
.string = (_string), \
- },
+ }),
/* Enumeration entry (range) */
#undef ctf_enum_range
#define ctf_enum_range(_string, _range_start, _range_end) \
- { \
+ __LTTNG_COMPOUND_LITERAL(struct lttng_ust_enum_entry, { \
+ .struct_size = sizeof(struct lttng_ust_enum_entry), \
.start = { \
.value = lttng_is_signed_type(__typeof__(_range_start)) ? \
(long long) (_range_start) : (_range_start), \
.signedness = lttng_is_signed_type(__typeof__(_range_end)), \
}, \
.string = (_string), \
- },
+ }),
/* Enumeration entry (automatic value; follows the rules of CTF) */
#undef ctf_enum_auto
-#define ctf_enum_auto(_string) \
- { \
+#define ctf_enum_auto(_string) \
+ __LTTNG_COMPOUND_LITERAL(struct lttng_ust_enum_entry, { \
+ .struct_size = sizeof(struct lttng_ust_enum_entry), \
.start = { \
.value = -1ULL, \
.signedness = 0, \
.signedness = 0, \
}, \
.string = (_string), \
- .u = { \
- .extra = { \
- .options = LTTNG_ENUM_ENTRY_OPTION_IS_AUTO, \
- }, \
- }, \
- },
+ .options = LTTNG_ENUM_ENTRY_OPTION_IS_AUTO, \
+ }),
#undef TP_ENUM_VALUES
#define TP_ENUM_VALUES(...) \
#undef TRACEPOINT_ENUM
#define TRACEPOINT_ENUM(_provider, _name, _values) \
- const struct lttng_enum_entry __enum_values__##_provider##_##_name[] = { \
+ const struct lttng_ust_enum_entry *__enum_values__##_provider##_##_name[] = { \
_values \
ctf_enum_value("", 0) /* Dummy, 0-len array forbidden by C99. */ \
};
#undef TRACEPOINT_ENUM
#define TRACEPOINT_ENUM(_provider, _name, _values) \
- static const struct lttng_enum_desc __enum_##_provider##_##_name = { \
+ static const 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, \
struct lttng_ust_event_field;
struct lttng_ctx_field;
-struct lttng_enum_entry;
+struct lttng_ust_enum_entry;
struct lttng_integer_type;
struct lttng_session;
int session_objd, /* session descriptor */
const char *enum_name, /* enum name (input) */
size_t nr_entries, /* entries */
- const struct lttng_enum_entry *entries,
+ const struct lttng_ust_enum_entry **entries,
uint64_t *id); /* enum id (output) */
/*
static
int serialize_entries(struct ustctl_enum_entry **_entries,
size_t nr_entries,
- const struct lttng_enum_entry *lttng_entries)
+ const struct lttng_ust_enum_entry **lttng_entries)
{
struct ustctl_enum_entry *entries;
int i;
return -ENOMEM;
for (i = 0; i < nr_entries; i++) {
struct ustctl_enum_entry *uentry;
- const struct lttng_enum_entry *lentry;
+ const struct lttng_ust_enum_entry *lentry;
uentry = &entries[i];
- lentry = <tng_entries[i];
+ lentry = lttng_entries[i];
uentry->start.value = lentry->start.value;
uentry->start.signedness = lentry->start.signedness;
strncpy(uentry->string, lentry->string, LTTNG_UST_ABI_SYM_NAME_LEN);
uentry->string[LTTNG_UST_ABI_SYM_NAME_LEN - 1] = '\0';
- if (lentry->u.extra.options & LTTNG_ENUM_ENTRY_OPTION_IS_AUTO) {
+ if (lentry->options & LTTNG_ENUM_ENTRY_OPTION_IS_AUTO) {
uentry->u.extra.options |=
USTCTL_UST_ENUM_ENTRY_OPTION_IS_AUTO;
}
int session_objd, /* session descriptor */
const char *enum_name, /* enum name (input) */
size_t nr_entries, /* entries */
- const struct lttng_enum_entry *lttng_entries,
+ const struct lttng_ust_enum_entry **lttng_entries,
uint64_t *id)
{
ssize_t len;
}
static
-int lttng_enum_create(const struct lttng_enum_desc *desc,
+int lttng_enum_create(const struct lttng_ust_enum_desc *desc,
struct lttng_session *session)
{
const char *enum_name = desc->name;
switch (type->atype) {
case atype_enum_nestable:
{
- const struct lttng_enum_desc *enum_desc;
+ const struct lttng_ust_enum_desc *enum_desc;
int ret;
enum_desc = type->u.enum_nestable.desc;
case atype_dynamic:
{
const struct lttng_ust_event_field *tag_field_generic;
- const struct lttng_enum_desc *enum_desc;
+ const struct lttng_ust_enum_desc *enum_desc;
int ret;
tag_field_generic = lttng_ust_dynamic_type_tag_field();
/* Destroy enums of the current event. */
for (i = 0; i < event_recorder->parent->priv->desc->nr_fields; i++) {
- const struct lttng_enum_desc *enum_desc;
+ const struct lttng_ust_enum_desc *enum_desc;
const struct lttng_ust_event_field *field;
struct lttng_enum *curr_enum;
#include <ust-dynamic-type.h>
#define ctf_enum_value(_string, _value) \
- { \
+ __LTTNG_COMPOUND_LITERAL(struct lttng_ust_enum_entry, { \
+ .struct_size = sizeof(struct lttng_ust_enum_entry), \
.start = { \
.signedness = lttng_is_signed_type(__typeof__(_value)), \
.value = lttng_is_signed_type(__typeof__(_value)) ? \
(long long) (_value) : (_value), \
}, \
.string = (_string), \
- },
+ }),
-static const struct lttng_enum_entry dt_enum[_NR_LTTNG_UST_DYNAMIC_TYPES] = {
+static const 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_enum_desc dt_enum_desc = {
+static const struct lttng_ust_enum_desc dt_enum_desc = {
.name = "dynamic_type_enum",
.entries = dt_enum,
.nr_entries = LTTNG_ARRAY_SIZE(dt_enum),
* Needed by comm layer.
*/
struct lttng_enum *lttng_ust_enum_get_from_desc(struct lttng_session *session,
- const struct lttng_enum_desc *enum_desc)
+ const struct lttng_ust_enum_desc *enum_desc)
{
struct lttng_enum *_enum;
struct cds_hlist_head *head;
LTTNG_HIDDEN
struct lttng_enum *lttng_ust_enum_get_from_desc(struct lttng_session *session,
- const struct lttng_enum_desc *enum_desc);
+ const struct lttng_ust_enum_desc *enum_desc);
LTTNG_HIDDEN
int lttng_abi_create_root_handle(void);