2006-11-16 14:38:57 -07:00
|
|
|
#include <linux/sched.h>
|
|
|
|
#include <linux/stacktrace.h>
|
|
|
|
#include <linux/thread_info.h>
|
|
|
|
#include <asm/ptrace.h>
|
2008-03-24 21:06:24 -06:00
|
|
|
#include <asm/stacktrace.h>
|
2006-11-16 14:38:57 -07:00
|
|
|
|
2007-05-08 01:23:29 -06:00
|
|
|
void save_stack_trace(struct stack_trace *trace)
|
2006-11-16 14:38:57 -07:00
|
|
|
{
|
|
|
|
unsigned long ksp, fp, thread_base;
|
2007-05-08 01:23:29 -06:00
|
|
|
struct thread_info *tp = task_thread_info(current);
|
2006-11-16 14:38:57 -07:00
|
|
|
|
2008-03-24 21:06:24 -06:00
|
|
|
stack_trace_flush();
|
|
|
|
|
2007-05-08 01:23:29 -06:00
|
|
|
__asm__ __volatile__(
|
|
|
|
"mov %%fp, %0"
|
|
|
|
: "=r" (ksp)
|
|
|
|
);
|
2006-11-16 14:38:57 -07:00
|
|
|
|
|
|
|
fp = ksp + STACK_BIAS;
|
|
|
|
thread_base = (unsigned long) tp;
|
|
|
|
do {
|
|
|
|
struct reg_window *rw;
|
2008-04-24 04:28:52 -06:00
|
|
|
struct pt_regs *regs;
|
|
|
|
unsigned long pc;
|
2006-11-16 14:38:57 -07:00
|
|
|
|
|
|
|
/* Bogus frame pointer? */
|
|
|
|
if (fp < (thread_base + sizeof(struct thread_info)) ||
|
|
|
|
fp >= (thread_base + THREAD_SIZE))
|
|
|
|
break;
|
|
|
|
|
|
|
|
rw = (struct reg_window *) fp;
|
2008-04-24 04:28:52 -06:00
|
|
|
regs = (struct pt_regs *) (rw + 1);
|
|
|
|
|
|
|
|
if ((regs->magic & ~0x1ff) == PT_REGS_MAGIC) {
|
|
|
|
pc = regs->tpc;
|
|
|
|
fp = regs->u_regs[UREG_I6] + STACK_BIAS;
|
|
|
|
} else {
|
|
|
|
pc = rw->ins[7];
|
|
|
|
fp = rw->ins[6] + STACK_BIAS;
|
|
|
|
}
|
|
|
|
|
2006-11-16 14:38:57 -07:00
|
|
|
if (trace->skip > 0)
|
|
|
|
trace->skip--;
|
|
|
|
else
|
2008-04-24 04:28:52 -06:00
|
|
|
trace->entries[trace->nr_entries++] = pc;
|
2006-11-16 14:38:57 -07:00
|
|
|
} while (trace->nr_entries < trace->max_entries);
|
|
|
|
}
|