[SCSI] net: add FCoE offload support through net_device
[linux-2.6/mini2440.git] / arch / arm / kernel / stacktrace.c
blobfc650f64df43ce00a83ad9f22e33e26b266d76ce
1 #include <linux/module.h>
2 #include <linux/sched.h>
3 #include <linux/stacktrace.h>
5 #include "stacktrace.h"
7 int walk_stackframe(unsigned long fp, unsigned long low, unsigned long high,
8 int (*fn)(struct stackframe *, void *), void *data)
10 struct stackframe *frame;
12 do {
14 * Check current frame pointer is within bounds
16 if (fp < (low + 12) || fp + 4 >= high)
17 break;
19 frame = (struct stackframe *)(fp - 12);
21 if (fn(frame, data))
22 break;
25 * Update the low bound - the next frame must always
26 * be at a higher address than the current frame.
28 low = fp + 4;
29 fp = frame->fp;
30 } while (fp);
32 return 0;
34 EXPORT_SYMBOL(walk_stackframe);
36 #ifdef CONFIG_STACKTRACE
37 struct stack_trace_data {
38 struct stack_trace *trace;
39 unsigned int no_sched_functions;
40 unsigned int skip;
43 static int save_trace(struct stackframe *frame, void *d)
45 struct stack_trace_data *data = d;
46 struct stack_trace *trace = data->trace;
47 unsigned long addr = frame->lr;
49 if (data->no_sched_functions && in_sched_functions(addr))
50 return 0;
51 if (data->skip) {
52 data->skip--;
53 return 0;
56 trace->entries[trace->nr_entries++] = addr;
58 return trace->nr_entries >= trace->max_entries;
61 void save_stack_trace_tsk(struct task_struct *tsk, struct stack_trace *trace)
63 struct stack_trace_data data;
64 unsigned long fp, base;
66 data.trace = trace;
67 data.skip = trace->skip;
68 base = (unsigned long)task_stack_page(tsk);
70 if (tsk != current) {
71 #ifdef CONFIG_SMP
73 * What guarantees do we have here that 'tsk'
74 * is not running on another CPU?
76 BUG();
77 #else
78 data.no_sched_functions = 1;
79 fp = thread_saved_fp(tsk);
80 #endif
81 } else {
82 data.no_sched_functions = 0;
83 asm("mov %0, fp" : "=r" (fp));
86 walk_stackframe(fp, base, base + THREAD_SIZE, save_trace, &data);
87 if (trace->nr_entries < trace->max_entries)
88 trace->entries[trace->nr_entries++] = ULONG_MAX;
91 void save_stack_trace(struct stack_trace *trace)
93 save_stack_trace_tsk(current, trace);
95 EXPORT_SYMBOL_GPL(save_stack_trace);
96 #endif