[lttng-dev] [Patch LTTng-ust 6/7] Add the macros to generate the data structures for CTF named enumerations

Mathieu Desnoyers mathieu.desnoyers at efficios.com
Thu Jan 30 20:37:39 EST 2014


----- Original Message -----
> From: "Geneviève Bastien" <gbastien+lttng at 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.


> 
> Signed-off-by: Geneviève Bastien <gbastien+lttng at versatic.net>
> ---
>  include/lttng/ust-tracepoint-event.h | 141
>  ++++++++++++++++++++++++++++++++++-
>  1 file changed, 140 insertions(+), 1 deletion(-)
> 
> diff --git a/include/lttng/ust-tracepoint-event.h
> b/include/lttng/ust-tracepoint-event.h
> index f7b9d32..7b4a998 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[] = {\

Missing space before \

> +		_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 =						\
> +		{						\

Here and below, let's try to keep the { on the same line as the =.
(keeping the newline after the { ).

> +		  .atype = atype_enum,			        \
> +		  .u =						\
> +			{					\

same here.

> +			  .basic = { .enumeration =             \
> +				{ .name = #_provider "_" #_name },\

same here.
missing space before \.
you might want to split this into:


    {
       .name .....
    },

> +				},                              \
> +			},					\
> +		},						\
> +	  .nowrite = _nowrite,					\
> +	},
> +
> +
>  #undef TP_FIELDS
>  #define TP_FIELDS(...) __VA_ARGS__	/* Only one used in this phase */
>  
> @@ -204,6 +255,57 @@ 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),\

missing space before \

> +	};					\
> +
> +
> +#include TRACEPOINT_INCLUDE
> +
> +/*
> + * Stage 1.1 of tracepoint event generation.
> + *
> + * Create the metadata 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_named_metadata
> __metadata_for___##_provider##___##_name[] = {\
> +		_fields						\

above, missing space before \

> +	};
> +
>  #include TRACEPOINT_INCLUDE
>  
>  /*
> @@ -263,6 +365,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 +391,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));\

missing space before \

> +	__enum_len += sizeof(_type);						\
> +	return __enum_len;							\
> +}
> +
> +
>  #include TRACEPOINT_INCLUDE
>  
>  /*
> @@ -399,6 +517,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 +539,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 +599,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));\

missing space before each \

Thanks,

Mathieu

> +	}
> +
>  /* Beware: this get len actually consumes the len value */
>  #undef __get_dynamic_len
>  #define __get_dynamic_len(field)
>  	__stackvar.__dynamic_len[__dynamic_len_idx++]
> @@ -646,7 +784,8 @@ const struct lttng_event_desc
> __event_desc___##_provider##_##_name = {	       \
>  	.signature = __tp_event_signature___##_provider##___##_template,       \
>  	.u = { .ext =								\
>  		{ .model_emf_uri = &__ref_model_emf_uri___##_provider##___##_name,\
> -		  .nr_metadata = 0,						\
> +		  .nr_metadata =
> _TP_ARRAY_SIZE(__metadata_for___##_provider##___##_name),\
> +		  .named_metadata = __metadata_for___##_provider##___##_name,	\
>  		}								\
>  	},									\
>  };
> --
> 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



More information about the lttng-dev mailing list