diff mbox

[v4,2/3] trace: Introduce trace log output function for STM

Message ID 1437536763-10827-3-git-send-email-zhang.chunyan@linaro.org
State New
Headers show

Commit Message

Chunyan Zhang July 22, 2015, 3:46 a.m. UTC
This patch introduced a new function to print the trace events logs
to STM buffer when the trace event happens.

Signed-off-by: Chunyan Zhang <zhang.chunyan@linaro.org>
---
 kernel/trace/Makefile           |  1 +
 kernel/trace/trace_output_stm.c | 22 ++++++++++++++++++++++
 2 files changed, 23 insertions(+)
 create mode 100644 kernel/trace/trace_output_stm.c
diff mbox

Patch

diff --git a/kernel/trace/Makefile b/kernel/trace/Makefile
index 9b1044e..ac6c195 100644
--- a/kernel/trace/Makefile
+++ b/kernel/trace/Makefile
@@ -67,4 +67,5 @@  obj-$(CONFIG_UPROBE_EVENT) += trace_uprobe.o
 
 obj-$(CONFIG_TRACEPOINT_BENCHMARK) += trace_benchmark.o
 
+obj-$(CONFIG_TRACE_EVENT_STM) += trace_output_stm.o
 libftrace-y := ftrace.o
diff --git a/kernel/trace/trace_output_stm.c b/kernel/trace/trace_output_stm.c
new file mode 100644
index 0000000..42d5549
--- /dev/null
+++ b/kernel/trace/trace_output_stm.c
@@ -0,0 +1,22 @@ 
+#include <linux/trace_events.h>
+#include "trace_output.h"
+
+void trace_event_stm_log(struct trace_event_buffer *buffer)
+{
+	/* use static because iter can be a bit big for the stack */
+	static struct trace_iterator iter;
+	struct trace_entry *entry = (struct trace_entry *)buffer->entry;
+	struct trace_event *event = NULL;
+
+	iter.ent = entry;
+
+	if (entry)
+		event = ftrace_find_event(entry->type);
+
+	if (event && event->funcs) {
+		event->funcs->trace(&iter, 0, event);
+		stm_trace_event_write(iter.seq.buffer, iter.seq.seq.len);
+		iter.seq.seq.len = 0;
+	}
+}
+EXPORT_SYMBOL_GPL(trace_event_stm_log);