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