diff options
author | Linus Torvalds <torvalds@g5.osdl.org> | 2006-10-02 08:18:43 -0700 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-10-02 08:18:43 -0700 |
commit | 12dce6263d43daeb4e16fa4eb964c1c99fa4fa2e (patch) | |
tree | e70a514e5fec67be191e12eba508db8ced967a4b /arch/mips/kernel/stacktrace.c | |
parent | 3f2e05e90e0846c42626e3d272454f26be34a1bc (diff) | |
parent | 04b314b2c3732bb5aa752fdbb3076de16decdab6 (diff) |
Merge branch 'upstream' of git://ftp.linux-mips.org/pub/scm/upstream-linus
* 'upstream' of git://ftp.linux-mips.org/pub/scm/upstream-linus:
[MIPS] Remove unused galileo-boars header files
[MIPS] Rename SERIAL_PORT_DEFNS for EV64120
[MIPS] Add UART IRQ number for EV64120
[MIPS] Remove excite_flash.c
[MIPS] Update i8259 resources.
[MIPS] Make unwind_stack() can dig into interrupted context
[MIPS] Stacktrace build-fix and improvement
[MIPS] QEMU: Add support for little endian mips
[MIPS] Remove __flush_icache_page
[MIPS] lockdep: update defconfigs
[MIPS] lockdep: Add STACKTRACE_SUPPORT and enable LOCKDEP_SUPPORT
[MIPS] lockdep: fix TRACE_IRQFLAGS_SUPPORT
Diffstat (limited to 'arch/mips/kernel/stacktrace.c')
-rw-r--r-- | arch/mips/kernel/stacktrace.c | 85 |
1 files changed, 85 insertions, 0 deletions
diff --git a/arch/mips/kernel/stacktrace.c b/arch/mips/kernel/stacktrace.c new file mode 100644 index 00000000000..4aabe526a68 --- /dev/null +++ b/arch/mips/kernel/stacktrace.c @@ -0,0 +1,85 @@ +/* + * arch/mips/kernel/stacktrace.c + * + * Stack trace management functions + * + * Copyright (C) 2006 Atsushi Nemoto <anemo@mba.ocn.ne.jp> + */ +#include <linux/sched.h> +#include <linux/stacktrace.h> +#include <asm/stacktrace.h> + +/* + * Save stack-backtrace addresses into a stack_trace buffer: + */ +static void save_raw_context_stack(struct stack_trace *trace, + unsigned long reg29) +{ + unsigned long *sp = (unsigned long *)reg29; + unsigned long addr; + + while (!kstack_end(sp)) { + addr = *sp++; + if (__kernel_text_address(addr)) { + if (trace->skip > 0) + trace->skip--; + else + trace->entries[trace->nr_entries++] = addr; + if (trace->nr_entries >= trace->max_entries) + break; + } + } +} + +static void save_context_stack(struct stack_trace *trace, + struct task_struct *task, struct pt_regs *regs) +{ + unsigned long sp = regs->regs[29]; +#ifdef CONFIG_KALLSYMS + unsigned long ra = regs->regs[31]; + unsigned long pc = regs->cp0_epc; + + if (raw_show_trace || !__kernel_text_address(pc)) { + unsigned long stack_page = + (unsigned long)task_stack_page(task); + if (stack_page && sp >= stack_page && + sp <= stack_page + THREAD_SIZE - 32) + save_raw_context_stack(trace, sp); + return; + } + do { + if (trace->skip > 0) + trace->skip--; + else + trace->entries[trace->nr_entries++] = pc; + if (trace->nr_entries >= trace->max_entries) + break; + pc = unwind_stack(task, &sp, pc, &ra); + } while (pc); +#else + save_raw_context_stack(sp); +#endif +} + +/* + * Save stack-backtrace addresses into a stack_trace buffer. + */ +void save_stack_trace(struct stack_trace *trace, struct task_struct *task) +{ + struct pt_regs dummyregs; + struct pt_regs *regs = &dummyregs; + + WARN_ON(trace->nr_entries || !trace->max_entries); + + if (task && task != current) { + regs->regs[29] = task->thread.reg29; + regs->regs[31] = 0; + regs->cp0_epc = task->thread.reg31; + } else { + if (!task) + task = current; + prepare_frametrace(regs); + } + + save_context_stack(trace, task, regs); +} |