[ltt-dev] [PATCH take2 05/13] read basic type from ltt-relay buffer

Mathieu Desnoyers compudj at krystal.dyndns.org
Mon Feb 23 13:58:05 EST 2009


* Lai Jiangshan (laijs at cn.fujitsu.com) wrote:
> we need function read the base type from ltt-relay buffer
> in the kernel for text output
> 

Looks good, will merge. Thanks !

Mathieu

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers at polymtl.ca>

> Signed-off-by: Lai Jiangshan <laijs at cn.fujitsu.com>
> ---
> diff --git a/ltt/ltt-serialize.c b/ltt/ltt-serialize.c
> index 5c34899..0ca6683 100644
> --- a/ltt/ltt-serialize.c
> +++ b/ltt/ltt-serialize.c
> @@ -531,6 +531,48 @@ notrace size_t ltt_serialize_data(struct rchan_buf *buf, size_t buf_offset,
>  }
>  EXPORT_SYMBOL_GPL(ltt_serialize_data);
>  
> +static inline uint64_t unserialize_base_type(struct rchan_buf *buf,
> +		size_t *ppos, char trace_size, enum ltt_type trace_type)
> +{
> +	uint64_t tmp;
> +
> +	*ppos += ltt_align(*ppos, trace_size);
> +	ltt_relay_read(buf, *ppos, &tmp, trace_size);
> +	*ppos += trace_size;
> +
> +	switch (trace_type) {
> +	case LTT_TYPE_SIGNED_INT:
> +		switch (trace_size) {
> +		case 1:
> +			return (uint64_t)*(int8_t *)&tmp;
> +		case 2:
> +			return (uint64_t)*(int16_t *)&tmp;
> +		case 4:
> +			return (uint64_t)*(int32_t *)&tmp;
> +		case 8:
> +			return tmp;
> +		}
> +		break;
> +	case LTT_TYPE_UNSIGNED_INT:
> +		switch (trace_size) {
> +		case 1:
> +			return (uint64_t)*(uint8_t *)&tmp;
> +		case 2:
> +			return (uint64_t)*(uint16_t *)&tmp;
> +		case 4:
> +			return (uint64_t)*(uint32_t *)&tmp;
> +		case 8:
> +			return tmp;
> +		}
> +		break;
> +	default:
> +		break;
> +	}
> +
> +	BUG();
> +	return 0;
> +}
> +
>  /*
>   * Calculate data size
>   * Assume that the padding for alignment starts at a sizeof(void *) address.
> 
> 
> 
> _______________________________________________
> ltt-dev mailing list
> ltt-dev at lists.casi.polymtl.ca
> http://lists.casi.polymtl.ca/cgi-bin/mailman/listinfo/ltt-dev
> 

-- 
Mathieu Desnoyers
OpenPGP key fingerprint: 8CD5 52C3 8E3C 4140 715F  BA06 3F25 A8FE 3BAE 9A68




More information about the lttng-dev mailing list