Mirror of the lttng-dev mailing list
 help / color / mirror / Atom feed
* [lttng-dev] [Patch LTTng-ust 6/7] Add the macros to generate the data structures for CTF named enumerations
       [not found]     ` <52EB0287.4000105@mentor.com>
@ 2014-02-03 15:28       ` Mathieu Desnoyers
  2014-02-03 15:41         ` Stefan Seefeld
  0 siblings, 1 reply; 12+ messages in thread
From: Mathieu Desnoyers @ 2014-02-03 15:28 UTC (permalink / raw)


----- Original Message -----
> From: "Stefan Seefeld" <stefan_seefeld@mentor.com>
> To: lttng-dev at lists.lttng.org
> Sent: Thursday, January 30, 2014 8:55:19 PM
> Subject: Re: [lttng-dev] [Patch LTTng-ust 6/7] Add the macros to generate the data structures for CTF named
> enumerations
> 
> On 01/30/2014 08:37 PM, Mathieu Desnoyers wrote:
> > ----- Original Message -----
> >> From: "Genevi?ve Bastien" <gbastien+lttng@versatic.net>
> >> To: lttng-dev at lists.lttng.org
> >> Sent: Friday, January 24, 2014 3:04:44 PM
> >> Subject: [lttng-dev] [Patch LTTng-ust 6/7] Add the macros to generate the
> >> 	data structures for CTF named enumerations
> >>
> >> Fills the macros to initialize the metadata for a tracepoint.
> >>
> >> From this patch on, the named metadata are enabled.
> > Now that I think about it, "named metadata" does not seem to be
> > semantically clear.
> > Perhaps we could change this to "global type declarations" ? Because this
> > is really
> > what it is: type declarations that are in the global scope of the metadata.
> > This applies
> > to all other patches in this series.
> 
> Mathieu,
> 
> I may be misunderstanding what you intend to relabel as "global type
> declarations", but I believe the term is too restrictive.
> I'm following this discussion with interest, as I have another use-case
> for meta-data which might be implementable very much like the named
> enums: constant or "event-static" fields. For example, we may want to
> store numeric values in events that need a (constant) scale factor (a
> unit of measurement), which would be well represented in meta-data, as
> opposed to redundantly inside events.
> And so, while I agree to your characterization of named enumerations as
> type declarations, I'm still looking at the mechanism as enabling the
> storage of named meta-data.

Hi Stefan,

Let's try to make sure I understand your intent here. Let's say we have
an event with a "weight" field (uint32_t). You would like to have
a multiplicative factor (e.g. *1000 for "kg") as a second field, that would
be entirely known from the metadata (pretty much a C literal in the metadata,
so it does not have to be repeated for each event).

There are various ways to do this I imagine: e.g.:

* Using the typing system

event {
  ...
  fields := struct {
    integer { size = 32; signed = false; align = 32; scale = 1000; } weight;
  };
};

* Another way to do this would be to associate a format string with the event:

event {
  ...
  fields := struct {
    integer { size = 32; signed = false; align = 32; } weight;
  };
  format = ("The weight is %u kg.", weight);
};

* Yet another way would be to associate the format string with the struct type:

event {
  ...
  fields := struct {
    integer { size = 32; signed = false; align = 32; } weight;
  } format ("The weight is %u kg.", weight);
};

But I don't see anything there that requires adding any top-level construct
to the CTF metadata. Hence, I am tempted to keep the name "global type declaration"
for the part of metadata located in the "global" section (opposed to within a
trace, env, stream, and event scope). Anyway, all we can declare there are types,
so it makes sense to use this name. If we ever add something to the CTF spec in the
future that is global but is not a type, then we'll have to extend the interfaces
and implementations (which should be expected if we extend the CTF spec).

Thanks,

Mathieu

> 
> 
> Thanks,
>         Stefan
> 
> --
> Stefan Seefeld
> CodeSourcery / Mentor Graphics
> http://www.mentor.com/embedded-software/
> 
> 
> _______________________________________________
> lttng-dev mailing list
> lttng-dev at lists.lttng.org
> http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev
> 

-- 
Mathieu Desnoyers
EfficiOS Inc.
http://www.efficios.com



^ permalink raw reply	[flat|nested] 12+ messages in thread

* [lttng-dev] [Patch LTTng-ust 1/7] Add or update data structures to support CTF named metadata
       [not found]     ` <52EC0746.2020200@versatic.net>
