diff options
author | Franck Bui-Huu <vagabon.xyz@gmail.com> | 2006-08-03 09:29:21 +0200 |
---|---|---|
committer | Ralf Baechle <ralf@linux-mips.org> | 2006-09-27 13:37:29 +0100 |
commit | 4d157d5eac29d7d5559fdcabf20f3961bc5cb3e7 (patch) | |
tree | 82662abbe473e5bd0be973e2a8ceb8b63082da55 /arch/mips/kernel/process.c | |
parent | 0cceb4aa9acf6192a5f02134e764b1feeea8b9de (diff) | |
download | op-kernel-dev-4d157d5eac29d7d5559fdcabf20f3961bc5cb3e7.zip op-kernel-dev-4d157d5eac29d7d5559fdcabf20f3961bc5cb3e7.tar.gz |
[MIPS] Improve unwind_stack()
This patch allows unwind_stack() to return ra for leaf function.
But it tries to detects cases where get_frame_info() wrongly
consider nested function as a leaf one.
It also pass 'unsinged long *sp' instead of 'unsigned long **sp'
as second parameter. The code looks cleaner.
Signed-off-by: Franck Bui-Huu <vagabon.xyz@gmail.com>
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Diffstat (limited to 'arch/mips/kernel/process.c')
-rw-r--r-- | arch/mips/kernel/process.c | 35 |
1 files changed, 22 insertions, 13 deletions
diff --git a/arch/mips/kernel/process.c b/arch/mips/kernel/process.c index 309bfa4..951bf9c 100644 --- a/arch/mips/kernel/process.c +++ b/arch/mips/kernel/process.c @@ -448,15 +448,16 @@ unsigned long get_wchan(struct task_struct *p) } #ifdef CONFIG_KALLSYMS -/* used by show_frametrace() */ -unsigned long unwind_stack(struct task_struct *task, - unsigned long **sp, unsigned long pc) +/* used by show_backtrace() */ +unsigned long unwind_stack(struct task_struct *task, unsigned long *sp, + unsigned long pc, unsigned long ra) { unsigned long stack_page; struct mips_frame_info info; char *modname; char namebuf[KSYM_NAME_LEN + 1]; unsigned long size, ofs; + int leaf; stack_page = (unsigned long)task_stack_page(task); if (!stack_page) @@ -469,18 +470,26 @@ unsigned long unwind_stack(struct task_struct *task, info.func = (void *)(pc - ofs); info.func_size = ofs; /* analyze from start to ofs */ - if (get_frame_info(&info)) { - /* leaf or unknown */ - *sp += info.frame_size / sizeof(long); + leaf = get_frame_info(&info); + if (leaf < 0) return 0; - } - if ((unsigned long)*sp < stack_page || - (unsigned long)*sp + info.frame_size / sizeof(long) > - stack_page + THREAD_SIZE - 32) + + if (*sp < stack_page || + *sp + info.frame_size > stack_page + THREAD_SIZE - 32) return 0; - pc = (*sp)[info.pc_offset]; - *sp += info.frame_size / sizeof(long); - return pc; + if (leaf) + /* + * For some extreme cases, get_frame_info() can + * consider wrongly a nested function as a leaf + * one. In that cases avoid to return always the + * same value. + */ + pc = pc != ra ? ra : 0; + else + pc = ((unsigned long *)(*sp))[info.pc_offset]; + + *sp += info.frame_size; + return __kernel_text_address(pc) ? pc : 0; } #endif |