mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 1/3] ftrace: add proper bin iterator support
@ 2008-11-14 10:46 Aneesh Kumar K.V
  2008-11-14 10:46 ` [PATCH 2/3] ftrace: Add debug_print trace to print data from kernel to userspace Aneesh Kumar K.V
  0 siblings, 1 reply; 11+ messages in thread
From: Aneesh Kumar K.V @ 2008-11-14 10:46 UTC (permalink / raw)
  To: rostedt, mingo, akpm; +Cc: linux-kernel, Aneesh Kumar K.V

In s_show after print_trace_line we call trace_print_seq which
does a strlen on the buffer containing binary data. I guess that would
give wrong results for bin data even though we are null terminating it.
We also don't want header in the output file if we have  TRACE_ITER_BIN.

Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
---
 kernel/trace/trace.c |   41 +++++++++++++++++++++++++++++++++++++++++
 1 files changed, 41 insertions(+), 0 deletions(-)

diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index 8a499e2..fb32a5c 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -1833,10 +1833,51 @@ static enum print_line_t print_trace_line(struct trace_iterator *iter)
 	return print_trace_fmt(iter);
 }
 
+static int s_bin_show(struct seq_file *m, void *v)
+{
+	int len;
+	enum print_line_t ret;
+	struct trace_iterator *iter = v;
+
+	if (iter->ent == NULL)
+		return 0;
+
+	if (iter->trace && iter->trace->print_line) {
+		ret = iter->trace->print_line(iter);
+		if (ret != TRACE_TYPE_UNHANDLED)
+			goto trace_handled;
+	}
+	/*
+	 * If  trace type is unhandled or if we don't have
+	 * a print_line call the standard bin_fmt callback
+	 */
+	print_bin_fmt(iter);
+
+trace_handled:
+	/* copy the trace buffer to seq file buffer */
+	if (iter->seq.len >= PAGE_SIZE)
+		len = PAGE_SIZE - 1;
+	else
+		len = iter->seq.len;
+
+	if (m->count + len < m->size) {
+		memcpy(m->buf + m->count, iter->seq.buffer, len);
+		m->count += len;
+	} else
+		m->count = m->size;
+	trace_seq_reset(&iter->seq);
+
+	return 0;
+}
+
+
 static int s_show(struct seq_file *m, void *v)
 {
 	struct trace_iterator *iter = v;
 
+	if (trace_flags & TRACE_ITER_BIN)
+		return s_bin_show(m, v);
+
 	if (iter->ent == NULL) {
 		if (iter->tr) {
 			seq_printf(m, "# tracer: %s\n", iter->trace->name);
-- 
1.6.0.4.608.ga9645


^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2008-11-16 10:49 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-11-14 10:46 [PATCH 1/3] ftrace: add proper bin iterator support Aneesh Kumar K.V
2008-11-14 10:46 ` [PATCH 2/3] ftrace: Add debug_print trace to print data from kernel to userspace Aneesh Kumar K.V
2008-11-14 10:46   ` [PATCH 3/3] ftrace: Add debug_dump trace to dump binary " Aneesh Kumar K.V
2008-11-14 11:54     ` Frédéric Weisbecker
2008-11-14 13:19     ` Frédéric Weisbecker
2008-11-14 13:25       ` Frédéric Weisbecker
2008-11-14 11:21   ` [PATCH 2/3] ftrace: Add debug_print trace to print " Frédéric Weisbecker
2008-11-14 13:46     ` Aneesh Kumar K.V
2008-11-14 14:39       ` Frédéric Weisbecker
2008-11-16 10:49         ` Aneesh Kumar K.V
2008-11-14 11:25   ` Frédéric Weisbecker

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome