Commit | Line | Data |
---|---|---|
10e26723 DM |
1 | #include <linux/sched.h> |
2 | #include <linux/stacktrace.h> | |
3 | #include <linux/thread_info.h> | |
a05fe038 | 4 | #include <linux/module.h> |
10e26723 | 5 | #include <asm/ptrace.h> |
85a79353 | 6 | #include <asm/stacktrace.h> |
10e26723 | 7 | |
ab1b6f03 | 8 | void save_stack_trace(struct stack_trace *trace) |
10e26723 DM |
9 | { |
10 | unsigned long ksp, fp, thread_base; | |
ab1b6f03 | 11 | struct thread_info *tp = task_thread_info(current); |
10e26723 | 12 | |
85a79353 DM |
13 | stack_trace_flush(); |
14 | ||
ab1b6f03 CH |
15 | __asm__ __volatile__( |
16 | "mov %%fp, %0" | |
17 | : "=r" (ksp) | |
18 | ); | |
10e26723 DM |
19 | |
20 | fp = ksp + STACK_BIAS; | |
21 | thread_base = (unsigned long) tp; | |
22 | do { | |
14d2c68b | 23 | struct sparc_stackf *sf; |
77c664fa DM |
24 | struct pt_regs *regs; |
25 | unsigned long pc; | |
10e26723 DM |
26 | |
27 | /* Bogus frame pointer? */ | |
28 | if (fp < (thread_base + sizeof(struct thread_info)) || | |
433c5f70 | 29 | fp > (thread_base + THREAD_SIZE - sizeof(struct sparc_stackf))) |
10e26723 DM |
30 | break; |
31 | ||
14d2c68b DM |
32 | sf = (struct sparc_stackf *) fp; |
33 | regs = (struct pt_regs *) (sf + 1); | |
77c664fa | 34 | |
433c5f70 DM |
35 | if (((unsigned long)regs <= |
36 | (thread_base + THREAD_SIZE - sizeof(*regs))) && | |
37 | (regs->magic & ~0x1ff) == PT_REGS_MAGIC) { | |
14d2c68b DM |
38 | if (!(regs->tstate & TSTATE_PRIV)) |
39 | break; | |
77c664fa DM |
40 | pc = regs->tpc; |
41 | fp = regs->u_regs[UREG_I6] + STACK_BIAS; | |
42 | } else { | |
14d2c68b DM |
43 | pc = sf->callers_pc; |
44 | fp = (unsigned long)sf->fp + STACK_BIAS; | |
77c664fa DM |
45 | } |
46 | ||
10e26723 DM |
47 | if (trace->skip > 0) |
48 | trace->skip--; | |
49 | else | |
77c664fa | 50 | trace->entries[trace->nr_entries++] = pc; |
10e26723 DM |
51 | } while (trace->nr_entries < trace->max_entries); |
52 | } | |
7b4c9505 | 53 | EXPORT_SYMBOL_GPL(save_stack_trace); |