diff options
author | gonzo <gonzo@FreeBSD.org> | 2012-03-14 23:46:07 +0000 |
---|---|---|
committer | gonzo <gonzo@FreeBSD.org> | 2012-03-14 23:46:07 +0000 |
commit | 0e6c83a1b6b87a39b461e832ccb815fd2aa4ee76 (patch) | |
tree | 00cec0ccafb968b3534176611f63b028d49feac4 /sys/dev/hwpmc/hwpmc_mips.c | |
parent | 5979b593d79907bea314a40ac310b5f2b254e0a1 (diff) | |
download | FreeBSD-src-0e6c83a1b6b87a39b461e832ccb815fd2aa4ee76.zip FreeBSD-src-0e6c83a1b6b87a39b461e832ccb815fd2aa4ee76.tar.gz |
- Remove unncessary type casts
- Make kernel backtrace routine more robust by refusing to backtrace
further when encountered function that is possibly modifies SP
value
Diffstat (limited to 'sys/dev/hwpmc/hwpmc_mips.c')
-rw-r--r-- | sys/dev/hwpmc/hwpmc_mips.c | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/sys/dev/hwpmc/hwpmc_mips.c b/sys/dev/hwpmc/hwpmc_mips.c index a0a324d..4ecb457 100644 --- a/sys/dev/hwpmc/hwpmc_mips.c +++ b/sys/dev/hwpmc/hwpmc_mips.c @@ -150,6 +150,15 @@ pmc_next_frame(register_t *pc, register_t *sp) 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, int nframes, 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, int nframes, 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 |