@ 2014-02-03 15:31       ` Mathieu Desnoyers
  0 siblings, 0 replies; 12+ messages in thread
From: Mathieu Desnoyers @ 2014-02-03 15:31 UTC (permalink / raw)


----- Original Message -----
> From: "Genevi?ve Bastien" <gbastien@versatic.net>
> To: "Mathieu Desnoyers" <mathieu.desnoyers at efficios.com>, "Genevi?ve Bastien" <gbastien+lttng at versatic.net>
> Cc: lttng-dev at lists.lttng.org
> Sent: Friday, January 31, 2014 3:27:50 PM
> Subject: Re: [lttng-dev] [Patch LTTng-ust 1/7] Add or update data structures to	support CTF named metadata
> 
> Thanks for reviewing all those patches! I'll make the changes soon when
> the naming of this concept is settled (see Stefan's email). "Global
> types" sounds good.

OK. Replied in a separate email for this one.

> 
> Only thing where answer is needed inline below.
> 
> On 14-01-30 06:06 PM, Mathieu Desnoyers wrote:
> > ----- Original Message -----
> >> From: "Genevi?ve Bastien" <gbastien+lttng@versatic.net>
> >> To: lttng-dev at lists.lttng.org
> >> Sent: Friday, January 24, 2014 3:04:39 PM
> >> Subject: [lttng-dev] [Patch LTTng-ust 1/7] Add or update data structures
> >> to	support CTF named metadata
> >>
> >> The structures match those in LTTng-tools to support named metadata in
> >> general
> >> and CTF enumerations in particular.
> >>
> >> Signed-off-by: Genevi?ve Bastien <gbastien+lttng at versatic.net>
> >> ---
> >>   include/lttng/ust-ctl.h    | 36 +++++++++++++++++++++++++++++++++++-
> >>   include/lttng/ust-events.h | 20 +++++++++++++++++++-
> >>   2 files changed, 54 insertions(+), 2 deletions(-)
> >>
> >> diff --git a/include/lttng/ust-ctl.h b/include/lttng/ust-ctl.h
> >> index 40e831e..29c89fe 100644
> >> --- a/include/lttng/ust-ctl.h
> >> +++ b/include/lttng/ust-ctl.h
> >> @@ -295,13 +295,23 @@ struct ustctl_float_type {
> >>   	char padding[USTCTL_UST_FLOAT_TYPE_PADDING];
> >>   } LTTNG_PACKED;
> >>   
> >> -#define USTCTL_UST_BASIC_TYPE_PADDING	296
> >> +#define USTCTL_UST_ENUM_ENTRY_PADDING	296
> >> +struct ustctl_enum_entry {
> >> +	unsigned long long start, end;	/* start and end are inclusive */
> >> +	char string[LTTNG_UST_SYM_NAME_LEN];
> >> +	char padding[USTCTL_UST_ENUM_ENTRY_PADDING];
> >> +};
> >> +
> >> +#define USTCTL_UST_BASIC_TYPE_PADDING	40
> >>   union _ustctl_basic_type {
> >>   	struct ustctl_integer_type integer;
> >>   	struct {
> >>   		enum ustctl_string_encodings encoding;
> >>   	} string;
> >>   	struct ustctl_float_type _float;
> >> +	struct {
> >> +		char name[LTTNG_UST_SYM_NAME_LEN];
> >> +	} enumeration;
> >>   	char padding[USTCTL_UST_BASIC_TYPE_PADDING];
> >>   } LTTNG_PACKED;
> >>   
> >> @@ -329,6 +339,30 @@ struct ustctl_type {
> >>   	} u;
> >>   } LTTNG_PACKED;
> >>   
> >> +#define USTCTL_UST_ENUM_TYPE_PADDING	296
> >> +struct ustctl_enum {
> >> +	char name[LTTNG_UST_SYM_NAME_LEN];
> >> +	struct ustctl_integer_type container_type;
> >> +	struct ustctl_enum_entry *entries;
> >> +	unsigned int len;
> >> +	char padding[USTCTL_UST_ENUM_TYPE_PADDING];
> >> +} LTTNG_PACKED;
> >> +
> >> +/* CTF Metadata types for named metadata described outside event
> >> descriptions */
> >> +enum ustctl_metadata_types {
> >> +	ustctl_mtype_enum,
> >> +	NR_USTCTL_METADATA_TYPES,
> >> +};
> >> +
> >> +#define USTCTL_UST_NAMED_METADATA_PADDING 640
> >> +struct ustctl_named_metadata {
> >> +	enum ustctl_metadata_types mtype;
> > OK to use the enumeration, but define this mtype field as a fixed-size
> > field (e.g. int32_t). (yes, I did the mistake to use enums in the ABI
> > in the past). Currently, compilers use 32-bit int typically, but they
> > have some freedom in the choice of the backing type.
> >
> >> +	union {
> >> +		struct ustctl_enum ctf_enum;
> >> +		char padding[USTCTL_UST_NAMED_METADATA_PADDING];
> >> +	} u;
> >> +};
> >> +
> >>   #define USTCTL_UST_FIELD_PADDING	28
> >>   struct ustctl_field {
> >>   	char name[LTTNG_UST_SYM_NAME_LEN];
> >> diff --git a/include/lttng/ust-events.h b/include/lttng/ust-events.h
> >> index d93c912..260b221 100644
> >> --- a/include/lttng/ust-events.h
> >> +++ b/include/lttng/ust-events.h
> >> @@ -89,6 +89,12 @@ enum lttng_string_encodings {
> >>   	NR_STRING_ENCODINGS,
> >>   };
> >>   
> >> +/* CTF Metadata types for named metadata described outside event
> >> descriptions */
> >> +enum lttng_metadata_types {
> >> +	mtype_enum,
> >> +	NR_METADATA_TYPES,
> >> +};
> >> +
> >>   #define LTTNG_UST_ENUM_ENTRY_PADDING	16
> >>   struct lttng_enum_entry {
> >>   	unsigned long long start, end;	/* start and end are inclusive */
> >> @@ -204,12 +210,22 @@ struct lttng_type {
> >>   #define LTTNG_UST_ENUM_TYPE_PADDING	24
> >>   struct lttng_enum {
> >>   	const char *name;
> >> -	struct lttng_type container_type;
> >> +	struct lttng_integer_type container_type;
> > doing this change assumes that lttng_enum was never used in lttng-ust, is
> > that true ?
> Are you asking me or the list? I haven't seen any reference to it and
> you told me on IRC that [you thought] it hadn't been used anywhere ever.
> But I don't know about the past of UST... For more security, maybe I
> should just add a new field at the end of this struct?

I think it should be safe to assume that nobody used it, since it's not
supported neither at the instrumentation API level, nor used by lttng-ust,
nor written into the CTF metadata by lttng-sessiond. You might want to
document this assumption in the patch changelog though.

Thanks,

Mathieu

> 
> Thanks,
> 
> Genevi?ve
> >
> > Thanks,
> >
> > Mathieu
> >
> >>   	const struct lttng_enum_entry *entries;
> >>   	unsigned int len;
> >>   	char padding[LTTNG_UST_ENUM_TYPE_PADDING];
> >>   };
> >>   
> >> +#define LTTNG_UST_NAMED_METADATA_PADDING	60
> >> +struct lttng_named_metadata {
> >> +	enum lttng_metadata_types mtype;
> >> +	unsigned int nowrite; /* inherited from the field using it */
> >> +	union {
> >> +		const struct lttng_enum *ctf_enum;
> >> +		char padding[LTTNG_UST_NAMED_METADATA_PADDING];
> >> +	} u;
> >> +};
> >> +
> >>   /*
> >>    * Event field description
> >>    *
> >> @@ -267,6 +283,8 @@ struct lttng_event_desc {
> >>   	union {
> >>   		struct {
> >>   			const char **model_emf_uri;
> >> +			unsigned int nr_metadata;
> >> +			const struct lttng_named_metadata *named_metadata;
> >>   		} ext;
> >>   		char padding[LTTNG_UST_EVENT_DESC_PADDING];
> >>   	} u;
> >> --
> >> 1.8.5.3
> >>
> >>
> >> _______________________________________________
> >> lttng-dev mailing list
> >> lttng-dev at lists.lttng.org
> >> http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev
> >>
> 
> 

-- 
Mathieu Desnoyers
EfficiOS Inc.
http://www.efficios.com



^ permalink raw reply	[flat|nested] 12+ messages in thread

* [lttng-dev] [Patch LTTng-ust 6/7] Add the macros to generate the data structures for CTF named enumerations
  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
  0 siblings, 1 reply; 12+ messages in thread
From: Stefan Seefeld @ 2014-02-03 15:41 UTC (permalink / raw)


On 02/03/2014 10:28 AM, Mathieu Desnoyers wrote:

> Hi Stefan,
> 
> Let's try to make sure I understand your intent here. Let's say we have
> an event with a "weight" field (uint32_t). You would like to have
> a multiplicative factor (e.g. *1000 for "kg") as a second field, that would
> be entirely known from the metadata (pretty much a C literal in the metadata,
> so it does not have to be repeated for each event).

Right. The analogy with a C literal isn't entirely sufficient, as there
is a range of situations where in fact "constant" doesn't map to
compile-time constant in C/C++. Thus...

> There are various ways to do this I imagine: e.g.:
> 
> * Using the typing system


[...]

...the typing system can't quite capture values that are immutable
within a running session, but not quite constant in the sense that they
can be captured in a type system.

So perhaps another way to look at it is like a static class member, for
which storage isn't part of each instance of the class, but rather
somewhere that's associated with all instances of the class...

> But I don't see anything there that requires adding any top-level construct
> to the CTF metadata.

...and that "somewhere" would naturally be the metadata section of the
traces.

> Hence, I am tempted to keep the name "global type declaration"
> for the part of metadata located in the "global" section (opposed to within a
> trace, env, stream, and event scope). Anyway, all we can declare there are types,
> so it makes sense to use this name. If we ever add something to the CTF spec in the
> future that is global but is not a type, then we'll have to extend the interfaces
> and implementations (which should be expected if we extend the CTF spec).

Right. I wasn't arguing so much against the use of "global type
declaration" for the case of named enums, but merely wanted to point out
that the mechanism could be extended to cover non-type-related metadata.

Thanks,
		Stefan


-- 
Stefan Seefeld
CodeSourcery / Mentor Graphics
http://www.mentor.com/embedded-software/



^ permalink raw reply	[flat|nested] 12+ messages in thread

* [lttng-dev] [Patch LTTng-ust 6/7] Add the macros to generate the data structures for CTF named enumerations
  2014-02-03 15:41         ` Stefan Seefeld
@ 2014-02-03 16:17           ` Mathieu Desnoyers
  0 siblings, 0 replies; 12+ messages in thread
From: Mathieu Desnoyers @ 2014-02-03 16:17 UTC (permalink / raw)


----- Original Message -----
> From: "Stefan Seefeld" <stefan_seefeld@mentor.com>
> To: "Mathieu Desnoyers" <mathieu.desnoyers at efficios.com>
> Cc: lttng-dev at lists.lttng.org
> Sent: Monday, February 3, 2014 10:41:14 AM
> Subject: Re: [lttng-dev] [Patch LTTng-ust 6/7] Add the macros to generate the data structures for CTF named
> enumerations
> 
> On 02/03/2014 10:28 AM, Mathieu Desnoyers wrote:
> 
> > Hi Stefan,
> > 
> > Let's try to make sure I understand your intent here. Let's say we have
> > an event with a "weight" field (uint32_t). You would like to have
> > a multiplicative factor (e.g. *1000 for "kg") as a second field, that would
> > be entirely known from the metadata (pretty much a C literal in the
> > metadata,
> > so it does not have to be repeated for each event).
> 
> Right. The analogy with a C literal isn't entirely sufficient, as there
> is a range of situations where in fact "constant" doesn't map to
> compile-time constant in C/C++. Thus...

Can you provide a concrete example of what you envision ? What would
this look like an an "extended" CTF metadata ?

Thanks,

Mathieu

> 
> > There are various ways to do this I imagine: e.g.:
> > 
> > * Using the typing system
> 
> 
> [...]
> 
> ...the typing system can't quite capture values that are immutable
> within a running session, but not quite constant in the sense that they
> can be captured in a type system.
> 
> So perhaps another way to look at it is like a static class member, for
> which storage isn't part of each instance of the class, but rather
> somewhere that's associated with all instances of the class...
> 
> > But I don't see anything there that requires adding any top-level construct
> > to the CTF metadata.
> 
> ...and that "somewhere" would naturally be the metadata section of the
> traces.
> 
> > Hence, I am tempted to keep the name "global type declaration"
> > for the part of metadata located in the "global" section (opposed to within
> > a
> > trace, env, stream, and event scope). Anyway, all we can declare there are
> > types,
> > so it makes sense to use this name. If we ever add something to the CTF
> > spec in the
> > future that is global but is not a type, then we'll have to extend the
> > interfaces
> > and implementations (which should be expected if we extend the CTF spec).
> 
> Right. I wasn't arguing so much against the use of "global type
> declaration" for the case of named enums, but merely wanted to point out
> that the mechanism could be extended to cover non-type-related metadata.
> 
> Thanks,
> 		Stefan
> 
> 
> --
> Stefan Seefeld
> CodeSourcery / Mentor Graphics
> http://www.mentor.com/embedded-software/
> 

-- 
Mathieu Desnoyers
EfficiOS Inc.
http://www.efficios.com



^ permalink raw reply	[flat|nested] 12+ messages in thread

* [lttng-dev] LTTng-ust: Add support of global types and CTF enumerations
       [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] ` <1390593885-7463-2-git-send-email-gbastien+lttng@versatic.net>
