Date: Wed, 14 Mar 2012 23:46:07 +0000 (UTC) From: Oleksandr Tymoshenko <gonzo@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r232992 - head/sys/dev/hwpmc Message-ID: <201203142346.q2ENk7qJ037331@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: gonzo Date: Wed Mar 14 23:46:07 2012 New Revision: 232992 URL: http://svn.freebsd.org/changeset/base/232992 Log: - Remove unncessary type casts - Make kernel backtrace routine more robust by refusing to backtrace further when encountered function that is possibly modifies SP value Modified: head/sys/dev/hwpmc/hwpmc_mips.c Modified: head/sys/dev/hwpmc/hwpmc_mips.c ============================================================================== --- head/sys/dev/hwpmc/hwpmc_mips.c Wed Mar 14 23:25:46 2012 (r232991) +++ head/sys/dev/hwpmc/hwpmc_mips.c Wed Mar 14 23:46:07 2012 (r232992) @@ -150,6 +150,15 @@ pmc_next_frame(register_t *pc, register_ case OP_SW: case OP_SD: + /* + * SP is being saved using S8(FP). Most likely it indicates + * that SP is modified in the function and we can't get + * its value safely without emulating code backward + * So just bail out on functions like this + */ + if ((i.IType.rs == 30) && (i.IType.rt = 29)) + return (-1); + /* look for saved registers on the stack */ if (i.IType.rs != 29) break; @@ -327,9 +336,9 @@ pmc_save_kernel_callchain(uintptr_t *cc, register_t pc, ra, sp; int frames = 0; - pc = (uint64_t)tf->pc; - sp = (uint64_t)tf->sp; - ra = (uint64_t)tf->ra; + pc = tf->pc; + sp = tf->sp; + ra = tf->ra; /* * Unwind, and unwind, and unwind @@ -353,9 +362,9 @@ pmc_save_user_callchain(uintptr_t *cc, i register_t pc, ra, sp; int frames = 0; - pc = (uint64_t)tf->pc; - sp = (uint64_t)tf->sp; - ra = (uint64_t)tf->ra; + pc = tf->pc; + sp = tf->sp; + ra = tf->ra; /* * Unwind, and unwind, and unwind
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201203142346.q2ENk7qJ037331>