diff options
Diffstat (limited to 'arch/sh/kernel/dumpstack.c')
-rw-r--r-- | arch/sh/kernel/dumpstack.c | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/arch/sh/kernel/dumpstack.c b/arch/sh/kernel/dumpstack.c index 694158b9a50f..7617dc4129ac 100644 --- a/arch/sh/kernel/dumpstack.c +++ b/arch/sh/kernel/dumpstack.c | |||
@@ -2,13 +2,48 @@ | |||
2 | * Copyright (C) 1991, 1992 Linus Torvalds | 2 | * Copyright (C) 1991, 1992 Linus Torvalds |
3 | * Copyright (C) 2000, 2001, 2002 Andi Kleen, SuSE Labs | 3 | * Copyright (C) 2000, 2001, 2002 Andi Kleen, SuSE Labs |
4 | * Copyright (C) 2009 Matt Fleming | 4 | * Copyright (C) 2009 Matt Fleming |
5 | * Copyright (C) 2002 - 2012 Paul Mundt | ||
6 | * | ||
7 | * This file is subject to the terms and conditions of the GNU General Public | ||
8 | * License. See the file "COPYING" in the main directory of this archive | ||
9 | * for more details. | ||
5 | */ | 10 | */ |
6 | #include <linux/kallsyms.h> | 11 | #include <linux/kallsyms.h> |
7 | #include <linux/ftrace.h> | 12 | #include <linux/ftrace.h> |
8 | #include <linux/debug_locks.h> | 13 | #include <linux/debug_locks.h> |
14 | #include <linux/kdebug.h> | ||
15 | #include <linux/export.h> | ||
16 | #include <linux/uaccess.h> | ||
9 | #include <asm/unwinder.h> | 17 | #include <asm/unwinder.h> |
10 | #include <asm/stacktrace.h> | 18 | #include <asm/stacktrace.h> |
11 | 19 | ||
20 | void dump_mem(const char *str, unsigned long bottom, unsigned long top) | ||
21 | { | ||
22 | unsigned long p; | ||
23 | int i; | ||
24 | |||
25 | printk("%s(0x%08lx to 0x%08lx)\n", str, bottom, top); | ||
26 | |||
27 | for (p = bottom & ~31; p < top; ) { | ||
28 | printk("%04lx: ", p & 0xffff); | ||
29 | |||
30 | for (i = 0; i < 8; i++, p += 4) { | ||
31 | unsigned int val; | ||
32 | |||
33 | if (p < bottom || p >= top) | ||
34 | printk(" "); | ||
35 | else { | ||
36 | if (__get_user(val, (unsigned int __user *)p)) { | ||
37 | printk("\n"); | ||
38 | return; | ||
39 | } | ||
40 | printk("%08x ", val); | ||
41 | } | ||
42 | } | ||
43 | printk("\n"); | ||
44 | } | ||
45 | } | ||
46 | |||
12 | void printk_address(unsigned long address, int reliable) | 47 | void printk_address(unsigned long address, int reliable) |
13 | { | 48 | { |
14 | printk(" [<%p>] %s%pS\n", (void *) address, | 49 | printk(" [<%p>] %s%pS\n", (void *) address, |
@@ -106,3 +141,26 @@ void show_trace(struct task_struct *tsk, unsigned long *sp, | |||
106 | 141 | ||
107 | debug_show_held_locks(tsk); | 142 | debug_show_held_locks(tsk); |
108 | } | 143 | } |
144 | |||
145 | void show_stack(struct task_struct *tsk, unsigned long *sp) | ||
146 | { | ||
147 | unsigned long stack; | ||
148 | |||
149 | if (!tsk) | ||
150 | tsk = current; | ||
151 | if (tsk == current) | ||
152 | sp = (unsigned long *)current_stack_pointer; | ||
153 | else | ||
154 | sp = (unsigned long *)tsk->thread.sp; | ||
155 | |||
156 | stack = (unsigned long)sp; | ||
157 | dump_mem("Stack: ", stack, THREAD_SIZE + | ||
158 | (unsigned long)task_stack_page(tsk)); | ||
159 | show_trace(tsk, sp, NULL); | ||
160 | } | ||
161 | |||
162 | void dump_stack(void) | ||
163 | { | ||
164 | show_stack(NULL, NULL); | ||
165 | } | ||
166 | EXPORT_SYMBOL(dump_stack); | ||