Mirror of the lttng-dev mailing list
 help / color / mirror / Atom feed
From: gbastien+lttng@versatic.net (Geneviève Bastien)
Subject: [lttng-dev] [Patch LTTng-ust v2 2/7] Add empty macros to support CTF global enumerations
Date: Tue, 11 Feb 2014 16:35:31 -0500	[thread overview]
Message-ID: <1392154536-31191-3-git-send-email-gbastien+lttng@versatic.net> (raw)
In-Reply-To: <1392154536-31191-1-git-send-email-gbastien+lttng@versatic.net>

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




  parent reply	other threads:[~2014-02-11 21:35 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1390593885-7463-1-git-send-email-gbastien+lttng@versatic.net>
     [not found] ` <1390593885-7463-7-git-send-email-gbastien+lttng@versatic.net>
     [not found]   ` <1490865069.16181.1391132259063.JavaMail.zimbra@efficios.com>
     [not found]     ` <52EB0287.4000105@mentor.com>
2014-02-03 15:28       ` [lttng-dev] [Patch LTTng-ust 6/7] Add the macros to generate the data structures for CTF named enumerations Mathieu Desnoyers
2014-02-03 15:41         ` Stefan Seefeld
2014-02-03 16:17           ` Mathieu Desnoyers
     [not found] ` <1390593885-7463-2-git-send-email-gbastien+lttng@versatic.net>
     [not found]   ` <2139172576.16061.1391123211482.JavaMail.zimbra@efficios.com>
     [not found]     ` <52EC0746.2020200@versatic.net>
2014-02-03 15:31       ` [lttng-dev] [Patch LTTng-ust 1/7] Add or update data structures to support CTF named metadata Mathieu Desnoyers
2014-02-11 21:35 ` [lttng-dev] LTTng-ust: Add support of global types and CTF enumerations Geneviève Bastien
2014-02-11 21:35   ` [lttng-dev] [Patch LTTng-ust v2 1/7] Update data structures to support CTF global type declarations Geneviève Bastien
2014-02-11 21:35   ` Geneviève Bastien [this message]
2014-02-11 21:35   ` [lttng-dev] [Patch LTTng-ust v2 3/7] Add an example using CTF global type enumerations Geneviève Bastien
2014-02-11 21:35   ` [lttng-dev] [Patch LTTng-ust v2 4/7] Serialize the CTF global enumerations data structures for ust-comm Geneviève Bastien
2014-02-11 21:35   ` [lttng-dev] [Patch LTTng-ust v2 5/7] Send and receive serialized data for CTF global enumerations Geneviève Bastien
2014-02-11 21:35   ` [lttng-dev] [Patch LTTng-ust v2 6/7] Add the macros to generate the data structures " Geneviève Bastien
2014-02-11 21:35   ` [lttng-dev] [Patch LTTng-ust v2 7/7] Update the LTTng documentation with " Geneviève Bastien

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1392154536-31191-3-git-send-email-gbastien+lttng@versatic.net \
    --to=gbastien+lttng@versatic.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox