Path: blob/master/arch/blackfin/kernel/stacktrace.c
10817 views
/*1* Blackfin stacktrace code (mostly copied from avr32)2*3* Copyright 2009 Analog Devices Inc.4* Licensed under the GPL-2 or later.5*/67#include <linux/sched.h>8#include <linux/stacktrace.h>9#include <linux/thread_info.h>10#include <linux/module.h>1112register unsigned long current_frame_pointer asm("FP");1314struct stackframe {15unsigned long fp;16unsigned long rets;17};1819/*20* Save stack-backtrace addresses into a stack_trace buffer.21*/22void save_stack_trace(struct stack_trace *trace)23{24unsigned long low, high;25unsigned long fp;26struct stackframe *frame;27int skip = trace->skip;2829low = (unsigned long)task_stack_page(current);30high = low + THREAD_SIZE;31fp = current_frame_pointer;3233while (fp >= low && fp <= (high - sizeof(*frame))) {34frame = (struct stackframe *)fp;3536if (skip) {37skip--;38} else {39trace->entries[trace->nr_entries++] = frame->rets;40if (trace->nr_entries >= trace->max_entries)41break;42}4344/*45* The next frame must be at a higher address than the46* current frame.47*/48low = fp + sizeof(*frame);49fp = frame->fp;50}51}52EXPORT_SYMBOL_GPL(save_stack_trace);535455