1 #include <linux/sched.h>
2 #include <linux/stacktrace.h>
4 #include "stacktrace.h"
6 int walk_stackframe(unsigned long fp, unsigned long low, unsigned long high,
7 int (*fn)(struct stackframe *, void *), void *data)
9 struct stackframe *frame;
13 * Check current frame pointer is within bounds
15 if ((fp - 12) < low || fp + 4 >= high)
18 frame = (struct stackframe *)(fp - 12);
24 * Update the low bound - the next frame must always
25 * be at a higher address than the current frame.
34 #ifdef CONFIG_STACKTRACE
35 struct stack_trace_data {
36 struct stack_trace *trace;
40 static int save_trace(struct stackframe *frame, void *d)
42 struct stack_trace_data *data = d;
43 struct stack_trace *trace = data->trace;
50 trace->entries[trace->nr_entries++] = frame->lr;
52 return trace->nr_entries >= trace->max_entries;
55 void save_stack_trace(struct stack_trace *trace, struct task_struct *task)
57 struct stack_trace_data data;
58 unsigned long fp, base;
61 data.skip = trace->skip;
64 base = (unsigned long)task_stack_page(task);
67 base = (unsigned long)task_stack_page(current);
68 asm("mov %0, fp" : "=r" (fp));
71 walk_stackframe(fp, base, base + THREAD_SIZE, save_trace, &data);