From 3e7622607bd37d4f19b8ef831c27b7b556acf6d5 Mon Sep 17 00:00:00 2001 From: Philippe Proulx Date: Mon, 4 Jul 2016 17:04:42 -0400 Subject: [PATCH] Add ctf_enum_auto() for autoincrementing enumeration values Signed-off-by: Philippe Proulx Signed-off-by: Mathieu Desnoyers --- include/lttng/ust-abi.h | 2 +- include/lttng/ust-ctl.h | 11 ++++++++++- include/lttng/ust-events.h | 11 ++++++++++- include/lttng/ust-tracepoint-event.h | 20 ++++++++++++++++++++ liblttng-ust-comm/lttng-ust-comm.c | 5 +++++ 5 files changed, 46 insertions(+), 3 deletions(-) diff --git a/include/lttng/ust-abi.h b/include/lttng/ust-abi.h index 379e0231..6e8f8d7b 100644 --- a/include/lttng/ust-abi.h +++ b/include/lttng/ust-abi.h @@ -42,7 +42,7 @@ #define LTTNG_UST_COMM_MAGIC 0xC57C57C5 /* Version for ABI between liblttng-ust, sessiond, consumerd */ -#define LTTNG_UST_ABI_MAJOR_VERSION 6 +#define LTTNG_UST_ABI_MAJOR_VERSION 7 #define LTTNG_UST_ABI_MINOR_VERSION 1 enum lttng_ust_instrumentation { diff --git a/include/lttng/ust-ctl.h b/include/lttng/ust-ctl.h index 20178234..7b750fd4 100644 --- a/include/lttng/ust-ctl.h +++ b/include/lttng/ust-ctl.h @@ -330,11 +330,20 @@ struct ustctl_enum_value { char padding[USTCTL_UST_ENUM_VALUE_PADDING]; } LTTNG_PACKED; +enum ustctl_ust_enum_entry_options { + USTCTL_UST_ENUM_ENTRY_OPTION_IS_AUTO = 1U << 0, +}; + #define USTCTL_UST_ENUM_ENTRY_PADDING 32 struct ustctl_enum_entry { struct ustctl_enum_value start, end; /* start and end are inclusive */ char string[LTTNG_UST_SYM_NAME_LEN]; - char padding[USTCTL_UST_ENUM_ENTRY_PADDING]; + union { + struct { + uint32_t options; + } LTTNG_PACKED extra; + char padding[USTCTL_UST_ENUM_ENTRY_PADDING]; + } u; } LTTNG_PACKED; #define USTCTL_UST_BASIC_TYPE_PADDING 296 diff --git a/include/lttng/ust-events.h b/include/lttng/ust-events.h index 5167ddee..61acf754 100644 --- a/include/lttng/ust-events.h +++ b/include/lttng/ust-events.h @@ -106,11 +106,20 @@ struct lttng_enum_value { unsigned int signedness:1; }; +enum lttng_enum_entry_options { + LTTNG_ENUM_ENTRY_OPTION_IS_AUTO = 1U << 0, +}; + #define LTTNG_UST_ENUM_ENTRY_PADDING 16 struct lttng_enum_entry { struct lttng_enum_value start, end; /* start and end are inclusive */ const char *string; - char padding[LTTNG_UST_ENUM_ENTRY_PADDING]; + union { + struct { + unsigned int options; + } LTTNG_PACKED extra; + char padding[LTTNG_UST_ENUM_ENTRY_PADDING]; + } u; }; #define __type_integer(_type, _byte_order, _base, _encoding) \ diff --git a/include/lttng/ust-tracepoint-event.h b/include/lttng/ust-tracepoint-event.h index 2b703dc5..0b4e5a26 100644 --- a/include/lttng/ust-tracepoint-event.h +++ b/include/lttng/ust-tracepoint-event.h @@ -161,6 +161,26 @@ static const char \ .string = (_string), \ }, +/* Enumeration entry (automatic value; follows the rules of CTF) */ +#undef ctf_enum_auto +#define ctf_enum_auto(_string) \ + { \ + .start = { \ + .value = -1ULL, \ + .signedness = 0, \ + }, \ + .end = { \ + .value = -1ULL, \ + .signedness = 0, \ + }, \ + .string = (_string), \ + .u = { \ + .extra = { \ + .options = LTTNG_ENUM_ENTRY_OPTION_IS_AUTO, \ + }, \ + }, \ + }, + #undef TP_ENUM_VALUES #define TP_ENUM_VALUES(...) \ __VA_ARGS__ diff --git a/liblttng-ust-comm/lttng-ust-comm.c b/liblttng-ust-comm/lttng-ust-comm.c index 4e9de57b..129ad8f2 100644 --- a/liblttng-ust-comm/lttng-ust-comm.c +++ b/liblttng-ust-comm/lttng-ust-comm.c @@ -1094,6 +1094,11 @@ int serialize_entries(struct ustctl_enum_entry **_entries, uentry->end.signedness = lentry->end.signedness; strncpy(uentry->string, lentry->string, LTTNG_UST_SYM_NAME_LEN); uentry->string[LTTNG_UST_SYM_NAME_LEN - 1] = '\0'; + + if (lentry->u.extra.options & LTTNG_ENUM_ENTRY_OPTION_IS_AUTO) { + uentry->u.extra.options |= + USTCTL_UST_ENUM_ENTRY_OPTION_IS_AUTO; + } } *_entries = entries; return 0; -- 2.34.1