From 08ad106103b693905300061cd61affd24ebbba6b Mon Sep 17 00:00:00 2001 From: Philippe Proulx Date: Mon, 4 Jul 2016 15:14:54 -0400 Subject: [PATCH] Add ctf_enum_auto() for autoincrementing enumeration values Signed-off-by: Philippe Proulx Signed-off-by: Mathieu Desnoyers --- lttng-events.c | 13 ++++++++++++- lttng-events.h | 3 +++ probes/lttng-tracepoint-event-impl.h | 18 ++++++++++++++++++ 3 files changed, 33 insertions(+), 1 deletion(-) 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__ -- 2.34.1