usb-storage: separate dynamic flags from fixed flags
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / arch / sparc64 / kernel / stacktrace.c
blobb3e3737750d8bfb49701a862a6c57a821303fc18
1 #include <linux/sched.h>
2 #include <linux/stacktrace.h>
3 #include <linux/thread_info.h>
4 #include <linux/module.h>
5 #include <asm/ptrace.h>
6 #include <asm/stacktrace.h>
8 void save_stack_trace(struct stack_trace *trace)
10 unsigned long ksp, fp, thread_base;
11 struct thread_info *tp = task_thread_info(current);
13 stack_trace_flush();
15 __asm__ __volatile__(
16 "mov %%fp, %0"
17 : "=r" (ksp)
20 fp = ksp + STACK_BIAS;
21 thread_base = (unsigned long) tp;
22 do {
23 struct sparc_stackf *sf;
24 struct pt_regs *regs;
25 unsigned long pc;
27 /* Bogus frame pointer? */
28 if (fp < (thread_base + sizeof(struct thread_info)) ||
29 fp >= (thread_base + THREAD_SIZE))
30 break;
32 sf = (struct sparc_stackf *) fp;
33 regs = (struct pt_regs *) (sf + 1);
35 if ((regs->magic & ~0x1ff) == PT_REGS_MAGIC) {
36 if (!(regs->tstate & TSTATE_PRIV))
37 break;
38 pc = regs->tpc;
39 fp = regs->u_regs[UREG_I6] + STACK_BIAS;
40 } else {
41 pc = sf->callers_pc;
42 fp = (unsigned long)sf->fp + STACK_BIAS;
45 if (trace->skip > 0)
46 trace->skip--;
47 else
48 trace->entries[trace->nr_entries++] = pc;
49 } while (trace->nr_entries < trace->max_entries);
51 EXPORT_SYMBOL_GPL(save_stack_trace);