diff options
| -rw-r--r-- | arch/microblaze/Kconfig | 3 | ||||
| -rw-r--r-- | arch/microblaze/kernel/Makefile | 1 | ||||
| -rw-r--r-- | arch/microblaze/kernel/stacktrace.c | 65 |
3 files changed, 69 insertions, 0 deletions
diff --git a/arch/microblaze/Kconfig b/arch/microblaze/Kconfig index bbd8327f189..8e1c4f7d3e6 100644 --- a/arch/microblaze/Kconfig +++ b/arch/microblaze/Kconfig | |||
| @@ -57,6 +57,9 @@ config GENERIC_GPIO | |||
| 57 | config GENERIC_CSUM | 57 | config GENERIC_CSUM |
| 58 | def_bool y | 58 | def_bool y |
| 59 | 59 | ||
| 60 | config STACKTRACE_SUPPORT | ||
| 61 | def_bool y | ||
| 62 | |||
| 60 | config PCI | 63 | config PCI |
| 61 | def_bool n | 64 | def_bool n |
| 62 | 65 | ||
diff --git a/arch/microblaze/kernel/Makefile b/arch/microblaze/kernel/Makefile index fddd0c403d4..c465a5c4669 100644 --- a/arch/microblaze/kernel/Makefile +++ b/arch/microblaze/kernel/Makefile | |||
| @@ -16,5 +16,6 @@ obj-$(CONFIG_SELFMOD) += selfmod.o | |||
| 16 | obj-$(CONFIG_HEART_BEAT) += heartbeat.o | 16 | obj-$(CONFIG_HEART_BEAT) += heartbeat.o |
| 17 | obj-$(CONFIG_MODULES) += microblaze_ksyms.o module.o | 17 | obj-$(CONFIG_MODULES) += microblaze_ksyms.o module.o |
| 18 | obj-$(CONFIG_MMU) += misc.o | 18 | obj-$(CONFIG_MMU) += misc.o |
| 19 | obj-$(CONFIG_STACKTRACE) += stacktrace.o | ||
| 19 | 20 | ||
| 20 | obj-y += entry$(MMU).o | 21 | obj-y += entry$(MMU).o |
diff --git a/arch/microblaze/kernel/stacktrace.c b/arch/microblaze/kernel/stacktrace.c new file mode 100644 index 00000000000..123692f2264 --- /dev/null +++ b/arch/microblaze/kernel/stacktrace.c | |||
| @@ -0,0 +1,65 @@ | |||
| 1 | /* | ||
| 2 | * Stack trace support for Microblaze. | ||
| 3 | * | ||
| 4 | * Copyright (C) 2009 Michal Simek <monstr@monstr.eu> | ||
| 5 | * Copyright (C) 2009 PetaLogix | ||
| 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. | ||
| 10 | */ | ||
| 11 | |||
| 12 | #include <linux/sched.h> | ||
| 13 | #include <linux/stacktrace.h> | ||
| 14 | #include <linux/thread_info.h> | ||
| 15 | #include <linux/ptrace.h> | ||
| 16 | #include <linux/module.h> | ||
| 17 | |||
| 18 | /* FIXME initial support */ | ||
| 19 | void save_stack_trace(struct stack_trace *trace) | ||
| 20 | { | ||
| 21 | unsigned long *sp; | ||
| 22 | unsigned long addr; | ||
| 23 | asm("addik %0, r1, 0" : "=r" (sp)); | ||
| 24 | |||
| 25 | while (!kstack_end(sp)) { | ||
| 26 | addr = *sp++; | ||
| 27 | if (__kernel_text_address(addr)) { | ||
| 28 | if (trace->skip > 0) | ||
| 29 | trace->skip--; | ||
| 30 | else | ||
| 31 | trace->entries[trace->nr_entries++] = addr; | ||
| 32 | |||
| 33 | if (trace->nr_entries >= trace->max_entries) | ||
| 34 | break; | ||
| 35 | } | ||
| 36 | } | ||
| 37 | } | ||
| 38 | EXPORT_SYMBOL_GPL(save_stack_trace); | ||
| 39 | |||
| 40 | void save_stack_trace_tsk(struct task_struct *tsk, struct stack_trace *trace) | ||
| 41 | { | ||
| 42 | unsigned int *sp; | ||
| 43 | unsigned long addr; | ||
| 44 | |||
| 45 | struct thread_info *ti = task_thread_info(tsk); | ||
| 46 | |||
| 47 | if (tsk == current) | ||
| 48 | asm("addik %0, r1, 0" : "=r" (sp)); | ||
| 49 | else | ||
| 50 | sp = (unsigned int *)ti->cpu_context.r1; | ||
| 51 | |||
| 52 | while (!kstack_end(sp)) { | ||
| 53 | addr = *sp++; | ||
| 54 | if (__kernel_text_address(addr)) { | ||
| 55 | if (trace->skip > 0) | ||
| 56 | trace->skip--; | ||
| 57 | else | ||
| 58 | trace->entries[trace->nr_entries++] = addr; | ||
| 59 | |||
| 60 | if (trace->nr_entries >= trace->max_entries) | ||
| 61 | break; | ||
| 62 | } | ||
| 63 | } | ||
| 64 | } | ||
| 65 | EXPORT_SYMBOL_GPL(save_stack_trace_tsk); | ||
