From: Philippe Proulx Date: Mon, 4 Jul 2016 19:14:54 +0000 (-0400) Subject: Add ctf_enum_auto() for autoincrementing enumeration values X-Git-Tag: v2.9.0-rc1~47 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=08ad106103b693905300061cd61affd24ebbba6b;p=lttng-modules.git Add ctf_enum_auto() for autoincrementing enumeration values Signed-off-by: Philippe Proulx Signed-off-by: Mathieu Desnoyers --- diff --git a/lttng-events.c b/lttng-events.c index bcf59da1..ef934374 100644 --- a/lttng-events.c +++ b/lttng-events.c @@ -1955,8 +1955,19 @@ int _lttng_enum_statedump(struct lttng_session *session, if (ret) goto end; } + ret = lttng_metadata_printf(session, "\""); + if (ret) + goto end; + + if (entry->options.is_auto) { + ret = lttng_metadata_printf(session, ",\n"); + if (ret) + goto end; + continue; + } + ret = lttng_metadata_printf(session, - "\" = "); + " = "); if (ret) goto end; if (entry->start.signedness) diff --git a/lttng-events.h b/lttng-events.h index 9e05e2f9..42a7b24b 100644 --- a/lttng-events.h +++ b/lttng-events.h @@ -77,6 +77,9 @@ struct lttng_enum_value { struct lttng_enum_entry { struct lttng_enum_value start, end; /* start and end are inclusive */ const char *string; + struct { + unsigned int is_auto:1; + } options; }; #define __type_integer(_type, _size, _alignment, _signedness, \ diff --git a/probes/lttng-tracepoint-event-impl.h b/probes/lttng-tracepoint-event-impl.h index ed7072cf..e1c40829 100644 --- a/probes/lttng-tracepoint-event-impl.h +++ b/probes/lttng-tracepoint-event-impl.h @@ -222,6 +222,24 @@ void __event_template_proto___##_name(void); .string = (_string), \ }, +/* Enumeration entry (automatic value; follows the rules of CTF) */ +#undef ctf_enum_auto +#define ctf_enum_auto(_string) \ + { \ + .start = { \ + .signedness = -1, \ + .value = -1, \ + }, \ + .end = { \ + .signedness = -1, \ + .value = -1, \ + }, \ + .string = (_string), \ + .options = { \ + .is_auto = 1, \ + } \ + }, + #undef TP_ENUM_VALUES #define TP_ENUM_VALUES(...) \ __VA_ARGS__