[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-id: <19b2815dbb60bfd38d17596a3d466637ee44c9a5.1426521377.git.s.strogin@partner.samsung.com>
Date: Mon, 16 Mar 2015 19:06:58 +0300
From: Stefan Strogin <s.strogin@...tner.samsung.com>
To: linux-mm@...ck.org, linux-kernel@...r.kernel.org
Cc: Stefan Strogin <s.strogin@...tner.samsung.com>,
Joonsoo Kim <iamjoonsoo.kim@....com>,
Andrew Morton <akpm@...ux-foundation.org>,
Marek Szyprowski <m.szyprowski@...sung.com>,
Michal Nazarewicz <mina86@...a86.com>,
aneesh.kumar@...ux.vnet.ibm.com,
Laurent Pinchart <laurent.pinchart@...asonboard.com>,
Dmitry Safonov <d.safonov@...tner.samsung.com>,
Pintu Kumar <pintu.k@...sung.com>,
Weijie Yang <weijie.yang@...sung.com>,
Laura Abbott <lauraa@...eaurora.org>,
SeongJae Park <sj38.park@...il.com>,
Hui Zhu <zhuhui@...omi.com>, Minchan Kim <minchan@...nel.org>,
Dyasly Sergey <s.dyasly@...sung.com>,
Vyacheslav Tyrtov <v.tyrtov@...sung.com>,
Aleksei Mateosian <a.mateosian@...sung.com>,
gregory.0xf0@...il.com, sasha.levin@...cle.com, gioh.kim@....com,
pavel@....cz, stefan.strogin@...il.com
Subject: [PATCH v4 3/5] stacktrace: add seq_print_stack_trace()
Add a function seq_print_stack_trace() which prints stacktraces to seq_files.
Signed-off-by: Stefan Strogin <stefan.strogin@...il.com>
Reviewed-by: SeongJae Park <sj38.park@...il.com>
---
include/linux/stacktrace.h | 4 ++++
kernel/stacktrace.c | 17 +++++++++++++++++
2 files changed, 21 insertions(+)
diff --git a/include/linux/stacktrace.h b/include/linux/stacktrace.h
index 0a34489..d80f2e9 100644
--- a/include/linux/stacktrace.h
+++ b/include/linux/stacktrace.h
@@ -2,6 +2,7 @@
#define __LINUX_STACKTRACE_H
#include <linux/types.h>
+#include <linux/seq_file.h>
struct task_struct;
struct pt_regs;
@@ -22,6 +23,8 @@ extern void save_stack_trace_tsk(struct task_struct *tsk,
extern void print_stack_trace(struct stack_trace *trace, int spaces);
extern int snprint_stack_trace(char *buf, size_t size,
struct stack_trace *trace, int spaces);
+extern void seq_print_stack_trace(struct seq_file *m,
+ struct stack_trace *trace, int spaces);
#ifdef CONFIG_USER_STACKTRACE_SUPPORT
extern void save_stack_trace_user(struct stack_trace *trace);
@@ -35,6 +38,7 @@ extern void save_stack_trace_user(struct stack_trace *trace);
# define save_stack_trace_user(trace) do { } while (0)
# define print_stack_trace(trace, spaces) do { } while (0)
# define snprint_stack_trace(buf, size, trace, spaces) do { } while (0)
+# define seq_print_stack_trace(m, trace, spaces) do { } while (0)
#endif
#endif
diff --git a/kernel/stacktrace.c b/kernel/stacktrace.c
index b6e4c16..66ef6f4 100644
--- a/kernel/stacktrace.c
+++ b/kernel/stacktrace.c
@@ -57,6 +57,23 @@ int snprint_stack_trace(char *buf, size_t size,
}
EXPORT_SYMBOL_GPL(snprint_stack_trace);
+void seq_print_stack_trace(struct seq_file *m, struct stack_trace *trace,
+ int spaces)
+{
+ int i;
+
+ if (WARN_ON(!trace->entries))
+ return;
+
+ for (i = 0; i < trace->nr_entries; i++) {
+ unsigned long ip = trace->entries[i];
+
+ seq_printf(m, "%*c[<%p>] %pS\n", 1 + spaces, ' ',
+ (void *) ip, (void *) ip);
+ }
+}
+EXPORT_SYMBOL_GPL(seq_print_stack_trace);
+
/*
* Architectures that do not implement save_stack_trace_tsk or
* save_stack_trace_regs get this weak alias and a once-per-bootup warning
--
2.1.0
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists