12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- #include <linux/sched.h>
- #include <linux/stacktrace.h>
- #include <linux/thread_info.h>
- #include <linux/module.h>
- register unsigned long current_frame_pointer asm("r30");
- struct stackframe {
- unsigned long fp;
- unsigned long rets;
- };
- void save_stack_trace(struct stack_trace *trace)
- {
- unsigned long low, high;
- unsigned long fp;
- struct stackframe *frame;
- int skip = trace->skip;
- low = (unsigned long)task_stack_page(current);
- high = low + THREAD_SIZE;
- fp = current_frame_pointer;
- while (fp >= low && fp <= (high - sizeof(*frame))) {
- frame = (struct stackframe *)fp;
- if (skip) {
- skip--;
- } else {
- trace->entries[trace->nr_entries++] = frame->rets;
- if (trace->nr_entries >= trace->max_entries)
- break;
- }
-
- low = fp + sizeof(*frame);
- fp = frame->fp;
- }
- }
- EXPORT_SYMBOL_GPL(save_stack_trace);
|