[lttng-dev] [Patch LTTng-ust v2 2/7] Add empty macros to support CTF global enumerations
Geneviève Bastien
gbastien+lttng at versatic.net
Tue Feb 11 16:35:31 EST 2014
The macros are initialized so that CTF enumerations can be used in tracepoints.
They do not do anything yet.
Signed-off-by: Geneviève Bastien <gbastien+lttng at versatic.net>
---
include/lttng/tracepoint.h | 44 ++++++++++++++++++++++++++++
include/lttng/ust-tracepoint-event-nowrite.h | 4 +++
include/lttng/ust-tracepoint-event-reset.h | 12 ++++++++
include/lttng/ust-tracepoint-event-write.h | 4 +++
4 files changed, 64 insertions(+)
diff --git a/include/lttng/tracepoint.h b/include/lttng/tracepoint.h
index 66e2abd..8a49a22 100644
--- a/include/lttng/tracepoint.h
+++ b/include/lttng/tracepoint.h
@@ -421,6 +421,50 @@ __tracepoints__ptrs_destroy(void)
/* The following declarations must be outside re-inclusion protection. */
+#ifndef TRACEPOINT_ENUM
+
+/*
+ * Tracepoint Enumerations
+ *
+ * The enumeration is a mapping between an integer, or range of integers, and
+ * a string. It can be used to have a more compact trace in cases where the
+ * possible values for a field are limited:
+ *
+ * An example:
+ *
+ * TRACEPOINT_ENUM(someproject_component, enumname, int
+ * TP_ENUM_VALUES(
+ * ctf_enum_value("even", 0)
+ * ctf_enum_value("uneven", 1)
+ * ctf_enum_range("twoto4", 2, 4)
+ * ctf_enum_value("five", 5)
+ * )
+ * )
+ *
+ * Where "someproject_component" is the name of the component this enumeration
+ * belongs to and "enumname" identifies this enumeration. The "int" is the data
+ * type of the container and can be anything that can be translated to a ctf
+ * integer (int, short, char, etc). Inside the TP_ENUM_VALUES macro is the
+ * actual mapping. Each string value can map to either a single value with
+ * ctf_enum_value or a range of values with ctf_enum_range.
+ *
+ * Enumeration ranges may overlap, but the behavior is implementation-defined,
+ * each trace reader will handle overlapping as it wishes.
+ *
+ * That enumeration can then be used in a field inside the TP_FIELD macro using
+ * the following line:
+ *
+ * ctf_enum(someproject_component, enumname, enumfield, enumval)
+ *
+ * Where "someproject_component" and "enumname" match those in the
+ * TRACEPOINT_ENUM, "enumfield" is the name of the field and "enumval" is the
+ * value.
+ */
+
+#define TRACEPOINT_ENUM(provider, name, type, values)
+
+#endif /* #ifndef TRACEPOINT_ENUM */
+
#ifndef TRACEPOINT_EVENT
/*
diff --git a/include/lttng/ust-tracepoint-event-nowrite.h b/include/lttng/ust-tracepoint-event-nowrite.h
index 98d9791..7f5b1d9 100644
--- a/include/lttng/ust-tracepoint-event-nowrite.h
+++ b/include/lttng/ust-tracepoint-event-nowrite.h
@@ -49,3 +49,7 @@
#undef ctf_string_nowrite
#define ctf_string_nowrite(_item, _src) \
_ctf_string(_item, _src, 1)
+
+#undef ctf_enum_nowrite
+#define ctf_enum_nowrite(_provider, _name, _item, _src) \
+ _ctf_enum(_provider, _name, _item, _src, 1)
diff --git a/include/lttng/ust-tracepoint-event-reset.h b/include/lttng/ust-tracepoint-event-reset.h
index 412883d..58e3428 100644
--- a/include/lttng/ust-tracepoint-event-reset.h
+++ b/include/lttng/ust-tracepoint-event-reset.h
@@ -28,6 +28,9 @@
#undef TRACEPOINT_EVENT_INSTANCE
#define TRACEPOINT_EVENT_INSTANCE(_provider, _template, _name, _args)
+#undef TRACEPOINT_ENUM
+#define TRACEPOINT_ENUM(_provider, _name, _type, _values)
+
#undef TP_ARGS
#define TP_ARGS(...)
@@ -61,6 +64,9 @@
#undef _ctf_string
#define _ctf_string(_item, _src, _nowrite)
+#undef _ctf_enum
+#define _ctf_enum(_provider, _name, _item, _src, _nowrite)
+
/* "write" */
#undef ctf_integer
#define ctf_integer(_type, _item, _src)
@@ -92,6 +98,9 @@
#undef ctf_string
#define ctf_string(_item, _src)
+#undef ctf_enum
+#define ctf_enum(_provider, _name, _item, _src)
+
/* "nowrite" */
#undef ctf_integer_nowrite
#define ctf_integer_nowrite(_type, _item, _src)
@@ -113,3 +122,6 @@
#undef ctf_string_nowrite
#define ctf_string_nowrite(_item, _src)
+
+#undef ctf_enum_nowrite
+#define ctf_enum_nowrite(_provider, _name, _item, _src)
diff --git a/include/lttng/ust-tracepoint-event-write.h b/include/lttng/ust-tracepoint-event-write.h
index 44218d2..7dd06ed 100644
--- a/include/lttng/ust-tracepoint-event-write.h
+++ b/include/lttng/ust-tracepoint-event-write.h
@@ -61,3 +61,7 @@
#undef ctf_string
#define ctf_string(_item, _src) \
_ctf_string(_item, _src, 0)
+
+#undef ctf_enum
+#define ctf_enum(_provider, _name, _item, _src) \
+ _ctf_enum(_provider, _name, _item, _src, 0)
--
1.8.5.4
More information about the lttng-dev
mailing list