Mirror of the lttng-dev mailing list
 help / color / mirror / Atom feed
From: laijs@cn.fujitsu.com (Lai Jiangshan)
Subject: [ltt-dev] [PATCH 05/13] read basic type from ltt-relay buffer
Date: Tue, 13 Jan 2009 17:09:01 +0800	[thread overview]
Message-ID: <496C5A2D.2040300@cn.fujitsu.com> (raw)


we need function read the base type from ltt-relay buffer
in the kernel for text output

Signed-off-by: Lai Jiangshan <laijs at cn.fujitsu.com>
---
 ltt-serialize.c |   71 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 71 insertions(+)
diff --git a/ltt/ltt-serialize.c b/ltt/ltt-serialize.c
index 5c34899..deb9106 100644
--- a/ltt/ltt-serialize.c
+++ b/ltt/ltt-serialize.c
@@ -531,6 +538,77 @@
 }
 EXPORT_SYMBOL_GPL(ltt_serialize_data);
 
+static inline u64 serialize_read_base_type(struct rchan_buf *buf, size_t *ppos,
+		char trace_size, enum ltt_type trace_type)
+{
+	union {
+		uint8_t  u_8;
+		uint16_t u_16;
+		uint32_t u_32;
+		uint64_t u_64;
+		int8_t   s_8;
+		int16_t  s_16;
+		int32_t  s_32;
+		int64_t  s_64;
+	} tmp;
+	uint64_t value;
+
+	if (ltt_get_alignment())
+		*ppos += ltt_align(*ppos, trace_size);
+
+	switch (trace_type) {
+	case LTT_TYPE_SIGNED_INT:
+		switch (trace_size) {
+		case 1:
+			ltt_relay_read(buf, *ppos, &tmp.s_8, trace_size);
+			value = tmp.s_8;
+			break;
+		case 2:
+			ltt_relay_read(buf, *ppos, &tmp.s_16, trace_size);
+			value = tmp.s_16;
+			break;
+		case 4:
+			ltt_relay_read(buf, *ppos, &tmp.s_32, trace_size);
+			value = tmp.s_32;
+			break;
+		case 8:
+			ltt_relay_read(buf, *ppos, &tmp.s_64, trace_size);
+			value = tmp.s_64;
+			break;
+		default:
+			BUG();
+		}
+		break;
+	case LTT_TYPE_UNSIGNED_INT:
+		switch (trace_size) {
+		case 1:
+			ltt_relay_read(buf, *ppos, &tmp.u_8, trace_size);
+			value = tmp.u_8;
+			break;
+		case 2:
+			ltt_relay_read(buf, *ppos, &tmp.u_16, trace_size);
+			value = tmp.u_16;
+			break;
+		case 4:
+			ltt_relay_read(buf, *ppos, &tmp.u_32, trace_size);
+			value = tmp.u_32;
+			break;
+		case 8:
+			ltt_relay_read(buf, *ppos, &tmp.u_64, trace_size);
+			value = tmp.u_64;
+			break;
+		default:
+			BUG();
+		}
+		break;
+	default:
+		BUG();
+	}
+
+	*ppos += trace_size;
+	return value;
+}
+
 /*
  * Calculate data size
  * Assume that the padding for alignment starts at a sizeof(void *) address.







             reply	other threads:[~2009-01-13  9:09 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-01-13  9:09 Lai Jiangshan [this message]
2009-01-15 18:48 ` Mathieu Desnoyers
2009-01-17  3:24   ` Lai Jiangshan
2009-01-17  4:37     ` Mathieu Desnoyers
2009-01-19  2:27       ` Lai Jiangshan
2009-01-20  1:45         ` Mathieu Desnoyers

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=496C5A2D.2040300@cn.fujitsu.com \
    --to=laijs@cn.fujitsu.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox