From: laijs@cn.fujitsu.com (Lai Jiangshan)
Subject: [ltt-dev] [PATCH take2 05/13] read basic type from ltt-relay buffer
Date: Thu, 05 Feb 2009 11:31:28 +0800 [thread overview]
Message-ID: <498A5D90.8020004@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>
---
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.
next reply other threads:[~2009-02-05 3:31 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-02-05 3:31 Lai Jiangshan [this message]
2009-02-23 18:58 ` 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=498A5D90.8020004@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