1/** 2 * @file backtrace.c 3 * 4 * @remark Copyright 2008 Tensilica Inc. 5 * Copyright (C) 2015 Cadence Design Systems Inc. 6 * @remark Read the file COPYING 7 * 8 */ 9 10#include <linux/oprofile.h> 11#include <asm/ptrace.h> 12#include <asm/stacktrace.h> 13 14static int xtensa_backtrace_cb(struct stackframe *frame, void *data) 15{ 16 oprofile_add_trace(frame->pc); 17 return 0; 18} 19 20void xtensa_backtrace(struct pt_regs * const regs, unsigned int depth) 21{ 22 if (user_mode(regs)) 23 xtensa_backtrace_user(regs, depth, xtensa_backtrace_cb, NULL); 24 else 25 xtensa_backtrace_kernel(regs, depth, xtensa_backtrace_cb, 26 xtensa_backtrace_cb, NULL); 27} 28