blob: 8f952034e161b03ab806555ac36b06f8f4c74f76 [file] [log] [blame]
danne6ffe172008-05-21 17:43:50 -07001/**
2 * @file backtrace.c
3 *
4 * @remark Copyright 2008 Tensilica Inc.
Max Filippov5fdf3772015-06-25 07:27:16 +03005 * Copyright (C) 2015 Cadence Design Systems Inc.
danne6ffe172008-05-21 17:43:50 -07006 * @remark Read the file COPYING
7 *
8 */
9
10#include <linux/oprofile.h>
danne6ffe172008-05-21 17:43:50 -070011#include <asm/ptrace.h>
Max Filippov5fdf3772015-06-25 07:27:16 +030012#include <asm/stacktrace.h>
danne6ffe172008-05-21 17:43:50 -070013
Max Filippov5fdf3772015-06-25 07:27:16 +030014static int xtensa_backtrace_cb(struct stackframe *frame, void *data)
danne6ffe172008-05-21 17:43:50 -070015{
Max Filippov5fdf3772015-06-25 07:27:16 +030016 oprofile_add_trace(frame->pc);
17 return 0;
danne6ffe172008-05-21 17:43:50 -070018}
19
20void xtensa_backtrace(struct pt_regs * const regs, unsigned int depth)
21{
22 if (user_mode(regs))
Max Filippov5fdf3772015-06-25 07:27:16 +030023 xtensa_backtrace_user(regs, depth, xtensa_backtrace_cb, NULL);
danne6ffe172008-05-21 17:43:50 -070024 else
Max Filippov5fdf3772015-06-25 07:27:16 +030025 xtensa_backtrace_kernel(regs, depth, xtensa_backtrace_cb,
26 xtensa_backtrace_cb, NULL);
danne6ffe172008-05-21 17:43:50 -070027}