[lttng-dev] [Patch LTTng-tools 3/4] Statedump the metadata for CTF named enumerations

Mathieu Desnoyers mathieu.desnoyers at efficios.com
Thu Jan 30 20:46:48 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:07:24 PM
> Subject: [lttng-dev] [Patch LTTng-tools 3/4] Statedump the metadata for CTF	named enumerations
> 
> The metadata is dumped along with the event description, before the event
> itself so that the metadata precedes it in the metadata file.
> 
> Signed-off-by: Geneviève Bastien <gbastien+lttng at versatic.net>
> ---
>  src/bin/lttng-sessiond/ust-metadata.c | 93
>  ++++++++++++++++++++++++++++++++++-
>  1 file changed, 91 insertions(+), 2 deletions(-)
> 
> diff --git a/src/bin/lttng-sessiond/ust-metadata.c
> b/src/bin/lttng-sessiond/ust-metadata.c
> index b0f83d2..87d21fc 100644
> --- a/src/bin/lttng-sessiond/ust-metadata.c
> +++ b/src/bin/lttng-sessiond/ust-metadata.c
> @@ -180,6 +180,12 @@ int _lttng_field_statedump(struct ust_registry_session
> *session,
>  			field->type.u.basic.integer.reverse_byte_order ? bo_reverse : bo_native,
>  			field->name);
>  		break;
> +	case ustctl_atype_enum:
> +		ret = lttng_metadata_printf(session,
> +			"		enum __ust_enum__%s _%s;\n",
> +			field->type.u.basic.enumeration.name,
> +			field->name);
> +		break;
>  	case ustctl_atype_float:
>  		ret = lttng_metadata_printf(session,
>  			"		floating_point { exp_dig = %u; mant_dig = %u; align = %u;%s } _%s;\n",
> @@ -189,8 +195,6 @@ int _lttng_field_statedump(struct ust_registry_session
> *session,
>  			field->type.u.basic.integer.reverse_byte_order ? bo_reverse : bo_native,
>  			field->name);
>  		break;
> -	case ustctl_atype_enum:
> -		return -EINVAL;
>  	case ustctl_atype_array:
>  	{
>  		const struct ustctl_basic_type *elem_type;
> @@ -303,6 +307,86 @@ int _lttng_fields_metadata_statedump(struct
> ust_registry_session *session,
>  }
>  
>  /*
> + * Dumps a named metadata to the metadata file for the session. It should

(insert expected comment about named metadata -> global types)

> + * verify whether this metadata was already dumped by a previous event.
> + */
> +static
> +int _lttng_one_metadata_statedump(struct ust_registry_session *session,
> +		const struct ustctl_named_metadata *metadata)
> +{
> +	int ret = 0, i;
> +
> +	switch (metadata->mtype) {
> +	case ustctl_mtype_enum:
> +	{
> +		const struct ustctl_enum *uenum;

missing newline between type declarations and code. This comment applies to
other patches in the UST patchset (I've missed it).

> +		uenum = &metadata->u.ctf_enum;
> +		ret = lttng_metadata_printf(session,
> +			"enum __ust_enum__%s: integer { size = %u; align = %u; signed = %u;
> encoding = %s; base = %u; } {\n",
> +			uenum->name,
> +			uenum->container_type.size,
> +			uenum->container_type.alignment,
> +			uenum->container_type.signedness,
> +			(uenum->container_type.encoding == ustctl_encode_none)
> +				? "none"
> +				: (uenum->container_type.encoding == ustctl_encode_UTF8)
> +					? "UTF8"
> +					: "ASCII",
> +			uenum->container_type.base);
> +		if (ret)
> +			return ret;
> +		/* Dump the entries */
> +		for (i = 0; i < uenum->len; i++) {
> +			struct ustctl_enum_entry entry;
> +			entry = uenum->entries[i];
> +			if (entry.start == entry.end) {
> +				ret = lttng_metadata_printf(session,
> +						"	%s = %d,\n",
> +						entry.string, entry.start);
> +				if (ret)
> +					return ret;
> +			} else {
> +				ret = lttng_metadata_printf(session,
> +						"	%s = %d ... %d,\n",
> +						entry.string, entry.start, entry.end);
> +				if (ret)
> +					return ret;
> +			}
> +		}
> +		ret = lttng_metadata_printf(session, "};\n\n");
> +		if (ret)
> +			return ret;
> +		break;
> +	}
> +	default:
> +		return -EINVAL;
> +	}
> +
> +	return ret;
> +}
> +
> +/*
> + * This function dumps to the metadata the named metadata used by the

global types ?

> + * event.
> + */
> +static
> +int _lttng_named_metadata_statedump(struct ust_registry_session *session,
> +		struct ust_registry_event *event)
> +{
> +	int ret = 0;
> +	int i;

int ret = 0, i;

(for consistency with function above)

Thanks,

Mathieu

> +
> +	for (i = 0; i < event->nr_metadata; i++) {
> +		const struct ustctl_named_metadata *metadata = &event->named_metadata[i];
> +
> +		ret = _lttng_one_metadata_statedump(session, metadata);
> +		if (ret)
> +			return ret;
> +	}
> +	return ret;
> +}
> +
> +/*
>   * Should be called with session registry mutex held.
>   */
>  int ust_metadata_event_statedump(struct ust_registry_session *session,
> @@ -315,6 +399,11 @@ int ust_metadata_event_statedump(struct
> ust_registry_session *session,
>  	if (chan->chan_id == -1U)
>  		return 0;
>  
> +	/* Dump the named_metadata needed by this event */
> +	ret = _lttng_named_metadata_statedump(session, event);
> +	if (ret)
> +		goto end;
> +
>  	ret = lttng_metadata_printf(session,
>  		"event {\n"
>  		"	name = \"%s\";\n"
> --
> 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