@ 2014-02-11 21:35 ` 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
                     ` (6 more replies)
  2 siblings, 7 replies; 12+ messages in thread
From: Geneviève Bastien @ 2014-02-11 21:35 UTC (permalink / raw)


I made the corrections to the patches.




^ permalink raw reply	[flat|nested] 12+ messages in thread

* [lttng-dev] [Patch LTTng-ust v2 1/7] Update data structures to support CTF global type declarations
  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   ` Geneviève Bastien
  2014-02-11 21:35   ` [lttng-dev] [Patch LTTng-ust v2 2/7] Add empty macros to support CTF global enumerations Geneviève Bastien
                     ` (5 subsequent siblings)
  6 siblings, 0 replies; 12+ messages in thread
From: Geneviève Bastien @ 2014-02-11 21:35 UTC (permalink / raw)


The structures match those in LTTng-tools to support global type declarations
in general and CTF enumerations in particular.

Note: This patch uses the lttng_enum structure in ust-events.h and modifies
the container_type field. This structure was not used and has never been used
as far as we know.

Signed-off-by: Genevi?ve Bastien <gbastien+lttng at versatic.net>
---
 include/lttng/ust-ctl.h    | 36 +++++++++++++++++++++++++++++++++++-
 include/lttng/ust-events.h | 20 +++++++++++++++++++-
 2 files changed, 54 insertions(+), 2 deletions(-)

diff --git a/include/lttng/ust-ctl.h b/include/lttng/ust-ctl.h
index 40e831e..783492b 100644
--- a/include/lttng/ust-ctl.h
+++ b/include/lttng/ust-ctl.h
@@ -295,13 +295,23 @@ struct ustctl_float_type {
 	char padding[USTCTL_UST_FLOAT_TYPE_PADDING];
 } LTTNG_PACKED;
 
-#define USTCTL_UST_BASIC_TYPE_PADDING	296
+#define USTCTL_UST_ENUM_ENTRY_PADDING	296
+struct ustctl_enum_entry {
+	unsigned long long start, end;	/* start and end are inclusive */
+	char string[LTTNG_UST_SYM_NAME_LEN];
+	char padding[USTCTL_UST_ENUM_ENTRY_PADDING];
+};
+
+#define USTCTL_UST_BASIC_TYPE_PADDING	40
 union _ustctl_basic_type {
 	struct ustctl_integer_type integer;
 	struct {
 		enum ustctl_string_encodings encoding;
 	} string;
 	struct ustctl_float_type _float;
+	struct {
+		char name[LTTNG_UST_SYM_NAME_LEN];
+	} enumeration;
 	char padding[USTCTL_UST_BASIC_TYPE_PADDING];
 } LTTNG_PACKED;
 
@@ -329,6 +339,30 @@ struct ustctl_type {
 	} u;
 } LTTNG_PACKED;
 
+#define USTCTL_UST_ENUM_TYPE_PADDING	296
+struct ustctl_enum {
+	char name[LTTNG_UST_SYM_NAME_LEN];
+	struct ustctl_integer_type container_type;
+	struct ustctl_enum_entry *entries;
+	unsigned int len;
+	char padding[USTCTL_UST_ENUM_TYPE_PADDING];
+} LTTNG_PACKED;
+
+/* CTF categories for global types declared outside event descriptions */
+enum ustctl_global_type_categories {
+	ustctl_mtype_enum,
+	NR_USTCTL_GLOBAL_TYPES,
+};
+
+#define USTCTL_UST_GLOBAL_TYPES_PADDING 640
+struct ustctl_global_type_decl {
+	uint32_t mtype;
+	union {
+		struct ustctl_enum ctf_enum;
+		char padding[USTCTL_UST_GLOBAL_TYPES_PADDING];
+	} u;
+};
+
 #define USTCTL_UST_FIELD_PADDING	28
 struct ustctl_field {
 	char name[LTTNG_UST_SYM_NAME_LEN];
diff --git a/include/lttng/ust-events.h b/include/lttng/ust-events.h
index d93c912..a683de8 100644
--- a/include/lttng/ust-events.h
+++ b/include/lttng/ust-events.h
@@ -89,6 +89,12 @@ enum lttng_string_encodings {
 	NR_STRING_ENCODINGS,
 };
 
+/* CTF categories for global types declared outside event descriptions */
+enum lttng_global_type_categories {
+	mtype_enum,
+	NR_GLOBAL_TYPES,
+};
+
 #define LTTNG_UST_ENUM_ENTRY_PADDING	16
 struct lttng_enum_entry {
 	unsigned long long start, end;	/* start and end are inclusive */
@@ -204,12 +210,22 @@ struct lttng_type {
 #define LTTNG_UST_ENUM_TYPE_PADDING	24
 struct lttng_enum {
 	const char *name;
-	struct lttng_type container_type;
+	struct lttng_integer_type container_type;
 	const struct lttng_enum_entry *entries;
 	unsigned int len;
 	char padding[LTTNG_UST_ENUM_TYPE_PADDING];
 };
 
+#define LTTNG_UST_GLOBAL_TYPES_PADDING	60
+struct lttng_global_type_decl {
+	enum lttng_global_type_categories mtype;
+	unsigned int nowrite; /* inherited from the field using it */
+	union {
+		const struct lttng_enum *ctf_enum;
+		char padding[LTTNG_UST_GLOBAL_TYPES_PADDING];
+	} u;
+};
+
 /*
  * Event field description
  *
@@ -267,6 +283,8 @@ struct lttng_event_desc {
 	union {
 		struct {
 			const char **model_emf_uri;
+			unsigned int nr_global_type_decl;
+			const struct lttng_global_type_decl *global_type_decl;
 		} ext;
 		char padding[LTTNG_UST_EVENT_DESC_PADDING];
 	} u;
-- 
1.8.5.4




^ permalink raw reply	[flat|nested] 12+ messages in thread

* [lttng-dev] [Patch LTTng-ust v2 2/7] Add empty macros to support CTF global enumerations
  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
  2014-02-11 21:35   ` [lttng-dev] [Patch LTTng-ust v2 3/7] Add an example using CTF global type enumerations Geneviève Bastien
                     ` (4 subsequent siblings)
  6 siblings, 0 replies; 12+ messages in thread
From: Geneviève Bastien @ 2014-02-11 21:35 UTC (permalink / raw)


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




^ permalink raw reply	[flat|nested] 12+ messages in thread

* [lttng-dev] [Patch LTTng-ust v2 3/7] Add an example using CTF global type enumerations
  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   ` [lttng-dev] [Patch LTTng-ust v2 2/7] Add empty macros to support CTF global enumerations Geneviève Bastien
@ 2014-02-11 21:35   ` 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
                     ` (3 subsequent siblings)
  6 siblings, 0 replies; 12+ messages in thread
From: Geneviève Bastien @ 2014-02-11 21:35 UTC (permalink / raw)


A new test example is introduced in tests/ctf-global-types. This test
application will be used to test the support of CTF global type declarations.
For now, it contains two tracepoints that use a global enumeration.

