[lttng-dev] [PATCH] Teach babeltrace understand "native" and "network" for byte_order

Mathieu Desnoyers mathieu.desnoyers at efficios.com
Fri Mar 15 08:07:53 EDT 2013


* Yao Qi (yao at codesourcery.com) wrote:
> Hi,
> We wrote byte_order in metadata either "le" or "be", according to the
> host endianness.  Today, when I check the ctf specification, I find
> "native" fits our needs well.  However, after I replace "le" with
> "native" in metadata, I got the following error message:
> 
>   [error] get_trace_byte_order: unexpected string "native". Should be "native", "network", "be" or "le".
> 
> This patch teaches babeltrace understand "native" and "network".  With
> this patch applied, the output looks right now.  Let me know if I need
> run testsuite, and how.

your interpretation of what the byte order should accept is based on
section 4.1.3 of the CTF spec, which discusses what byte order can be
accepted by a type.

However, here you are proposing to change the byte order recognised at
the trace declaration level. Unfortunately, we cannot assume anything
about native endianness of the traced machine until we have the
endianness information at the trace declaration level, as the trace can
come from any source.

Possibly that the CTF spec would need to be clarified. Currently, we
need to look at:

7.4 TSDL Examples

trace {
  ...
  byte_order = be OR le;                        /* Endianness (required) */
  ...
};

to understand that only be and le should be expected in the trace
description.

Thoughts ?

Thanks,

Mathieu

> 
> Signed-off-by: Yao Qi <yao at codesourcery.com>
> ---
>  .../ctf/metadata/ctf-visitor-generate-io-struct.c  |    4 ++++
>  1 files changed, 4 insertions(+), 0 deletions(-)
> 
> diff --git a/formats/ctf/metadata/ctf-visitor-generate-io-struct.c b/formats/ctf/metadata/ctf-visitor-generate-io-struct.c
> index 9bcc170..cea2877 100644
> --- a/formats/ctf/metadata/ctf-visitor-generate-io-struct.c
> +++ b/formats/ctf/metadata/ctf-visitor-generate-io-struct.c
> @@ -1227,6 +1227,10 @@ int get_trace_byte_order(FILE *fd, int depth, struct ctf_node *unary_expression)
>  		byte_order = BIG_ENDIAN;
>  	else if (!strcmp(unary_expression->u.unary_expression.u.string, "le"))
>  		byte_order = LITTLE_ENDIAN;
> +	else if (!strcmp(unary_expression->u.unary_expression.u.string, "native"))
> +		byte_order = BYTE_ORDER;
> +	else if (!strcmp(unary_expression->u.unary_expression.u.string, "network"))
> +		byte_order = BIG_ENDIAN;
>  	else {
>  		fprintf(fd, "[error] %s: unexpected string \"%s\". Should be \"be\" or \"le\".\n",
>  			__func__, unary_expression->u.unary_expression.u.string);
> -- 
> 1.7.7.6
> 
> 
> _______________________________________________
> 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