[ltt-dev] [PATCH 03/13] read event header from ltt-relay buffer

Lai Jiangshan laijs at cn.fujitsu.com
Tue Jan 13 04:08:51 EST 2009


we implement ltt_read_event_header() read event header from ltt-relay
buffer. it does the work oppositely to ltt_write_event_header().

Signed-off-by: Lai Jiangshan <laijs at cn.fujitsu.com>
---
 ltt-tracer.h |   59 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 59 insertions(+)
diff --git a/include/linux/ltt-tracer.h b/include/linux/ltt-tracer.h
index ece6819..b49cac2 100644
--- a/include/linux/ltt-tracer.h
+++ b/include/linux/ltt-tracer.h
@@ -492,6 +506,65 @@ static inline size_t ltt_write_event_header(struct ltt_trace_struct *trace,
 	return buf_offset;
 }
 
+/*
+ * ltt_read_event_header
+ * buf_offset must aligned on 32 bits
+ */
+static inline size_t ltt_read_event_header( struct rchan_buf *buf,
+		long buf_offset, u64 *tsc, u32 *event_size, u16 *eID,
+		unsigned int *rflags)
+{
+	struct ltt_event_header header;
+	u16 small_size;
+
+	ltt_relay_read(buf, buf_offset, &header, sizeof(header));
+	buf_offset += sizeof(header);
+
+	*event_size = INT_MAX;
+	*eID = header.id_time >> LTT_TSC_BITS;
+	*tsc = header.id_time & LTT_TSC_MASK;
+
+	switch (*eID) {
+	case 29:
+		*rflags = LTT_RFLAG_ID_SIZE_TSC;
+		ltt_relay_read(buf, buf_offset, eID, sizeof(u16));
+		buf_offset += sizeof(u16);
+		ltt_relay_read(buf, buf_offset, &small_size, sizeof(u16));
+		buf_offset += sizeof(u16);
+		if (small_size == 0xFFFFU) {
+			ltt_relay_read(buf, buf_offset, event_size, sizeof(u32));
+			buf_offset += sizeof(u32);
+		} else
+			*event_size = small_size;
+		buf_offset += ltt_align(buf_offset, sizeof(u64));
+		ltt_relay_read(buf, buf_offset, tsc, sizeof(u64));
+		buf_offset += sizeof(u64);
+		break;
+	case 30:
+		*rflags = LTT_RFLAG_ID_SIZE;
+		ltt_relay_read(buf, buf_offset, eID, sizeof(u16));
+		buf_offset += sizeof(u16);
+		ltt_relay_read(buf, buf_offset, &small_size, sizeof(u16));
+		buf_offset += sizeof(u16);
+		if (small_size == 0xFFFFU) {
+			ltt_relay_read(buf, buf_offset, event_size, sizeof(u32));
+			buf_offset += sizeof(u32);
+		} else
+			*event_size = small_size;
+		break;
+	case 31:
+		*rflags = LTT_RFLAG_ID;
+		ltt_relay_read(buf, buf_offset, eID, sizeof(u16));
+		buf_offset += sizeof(u16);
+		break;
+	default:
+		*rflags = 0;
+		break;
+	}
+
+	return buf_offset;
+}
+
 /* Lockless LTTng */
 
 /* Buffer offset macros */







More information about the lttng-dev mailing list