Signed-off-by: Genevi?ve Bastien <gbastien+lttng at versatic.net>
---
 configure.ac                                       |  1 +
 tests/Makefile.am                                  |  2 +-
 tests/ctf-global-types/Makefile.am                 | 13 ++++
 tests/ctf-global-types/README                      |  3 +
 tests/ctf-global-types/ctf-global-types.c          | 46 ++++++++++++++
 tests/ctf-global-types/tp.c                        | 26 ++++++++
 .../ctf-global-types/ust_tests_ctf_global_types.h  | 71 ++++++++++++++++++++++
 7 files changed, 161 insertions(+), 1 deletion(-)
 create mode 100644 tests/ctf-global-types/Makefile.am
 create mode 100644 tests/ctf-global-types/README
 create mode 100644 tests/ctf-global-types/ctf-global-types.c
 create mode 100644 tests/ctf-global-types/tp.c
 create mode 100644 tests/ctf-global-types/ust_tests_ctf_global_types.h

diff --git a/configure.ac b/configure.ac
index 72a0314..710a390 100644
--- a/configure.ac
+++ b/configure.ac
@@ -295,6 +295,7 @@ AC_CONFIG_FILES([
 	liblttng-ust-cyg-profile/Makefile
 	tools/Makefile
 	tests/Makefile
+	tests/ctf-global-types/Makefile
 	tests/hello/Makefile
 	tests/hello.cxx/Makefile
 	tests/same_line_tracepoint/Makefile
diff --git a/tests/Makefile.am b/tests/Makefile.am
index b5166f9..c3f9e71 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -1,4 +1,4 @@
-SUBDIRS = utils hello same_line_tracepoint snprintf benchmark
+SUBDIRS = utils hello same_line_tracepoint snprintf benchmark ctf-global-types
 
 if CXX_WORKS
 SUBDIRS += hello.cxx
diff --git a/tests/ctf-global-types/Makefile.am b/tests/ctf-global-types/Makefile.am
new file mode 100644
index 0000000..2ae0b54
--- /dev/null
+++ b/tests/ctf-global-types/Makefile.am
@@ -0,0 +1,13 @@
+AM_CPPFLAGS = -I$(top_srcdir)/include -I$(top_builddir)/include -Wsystem-headers
+
+noinst_PROGRAMS = ctf-global-types
+ctf_global_types_SOURCES = ctf-global-types.c tp.c ust_tests_ctf_global_types.h
+ctf_global_types_LDADD = $(top_builddir)/liblttng-ust/liblttng-ust.la
+ctf_global_types_CFLAGS = -Werror=old-style-definition
+
+if LTTNG_UST_BUILD_WITH_LIBDL
+ctf_global_types_LDADD += -ldl
+endif
+if LTTNG_UST_BUILD_WITH_LIBC_DL
+ctf_global_types_LDADD += -lc
+endif
diff --git a/tests/ctf-global-types/README b/tests/ctf-global-types/README
new file mode 100644
index 0000000..0544476
--- /dev/null
+++ b/tests/ctf-global-types/README
@@ -0,0 +1,3 @@
+This is a "hello world" application used to verify that an instrumented program
+with tracepoints using global type declarations in CTF metadata can be built
+successfully.
diff --git a/tests/ctf-global-types/ctf-global-types.c b/tests/ctf-global-types/ctf-global-types.c
new file mode 100644
index 0000000..81b69e1
--- /dev/null
+++ b/tests/ctf-global-types/ctf-global-types.c
@@ -0,0 +1,46 @@
+/*
+ * Copyright (C) 2014  Genevi?ve Bastien <gbastien at versatic.net>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; version 2.1 of
+ * the License.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA
+ */
+
+#include <unistd.h>
+
+#define TRACEPOINT_DEFINE
+#include "ust_tests_ctf_global_types.h"
+
+int main(int argc, char **argv)
+{
+	int i;
+	int delay = 0;
+
+	if (argc == 2)
+		delay = atoi(argv[1]);
+
+	fprintf(stderr, "Hello, World!\n");
+
+	sleep(delay);
+
+	fprintf(stderr, "Tracing... ");
+	for (i = 0; i < 100; i++) {
+		tracepoint(ust_tests_ctf_global_types, tptest, i, (i % 6));
+	}
+
+	for (i = 0; i < 10; i++) {
+		tracepoint(ust_tests_ctf_global_types, tptest_bis, i, (i % 5));
+	}
+	fprintf(stderr, " done.\n");
+	return 0;
+}
diff --git a/tests/ctf-global-types/tp.c b/tests/ctf-global-types/tp.c
new file mode 100644
index 0000000..581e9e7
--- /dev/null
+++ b/tests/ctf-global-types/tp.c
@@ -0,0 +1,26 @@
+/*
+ * tp.c
+ *
+ * Copyright (c) 2014 Genevi?ve Bastien <gbastien at versatic.net>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#define TRACEPOINT_CREATE_PROBES
+#include "ust_tests_ctf_global_types.h"
diff --git a/tests/ctf-global-types/ust_tests_ctf_global_types.h b/tests/ctf-global-types/ust_tests_ctf_global_types.h
new file mode 100644
index 0000000..a1c0527
--- /dev/null
+++ b/tests/ctf-global-types/ust_tests_ctf_global_types.h
@@ -0,0 +1,71 @@
+#undef TRACEPOINT_PROVIDER
+#define TRACEPOINT_PROVIDER ust_tests_ctf_global_types
+
+#if !defined(_TRACEPOINT_UST_TESTS_CTF_GLOBAL_TYPES_H) || defined(TRACEPOINT_HEADER_MULTI_READ)
+#define _TRACEPOINT_UST_TESTS_CTF_GLOBAL_TYPES_H
+
+/*
+ * Copyright (C) 2014 Genevi?ve Bastien <gbastien at versatic.net>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include <lttng/tracepoint.h>
+
+TRACEPOINT_ENUM(ust_tests_ctf_global_types, testenum, 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)
+	)
+)
+
+/*
+ * Enumeration field is used twice to make sure the global type declaration
+ * is entered only once in the metadata file.
+ */
+TRACEPOINT_EVENT(ust_tests_ctf_global_types, tptest,
+	TP_ARGS(int, anint, int, enumval),
+	TP_FIELDS(
+		ctf_integer(int, intfield, anint)
+		ctf_enum(ust_tests_ctf_global_types, testenum, enumfield, enumval)
+		ctf_enum(ust_tests_ctf_global_types, testenum, enumfield_bis, enumval)
+	)
+)
+
+/*
+ * Another tracepoint using the global types to make sure each global type is
+ * entered only once in the metadata file.
+ */
+TRACEPOINT_EVENT(ust_tests_ctf_global_types, tptest_bis,
+	TP_ARGS(int, anint, int, enumval),
+	TP_FIELDS(
+		ctf_integer(int, intfield, anint)
+		ctf_enum(ust_tests_ctf_global_types, testenum, enumfield, enumval)
+	)
+)
+
+#endif /* _TRACEPOINT_UST_TESTS_CTF_GLOBAL_TYPES_H */
+
+#undef TRACEPOINT_INCLUDE
+#define TRACEPOINT_INCLUDE "./ust_tests_ctf_global_types.h"
+
+/* This part must be outside ifdef protection */
+#include <lttng/tracepoint-event.h>
-- 
1.8.5.4




^ permalink raw reply	[flat|nested] 12+ messages in thread

* [lttng-dev] [Patch LTTng-ust v2 4/7] Serialize the CTF global enumerations data structures for ust-comm
  2014-02-11 21:35 ` [lttng-dev] LTTng-ust: Add support of global types and CTF enumerations Geneviève Bastien
                     ` (2 preceding siblings ...)
  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   ` 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
                     ` (2 subsequent siblings)
  6 siblings, 0 replies; 12+ messages in thread
From: Geneviève Bastien @ 2014-02-11 21:35 UTC (permalink / raw)


The CTF enumerations global type are serialized to be ready to be sent to and
received by the session daemon.

Signed-off-by: Genevi?ve Bastien <gbastien+lttng at versatic.net>
---
 include/lttng/ust-tracepoint-event.h |   7 +-
 liblttng-ust-comm/lttng-ust-comm.c   | 124 ++++++++++++++++++++++++++++++++++-
 2 files changed, 129 insertions(+), 2 deletions(-)

diff --git a/include/lttng/ust-tracepoint-event.h b/include/lttng/ust-tracepoint-event.h
index be58030..5745cb5 100644
--- a/include/lttng/ust-tracepoint-event.h
+++ b/include/lttng/ust-tracepoint-event.h
@@ -644,7 +644,12 @@ const struct lttng_event_desc __event_desc___##_provider##_##_name = {	       \
 	.nr_fields = _TP_ARRAY_SIZE(__event_fields___##_provider##___##_template), \
 	.loglevel = &__ref_loglevel___##_provider##___##_name,		       \
 	.signature = __tp_event_signature___##_provider##___##_template,       \
-	.u = { .ext = { .model_emf_uri = &__ref_model_emf_uri___##_provider##___##_name } }, \
+	.u = { .ext =							       \
+		{							       \
+		  .model_emf_uri = &__ref_model_emf_uri___##_provider##___##_name, \
+		  .nr_global_type_decl = 0,				       \
+		},							       \
+	},								       \
 };
 
 #include TRACEPOINT_INCLUDE
diff --git a/liblttng-ust-comm/lttng-ust-comm.c b/liblttng-ust-comm/lttng-ust-comm.c
index 751ad2e..67c6381 100644
--- a/liblttng-ust-comm/lttng-ust-comm.c
+++ b/liblttng-ust-comm/lttng-ust-comm.c
@@ -733,6 +733,13 @@ int serialize_basic_type(enum ustctl_abstract_types *uatype,
 		break;
 	}
 	case atype_enum:
+	{
+		strncpy(ubt->enumeration.name, lbt->enumeration.name,
+				LTTNG_UST_SYM_NAME_LEN);
+		ubt->enumeration.name[LTTNG_UST_SYM_NAME_LEN - 1] = '\0';
+		*uatype = ustctl_atype_enum;
+		break;
+	}
 	case atype_array:
 	case atype_sequence:
 	default:
@@ -750,6 +757,7 @@ int serialize_one_type(struct ustctl_type *ut, const struct lttng_type *lt)
 	case atype_integer:
 	case atype_float:
 	case atype_string:
+	case atype_enum:
 		ret = serialize_basic_type(&ut->atype, lt->atype,
 			&ut->u.basic, &lt->u.basic);
 		if (ret)
@@ -792,7 +800,6 @@ int serialize_one_type(struct ustctl_type *ut, const struct lttng_type *lt)
 		ut->atype = ustctl_atype_sequence;
 		break;
 	}
-	case atype_enum:
 	default:
 		return -EINVAL;
 	}
@@ -841,6 +848,121 @@ error_type:
 }
 
 static
+int serialize_enum(struct ustctl_enum *uenum,
+		const struct lttng_enum *lenum)
+{
+	int i;
+	struct ustctl_integer_type *uit;
+	const struct lttng_integer_type *lit;
+	struct ustctl_enum_entry *entries;
+
+	strncpy(uenum->name, lenum->name, LTTNG_UST_SYM_NAME_LEN);
+	uenum->name[LTTNG_UST_SYM_NAME_LEN - 1] = '\0';
+
+	/* Serialize the container_type */
+	uit = &uenum->container_type;
+	lit = &lenum->container_type;
+	uit->size = lit->size;
+	uit->signedness = lit->signedness;
+	uit->reverse_byte_order = lit->reverse_byte_order;
+	uit->base = lit->base;
+	if (serialize_string_encoding(&uit->encoding, lit->encoding))
+		return -EINVAL;
+	uit->alignment = lit->alignment;
+
+	/* Serialize the entries */
+	entries = zmalloc(lenum->len * sizeof(*entries));
+	if (!entries)
+		return -ENOMEM;
+	for (i = 0; i < lenum->len; i++) {
+		struct ustctl_enum_entry *uentry;
+		const struct lttng_enum_entry *lentry;
+
+		uentry = &entries[i];
+		lentry = &lenum->entries[i];
+
+		uentry->start = lentry->start;
+		uentry->end = lentry->end;
+		strncpy(uentry->string, lentry->string, LTTNG_UST_SYM_NAME_LEN);
+		uentry->string[LTTNG_UST_SYM_NAME_LEN - 1] = '\0';
+	}
+	uenum->entries = entries;
+	uenum->len = lenum->len;
+	return 0;
+}
+
+static
+int serialize_global_type_decl(size_t *_nr_write_global_type_decl,
+		struct ustctl_global_type_decl **ustctl_global_type,
+		size_t nr_global_type_decl,
+		const struct lttng_global_type_decl *lttng_global_type)
+{
+	struct ustctl_global_type_decl *global_type_decl;
+	int i, ret;
+	size_t nr_write_global_type_decl = 0;
+
+	global_type_decl = zmalloc(nr_global_type_decl * sizeof(*global_type_decl));
+	if (!global_type_decl)
+		return -ENOMEM;
+
+	for (i = 0; i < nr_global_type_decl; i++) {
+		struct ustctl_global_type_decl *f;
+		const struct lttng_global_type_decl *lf;
+
+		f = &global_type_decl[nr_write_global_type_decl];
+		lf = &lttng_global_type[i];
+
+		/* skip 'nowrite' fields */
+		if (lf->nowrite)
+			continue;
+
+		/* do the serialize here */
+		switch (lf->mtype) {
+		case mtype_enum:
+		{
+			struct ustctl_enum *ue;
+			const struct lttng_enum *le;
+
+			ue = &f->u.ctf_enum;
+			le = lf->u.ctf_enum;
+			ret = serialize_enum(ue, le);
+			if (ret)
+				goto error;
+
+			f->mtype = ustctl_mtype_enum;
+			break;
+		}
+		default:
+			ret = -EINVAL;
+			goto error;
+		}
+
+		nr_write_global_type_decl++;
+	}
+
+	*_nr_write_global_type_decl = nr_write_global_type_decl;
+	*ustctl_global_type = global_type_decl;
+	return 0;
+
+error:
+	/* Free what has been allocated during global type serialization */
+	for (i = 0; i < nr_write_global_type_decl; i++) {
+		struct ustctl_global_type_decl *m;
+		m = &global_type_decl[i];
+		switch (m->mtype) {
+		case ustctl_mtype_enum:
+			free(m->u.ctf_enum.entries);
+			break;
+		default:
+			break;
+		}
+	}
+	free(global_type_decl);
+	return ret;
+
+}
+
+static
 int serialize_ctx_fields(size_t *_nr_write_fields,
 		struct ustctl_field **ustctl_fields,
 		size_t nr_fields,
-- 
1.8.5.4




^ permalink raw reply	[flat|nested] 12+ messages in thread

* [lttng-dev] [Patch LTTng-ust v2 5/7] Send and receive serialized data for CTF global enumerations
  2014-02-11 21:35 ` [lttng-dev] LTTng-ust: Add support of global types and CTF enumerations Geneviève Bastien
                     ` (3 preceding siblings ...)
  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   ` 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
  6 siblings, 0 replies; 12+ messages in thread
From: Geneviève Bastien @ 2014-02-11 21:35 UTC (permalink / raw)


Updates the functions used for the communication between UST and the session
daemon so that global type declarations can be sent and received. The
description of the global type declarations follows the event that uses them.
The extra fields for each global type category follow the descriptions of all
global type declarations.

Signed-off-by: Genevi?ve Bastien <gbastien+lttng at versatic.net>
---
 include/lttng/ust-ctl.h            |   4 +-
 include/ust-comm.h                 |   8 ++-
 liblttng-ust-comm/lttng-ust-comm.c | 111 ++++++++++++++++++++++++++++++++-----
 liblttng-ust-ctl/ustctl.c          |  74 ++++++++++++++++++++++++-
 liblttng-ust/lttng-events.c        |   4 +-
 5 files changed, 182 insertions(+), 19 deletions(-)

diff --git a/include/lttng/ust-ctl.h b/include/lttng/ust-ctl.h
index 783492b..b44fb41 100644
--- a/include/lttng/ust-ctl.h
+++ b/include/lttng/ust-ctl.h
@@ -421,7 +421,9 @@ int ustctl_recv_register_event(int sock,
 					 */
 	size_t *nr_fields,
 	struct ustctl_field **fields,
-	char **model_emf_uri);
+	char **model_emf_uri,
+	size_t *nr_global_type_decl,
+	struct ustctl_global_type_decl **global_type_decl);
 
 /*
  * Returns 0 on success, negative error value on error.
diff --git a/include/ust-comm.h b/include/ust-comm.h
index b9bbb39..ed46364 100644
--- a/include/ust-comm.h
+++ b/include/ust-comm.h
@@ -49,6 +49,7 @@
 #define LTTNG_UST_COMM_REG_MSG_PADDING			64
 
 struct lttng_event_field;
+struct lttng_global_type_decl;
 struct lttng_ctx_field;
 
 struct ustctl_reg_msg {
@@ -127,7 +128,7 @@ struct ustcomm_notify_hdr {
 	uint32_t notify_cmd;
 } LTTNG_PACKED;
 
-#define USTCOMM_NOTIFY_EVENT_MSG_PADDING	32
+#define USTCOMM_NOTIFY_EVENT_MSG_PADDING	28
 struct ustcomm_notify_event_msg {
 	uint32_t session_objd;
 	uint32_t channel_objd;
@@ -136,6 +137,7 @@ struct ustcomm_notify_event_msg {
 	uint32_t signature_len;
 	uint32_t fields_len;
 	uint32_t model_emf_uri_len;
+	uint32_t global_type_decl_len;
 	char padding[USTCOMM_NOTIFY_EVENT_MSG_PADDING];
 	/* followed by signature, fields, and model_emf_uri */
 } LTTNG_PACKED;
@@ -221,7 +223,9 @@ int ustcomm_register_event(int sock,
 	size_t nr_fields,		/* fields */
 	const struct lttng_event_field *fields,
 	const char *model_emf_uri,
-	uint32_t *id);			/* event id (output) */
+	uint32_t *id,			/* event id (output) */
+	size_t nr_global_type_decl,
+	const struct lttng_global_type_decl *lttng_global_types); /* global type declarations */
 
 /*
  * Returns 0 on success, negative error value on error.
diff --git a/liblttng-ust-comm/lttng-ust-comm.c b/liblttng-ust-comm/lttng-ust-comm.c
index 67c6381..a21a195 100644
--- a/liblttng-ust-comm/lttng-ust-comm.c
+++ b/liblttng-ust-comm/lttng-ust-comm.c
@@ -1015,7 +1015,9 @@ int ustcomm_register_event(int sock,
 	size_t nr_fields,		/* fields */
 	const struct lttng_event_field *lttng_fields,
 	const char *model_emf_uri,
-	uint32_t *id)			/* event id (output) */
+	uint32_t *id,			/* event id (output) */
+	size_t nr_global_type_decl,
+	const struct lttng_global_type_decl *lttng_global_types) /* global type declarations */
 {
 	ssize_t len;
 	struct {
@@ -1026,10 +1028,12 @@ int ustcomm_register_event(int sock,
 		struct ustcomm_notify_hdr header;
 		struct ustcomm_notify_event_reply r;
 	} reply;
-	size_t signature_len, fields_len, model_emf_uri_len;
+	size_t signature_len, fields_len, model_emf_uri_len, global_type_len;
 	struct ustctl_field *fields = NULL;
+	struct ustctl_global_type_decl *global_type_decl = NULL;
 	size_t nr_write_fields = 0;
-	int ret;
+	size_t nr_write_global_type_decl = 0;
+	int ret, i;
 
 	memset(&msg, 0, sizeof(msg));
 	msg.header.notify_cmd = USTCTL_NOTIFY_CMD_EVENT;
@@ -1057,14 +1061,26 @@ int ustcomm_register_event(int sock,
 		model_emf_uri_len = 0;
 	}
 	msg.m.model_emf_uri_len = model_emf_uri_len;
+	/* Calculate global type declarations len, serialize global types. */
+	if (nr_global_type_decl > 0) {
+		ret = serialize_global_type_decl(&nr_write_global_type_decl, &global_type_decl,
+				nr_global_type_decl, lttng_global_types);
+		if (ret) {
+			free(fields);
+			return ret;
+		}
+	}
+	global_type_len = sizeof(*global_type_decl) * nr_write_global_type_decl;
+	msg.m.global_type_decl_len = global_type_len;
+
 	len = ustcomm_send_unix_sock(sock, &msg, sizeof(msg));
 	if (len > 0 && len != sizeof(msg)) {
-		free(fields);
-		return -EIO;
+		ret = -EIO;
+		goto error_fields;
 	}
 	if (len < 0) {
-		free(fields);
-		return len;
+		ret = len;
+		goto error_fields;
 	}
 
 	/* send signature */
@@ -1083,10 +1099,12 @@ int ustcomm_register_event(int sock,
 		len = ustcomm_send_unix_sock(sock, fields, fields_len);
 		free(fields);
 		if (len > 0 && len != fields_len) {
-			return -EIO;
+			ret = -EIO;
+			goto error_global_type;
 		}
 		if (len < 0) {
-			return len;
+			ret = len;
+			goto error_global_type;
 		}
 	} else {
 		free(fields);
@@ -1096,10 +1114,58 @@ int ustcomm_register_event(int sock,
 		/* send model_emf_uri */
 		len = ustcomm_send_unix_sock(sock, model_emf_uri,
 				model_emf_uri_len);
-		if (len > 0 && len != model_emf_uri_len)
-			return -EIO;
-		if (len < 0)
-			return len;
+		if (len > 0 && len != model_emf_uri_len) {
+			ret = -EIO;
+			goto error_global_type;
+		}
+		if (len < 0) {
+			ret = len;
+			goto error_global_type;
+		}
+	}
+
+	/* Send global type declarations */
+	if (global_type_len > 0) {
+		len = ustcomm_send_unix_sock(sock, global_type_decl, global_type_len);
+		DBG("Sending global type declarations for event %s.\n", event_name);
+		if (len > 0 && len != global_type_len) {
+			goto error_global_type;
+		}
+		if (len < 0) {
+			goto error_global_type;
+		}
+		/* Send extra global types information */
+		for (i = 0; i < nr_write_global_type_decl; i++) {
+			struct ustctl_global_type_decl *one_global_type;
+			one_global_type = &global_type_decl[i];
+
+			switch (one_global_type->mtype) {
+			case ustctl_mtype_enum:
+			{
+				int entry_len = one_global_type->u.ctf_enum.len * sizeof(*one_global_type->u.ctf_enum.entries);
+
+				/* Send the entries */
+				DBG("Sending entries for global type enumeration %s.\n",
+						one_global_type->u.ctf_enum.name);
+				len = ustcomm_send_unix_sock(sock, one_global_type->u.ctf_enum.entries, entry_len);
+				free(one_global_type->u.ctf_enum.entries);
+				one_global_type->u.ctf_enum.entries = NULL;
+				if (len > 0 && len != entry_len) {
+					goto error_global_type;
+				}
+				if (len < 0) {
+					goto error_global_type;
+				}
+				break;
+			}
+			default:
+				break;
+			}
+		}
+		free(global_type_decl);
+
+	} else {
+		free(global_type_decl);
 	}
 
 	/* receive reply */
@@ -1133,6 +1199,25 @@ int ustcomm_register_event(int sock,
 			return len;
 		}
 	}
+
+error_fields:
+	free(fields);
+error_global_type:
+	/* First free dynamically allocated content in global_type */
+	for (i = 0; i < nr_write_global_type_decl; i++) {
+		struct ustctl_global_type_decl *one_global_type;
+		one_global_type = &global_type_decl[i];
+
+		switch (one_global_type->mtype) {
+		case ustctl_mtype_enum:
+			free(one_global_type->u.ctf_enum.entries);
+			break;
+		default:
+			break;
+		}
+	}
+	free(global_type_decl);
+	return ret;
 }
 
 /*
diff --git a/liblttng-ust-ctl/ustctl.c b/liblttng-ust-ctl/ustctl.c
index 00d9802..f1cfbb5 100644
--- a/liblttng-ust-ctl/ustctl.c
+++ b/liblttng-ust-ctl/ustctl.c
@@ -1724,13 +1724,17 @@ int ustctl_recv_register_event(int sock,
 	char **signature,
 	size_t *nr_fields,
 	struct ustctl_field **fields,
-	char **model_emf_uri)
+	char **model_emf_uri,
+	size_t *nr_global_type_decl,
+	struct ustctl_global_type_decl **global_type_decl)
 {
 	ssize_t len;
 	struct ustcomm_notify_event_msg msg;
-	size_t signature_len, fields_len, model_emf_uri_len;
+	size_t signature_len, fields_len, model_emf_uri_len, global_type_decl_len;
 	char *a_sign = NULL, *a_model_emf_uri = NULL;
 	struct ustctl_field *a_fields = NULL;
+	struct ustctl_global_type_decl *a_global_type = NULL;
+	int i;
 
 	len = ustcomm_recv_unix_sock(sock, &msg, sizeof(msg));
 	if (len > 0 && len != sizeof(msg))
@@ -1754,6 +1758,12 @@ int ustctl_recv_register_event(int sock,
 
 	model_emf_uri_len = msg.model_emf_uri_len;
 
+	global_type_decl_len = msg.global_type_decl_len;
+
+	if (global_type_decl_len % sizeof(*a_global_type) != 0) {
+		return -EINVAL;
+	}
+
 	/* recv signature. contains at least \0. */
 	a_sign = zmalloc(signature_len);
 	if (!a_sign)
@@ -1818,13 +1828,73 @@ int ustctl_recv_register_event(int sock,
 		a_model_emf_uri[model_emf_uri_len - 1] = '\0';
 	}
 
+	/* recv global types */
+	if (global_type_decl_len) {
+		a_global_type = zmalloc(global_type_decl_len);
+		if (!a_global_type) {
+			len = -ENOMEM;
+			goto signature_error;
+		}
+		len = ustcomm_recv_unix_sock(sock, a_global_type, global_type_decl_len);
+		DBG("Received global types for event %s.\n", event_name);
+		if (len > 0 && len != global_type_decl_len) {
+			len = -EIO;
+			goto global_type_error;
+		}
+		if (len == 0) {
+			len = -EPIPE;
+			goto global_type_error;
+		}
+		if (len < 0) {
+			goto global_type_error;
+		}
+		/* Receive extra information per global type category */
+		for (i = 0; i < global_type_decl_len / sizeof(*a_global_type); i++) {
+			struct ustctl_global_type_decl *one_global_type;
+			one_global_type = &a_global_type[i];
+
+			switch (one_global_type->mtype) {
+			case ustctl_mtype_enum:
+			{
+				int entry_len = one_global_type->u.ctf_enum.len * sizeof(*one_global_type->u.ctf_enum.entries);
+				/* Send the entries */
+				one_global_type->u.ctf_enum.entries = zmalloc(entry_len);
+				if (!one_global_type->u.ctf_enum.entries) {
+					len = -ENOMEM;
+					goto global_type_error;
+				}
+				len = ustcomm_recv_unix_sock(sock, one_global_type->u.ctf_enum.entries, entry_len);
+				DBG("Received entries for enum %s.\n", one_global_type->u.ctf_enum.name);
+				if (len > 0 && len != entry_len) {
+					len = -EIO;
+					goto global_type_error;
+				}
+				if (len == 0) {
+					len = -EPIPE;
+					goto global_type_error;
+				}
+				if (len < 0) {
+					goto global_type_error;
+				}
+				break;
+			}
+			default:
+				break;
+			}
+		}
+	}
+
 	*signature = a_sign;
 	*nr_fields = fields_len / sizeof(*a_fields);
 	*fields = a_fields;
 	*model_emf_uri = a_model_emf_uri;
+	*nr_global_type_decl = global_type_decl_len / sizeof(*a_global_type);
+	*global_type_decl = a_global_type;
 
 	return 0;
 
+global_type_error:
+	free(a_global_type);
 model_error:
 	free(a_model_emf_uri);
 fields_error:
diff --git a/liblttng-ust/lttng-events.c b/liblttng-ust/lttng-events.c
index 6e16cf2..c0db4a7 100644
--- a/liblttng-ust/lttng-events.c
+++ b/liblttng-ust/lttng-events.c
@@ -430,7 +430,9 @@ int lttng_event_create(const struct lttng_event_desc *desc,
 		desc->nr_fields,
 		desc->fields,
 		uri,
-		&event->id);
+		&event->id,
+		desc->u.ext.nr_global_type_decl,
+		desc->u.ext.global_type_decl);
 	if (ret < 0) {
 		DBG("Error (%d) registering event to sessiond", ret);
 		goto sessiond_register_error;
-- 
1.8.5.4




^ permalink raw reply	[flat|nested] 12+ messages in thread

* [lttng-dev] [Patch LTTng-ust v2 6/7] Add the macros to generate the data structures for CTF global enumerations
  2014-02-11 21:35 ` [lttng-dev] LTTng-ust: Add support of global types and CTF enumerations Geneviève Bastien
                     ` (4 preceding siblings ...)
  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   ` Geneviève Bastien
  2014-02-11 21:35   ` [lttng-dev] [Patch LTTng-ust v2 7/7] Update the LTTng documentation with " Geneviève Bastien
  6 siblings, 0 replies; 12+ messages in thread
From: Geneviève Bastien @ 2014-02-11 21:35 UTC (permalink / raw)


Fills the macros to initialize the global type declarations data for a
tracepoint.

From this patch on, the global type declarations are enabled.

Signed-off-by: Genevi?ve Bastien <gbastien+lttng at versatic.net>
---
 include/lttng/ust-tracepoint-event.h | 143 ++++++++++++++++++++++++++++++++++-
 1 file changed, 140 insertions(+), 3 deletions(-)

diff --git a/include/lttng/ust-tracepoint-event.h b/include/lttng/ust-tracepoint-event.h
index 5745cb5..39c7dc1 100644
--- a/include/lttng/ust-tracepoint-event.h
+++ b/include/lttng/ust-tracepoint-event.h
@@ -114,6 +114,39 @@ static const char							\
 #include TRACEPOINT_INCLUDE
 
 /*
+ * Stage 0.9 of tracepoint event generation
+ *
+ * Unfolding the enums
+ */
+#include <lttng/ust-tracepoint-event-reset.h>
+
+/* Enumeration entry (single value) */
+#undef ctf_enum_value
+#define ctf_enum_value(_string, _value)		\
+	{ _value, _value, #_string },
+
+/* Enumeration entry (range) */
+#undef ctf_enum_range
+#define ctf_enum_range(_string, _range_start, _range_end)		\
+	{ _range_start, _range_end, #_string },
+
+#undef TP_ENUM_VALUES
+#define TP_ENUM_VALUES(...)						\
+	__VA_ARGS__
+
+#undef TRACE_EVENT_ENUM
+#define TRACE_EVENT_ENUM(_name, _values)
+
+
+#undef TRACEPOINT_ENUM
+#define TRACEPOINT_ENUM(_provider, _name, _type, _values)		\
+	const struct lttng_enum_entry __enum_values__##_provider##_##_name[] = { \
+		_values					\
+	};
+
+#include TRACEPOINT_INCLUDE
+
+/*
  * Stage 1 of tracepoint event generation.
  *
  * Create event field type metadata section.
@@ -195,6 +228,24 @@ static const char							\
 	  .nowrite = _nowrite,					\
 	},
 
+#undef _ctf_enum
+#define _ctf_enum(_provider, _name, _item, _src, _nowrite)	  \
+	{							  \
+	  .name = #_item,					  \
+	  .type = {						  \
+	      .atype = atype_enum,			          \
+	      .u = {						  \
+		  .basic = {					  \
+		       .enumeration = {				  \
+			     .name = #_provider "_" #_name	  \
+			   },					  \
+		     },						  \
+		},						  \
+	    },							  \
+	  .nowrite = _nowrite,					  \
+	},
+
+
 #undef TP_FIELDS
 #define TP_FIELDS(...) __VA_ARGS__	/* Only one used in this phase */
 
@@ -204,6 +255,55 @@ static const char							\
 		_fields									     \
 	};
 
+#undef TRACEPOINT_ENUM
+#define TRACEPOINT_ENUM(_provider, _name, _type, _values)		\
+	static const struct lttng_enum __enum_##_provider##_##_name = {	\
+		.name = #_provider "_" #_name,				\
+		.container_type = {					\
+			  .size = sizeof(_type) * CHAR_BIT,		\
+			  .alignment = lttng_alignof(_type) * CHAR_BIT,	\
+			  .signedness = lttng_is_signed_type(_type),	\
+			  .reverse_byte_order = 0,			\
+			  .base = 10,					\
+			  .encoding = lttng_encode_none,		\
+			},						\
+		.entries = __enum_values__##_provider##_##_name,	\
+		.len = _TP_ARRAY_SIZE(__enum_values__##_provider##_##_name), \
+	};
+
+#include TRACEPOINT_INCLUDE
+
+/*
+ * Stage 1.1 of tracepoint event generation.
+ *
+ * Create the global type declarations structures for each field
+ */
+
+/* Reset all macros within TRACEPOINT_EVENT */
+#include <lttng/ust-tracepoint-event-reset.h>
+#include <lttng/ust-tracepoint-event-write.h>
+#include <lttng/ust-tracepoint-event-nowrite.h>
+
+#undef _ctf_enum
+#define _ctf_enum(_provider, _name, _item, _src, _nowrite)	\
+	{							\
+	  .mtype = mtype_enum,					\
+	  .nowrite = _nowrite,					\
+	  .u = {						\
+	      .ctf_enum = &__enum_##_provider##_##_name,	\
+	    },							\
+	},
+
+
+#undef TP_FIELDS
+#define TP_FIELDS(...) __VA_ARGS__	/* Only one used in this phase */
+
+#undef TRACEPOINT_EVENT_CLASS
+#define TRACEPOINT_EVENT_CLASS(_provider, _name, _args, _fields) \
+	static const struct lttng_global_type_decl __global_types_for___##_provider##___##_name[] = { \
+		_fields						 \
+	};
+
 #include TRACEPOINT_INCLUDE
 
 /*
@@ -263,6 +363,10 @@ static void __event_probe__##_provider##___##_name(_TP_ARGS_DATA_PROTO(_args));
 #define _ctf_string(_item, _src, _nowrite)				       \
 	__event_len += __dynamic_len[__dynamic_len_idx++] = strlen(_src) + 1;
 
+#undef _ctf_enum
+#define _ctf_enum(_provider, _name, _item, _src, _nowrite)		\
+	__event_len += __enum_get_size__##_provider##___##_name(__event_len);
+
 #undef TP_ARGS
 #define TP_ARGS(...) __VA_ARGS__
 
@@ -285,6 +389,18 @@ size_t __event_get_size__##_provider##___##_name(size_t *__dynamic_len, _TP_ARGS
 	return __event_len;						      \
 }
 
+#undef TRACEPOINT_ENUM
+#define TRACEPOINT_ENUM(_provider, _name, _type, _values)		      \
+static inline								      \
+size_t __enum_get_size__##_provider##___##_name(size_t __event_len)	      \
+{									      \
+	size_t __enum_len = 0;						      \
+	__enum_len = lib_ring_buffer_align(__event_len, lttng_alignof(_type)); \
+	__enum_len += sizeof(_type);					      \
+	return __enum_len;						      \
+}
+
+
 #include TRACEPOINT_INCLUDE
 
 /*
@@ -399,6 +515,10 @@ void __event_prepare_filter_stack__##_provider##___##_name(char *__stack_data,\
 #undef _ctf_string
 #define _ctf_string(_item, _src, _nowrite)
 
+#undef _ctf_enum
+#define _ctf_enum(_provider, _name, _item, _src, _nowrite)		\
+	__event_align = _tp_max_t(size_t, __event_align, __enum_get_align__##_provider##___##_name());
+
 #undef TP_ARGS
 #define TP_ARGS(...) __VA_ARGS__
 
@@ -417,6 +537,14 @@ size_t __event_get_align__##_provider##___##_name(_TP_ARGS_PROTO(_args))      \
 	return __event_align;						      \
 }
 
+#undef TRACEPOINT_ENUM
+#define TRACEPOINT_ENUM(_provider, _name, _type, _values)		      \
+static inline								      \
+size_t __enum_get_align__##_provider##___##_name(void)			      \
+{									      \
+	return lttng_alignof(_type);					      \
+}
+
 #include TRACEPOINT_INCLUDE
 
 
@@ -469,6 +597,14 @@ size_t __event_get_align__##_provider##___##_name(_TP_ARGS_PROTO(_args))      \
 	lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(*(_src)));	\
 	__chan->ops->event_write(&__ctx, _src, __get_dynamic_len(dest));
 
+#undef _ctf_enum
+#define _ctf_enum(_provider, _name, _item, _src, _nowrite)		 \
+	{								 \
+		int __tmp = (_src);					 \
+		lib_ring_buffer_align_ctx(&__ctx, lttng_alignof(__tmp)); \
+		__chan->ops->event_write(&__ctx, &__tmp, sizeof(__tmp)); \
+	}
+
 /* Beware: this get len actually consumes the len value */
 #undef __get_dynamic_len
 #define __get_dynamic_len(field)	__stackvar.__dynamic_len[__dynamic_len_idx++]
@@ -644,10 +780,11 @@ const struct lttng_event_desc __event_desc___##_provider##_##_name = {	       \
 	.nr_fields = _TP_ARRAY_SIZE(__event_fields___##_provider##___##_template), \
 	.loglevel = &__ref_loglevel___##_provider##___##_name,		       \
 	.signature = __tp_event_signature___##_provider##___##_template,       \
-	.u = { .ext =							       \
-		{							       \
+	.u = {								       \
+	    .ext = {							       \
 		  .model_emf_uri = &__ref_model_emf_uri___##_provider##___##_name, \
-		  .nr_global_type_decl = 0,				       \
+		  .nr_global_type_decl = _TP_ARRAY_SIZE(__global_types_for___##_provider##___##_name), \
+		  .global_type_decl = __global_types_for___##_provider##___##_name, \
 		},							       \
 	},								       \
 };
-- 
1.8.5.4




^ permalink raw reply	[flat|nested] 12+ messages in thread

* [lttng-dev] [Patch LTTng-ust v2 7/7] Update the LTTng documentation with CTF global enumerations
  2014-02-11 21:35 ` [lttng-dev] LTTng-ust: Add support of global types and CTF enumerations Geneviève Bastien
                     ` (5 preceding siblings ...)
  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   ` Geneviève Bastien
  6 siblings, 0 replies; 12+ messages in thread
From: Geneviève Bastien @ 2014-02-11 21:35 UTC (permalink / raw)


Signed-off-by: Genevi?ve Bastien <gbastien+lttng at versatic.net>
---
 doc/man/lttng-ust.3 | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 57 insertions(+)

diff --git a/doc/man/lttng-ust.3 b/doc/man/lttng-ust.3
index 7624e88..9958e59 100644
--- a/doc/man/lttng-ust.3
+++ b/doc/man/lttng-ust.3
@@ -158,6 +158,14 @@ TRACEPOINT_EVENT(
 		 */
 		ctf_float(float, floatfield, floatarg)
 		ctf_float(double, doublefield, doublearg)
+
+		/*
+		 * ctf_enum: a field using a previously declared global enumeration
+		 * args: (provider, enum name, field name, argument expression)
+		 * The enumeration itself and its values must have been defined
+		 * previously with the TRACEPOINT_ENUM macro, described below.
+		 */
+		ctf_enum(sample_component, enumeration_name, enumfield, enumarg)
 	)
 )
 
@@ -165,6 +173,55 @@ There can be an arbitrary number of tracepoint providers within an
 application, but they must each have their own provider name. Duplicate
 provider names are not allowed.
 
+The CTF specification also supports some global named basic and compound types
+that can be declared inside a tracepoint provider and used as fields in the
+tracepoint. This shows how to specify them and what they can be used for:
+
+The enumeration is a mapping between an integer, or a 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:
+
+TRACEPOINT_ENUM(
+	/*
+	 * The provider name, as described in the TRACEPOINT_EVENT macro.
+	 */
+	sample_component,
+
+	/*
+	 * The name of this enumeration, that will be used when using this
+	 * global type in tracepoint fields.
+	 */
+	enumeration_name,
+
+	/*
+	 * Integer type by which this enumeration will be represented.
+	 * It can be: char, int, long or any variant on those
+	 */
+	type,
+
+	/*
+	 * TP_ENUM_VALUES describe the values of this enumeration and what they
+	 * map to.
+	 */
+	TP_ENUM_VALUES(
+		/*
+		 * Maps an integer with this string value. By default, enumerations
+		 * start at 0 and increment 1 for each entry.
+		 */
+		ctf_enum_value(string_value)
+
+		/*
+		 * Maps the string value to integers in the range 'start' to 'end'
+		 * inclusively. If 'start' == 'end', then the string is mapped to
+		 * a specific value.
+		 * Enumeration ranges may overlap, but the behavior is
+		 * implementation-defined, each trace reader will handle overlapping
+		 * as it wishes.
+		 */
+		ctf_enum_range(start, end, string_value)
+	)
+)
+
 .fi
 
 .SH "ASSIGNING LOGLEVEL TO EVENTS"
-- 
1.8.5.4




^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2014-02-11 21:35 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [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   ` [lttng-dev] [Patch LTTng-ust v2 2/7] Add empty macros to support CTF global enumerations Geneviève Bastien
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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox