]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blob - arch/sparc64/kernel/stacktrace.c
237e7f8a40ac6f0bd3e161aca622b06ebd96366f
[linux-2.6-omap-h63xx.git] / arch / sparc64 / kernel / stacktrace.c
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>
7
8 #include "kstack.h"
9
10 void save_stack_trace(struct stack_trace *trace)
11 {
12         unsigned long ksp, fp, thread_base;
13         struct thread_info *tp = task_thread_info(current);
14
15         stack_trace_flush();
16
17         __asm__ __volatile__(
18                 "mov    %%fp, %0"
19                 : "=r" (ksp)
20         );
21
22         fp = ksp + STACK_BIAS;
23         thread_base = (unsigned long) tp;
24         do {
25                 struct sparc_stackf *sf;
26                 struct pt_regs *regs;
27                 unsigned long pc;
28
29                 if (!kstack_valid(tp, fp))
30                         break;
31
32                 sf = (struct sparc_stackf *) fp;
33                 regs = (struct pt_regs *) (sf + 1);
34
35                 if (kstack_is_trap_frame(tp, regs)) {
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;
43                 }
44
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);
50 }
51 EXPORT_SYMBOL_GPL(save_stack_trace);