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