diff options
| author | Vineet Gupta <vgupta@synopsys.com> | 2013-07-10 10:03:45 -0400 |
|---|---|---|
| committer | Vineet Gupta <vgupta@synopsys.com> | 2015-02-26 23:45:00 -0500 |
| commit | 3a51d50f426cbb65add424baebe511dcf5ac45cc (patch) | |
| tree | ae5b585e83bd9d4198c8e1307baeb1d9fbad02ac | |
| parent | c517d838eb7d07bbe9507871fab3931deccff539 (diff) | |
ARC: Make arc_unwind_core accessible externally
The arc unwinder can also be used for perf callchains.
Signed-off-by: Mischa Jonker <mjonker@synopsys.com>
Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
| -rw-r--r-- | arch/arc/include/asm/stacktrace.h | 37 | ||||
| -rw-r--r-- | arch/arc/kernel/stacktrace.c | 15 |
2 files changed, 51 insertions, 1 deletions
diff --git a/arch/arc/include/asm/stacktrace.h b/arch/arc/include/asm/stacktrace.h new file mode 100644 index 000000000000..b29b6064ea14 --- /dev/null +++ b/arch/arc/include/asm/stacktrace.h | |||
| @@ -0,0 +1,37 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2014-15 Synopsys, Inc. (www.synopsys.com) | ||
| 3 | * Copyright (C) 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com) | ||
| 4 | * | ||
| 5 | * This program is free software; you can redistribute it and/or modify | ||
| 6 | * it under the terms of the GNU General Public License version 2 as | ||
| 7 | * published by the Free Software Foundation. | ||
| 8 | */ | ||
| 9 | |||
| 10 | #ifndef __ASM_STACKTRACE_H | ||
| 11 | #define __ASM_STACKTRACE_H | ||
| 12 | |||
| 13 | #include <linux/sched.h> | ||
| 14 | |||
| 15 | /** | ||
| 16 | * arc_unwind_core - Unwind the kernel mode stack for an execution context | ||
| 17 | * @tsk: NULL for current task, specific task otherwise | ||
| 18 | * @regs: pt_regs used to seed the unwinder {SP, FP, BLINK, PC} | ||
| 19 | * If NULL, use pt_regs of @tsk (if !NULL) otherwise | ||
| 20 | * use the current values of {SP, FP, BLINK, PC} | ||
| 21 | * @consumer_fn: Callback invoked for each frame unwound | ||
| 22 | * Returns 0 to continue unwinding, -1 to stop | ||
| 23 | * @arg: Arg to callback | ||
| 24 | * | ||
| 25 | * Returns the address of first function in stack | ||
| 26 | * | ||
| 27 | * Semantics: | ||
| 28 | * - synchronous unwinding (e.g. dump_stack): @tsk NULL, @regs NULL | ||
| 29 | * - Asynchronous unwinding of sleeping task: @tsk !NULL, @regs NULL | ||
| 30 | * - Asynchronous unwinding of intr/excp etc: @tsk !NULL, @regs !NULL | ||
| 31 | */ | ||
| 32 | notrace noinline unsigned int arc_unwind_core( | ||
| 33 | struct task_struct *tsk, struct pt_regs *regs, | ||
| 34 | int (*consumer_fn) (unsigned int, void *), | ||
| 35 | void *arg); | ||
| 36 | |||
| 37 | #endif /* __ASM_STACKTRACE_H */ | ||
diff --git a/arch/arc/kernel/stacktrace.c b/arch/arc/kernel/stacktrace.c index 9ce47cfe2303..6492507a3d74 100644 --- a/arch/arc/kernel/stacktrace.c +++ b/arch/arc/kernel/stacktrace.c | |||
| @@ -43,6 +43,10 @@ static void seed_unwind_frame_info(struct task_struct *tsk, | |||
| 43 | struct pt_regs *regs, | 43 | struct pt_regs *regs, |
| 44 | struct unwind_frame_info *frame_info) | 44 | struct unwind_frame_info *frame_info) |
| 45 | { | 45 | { |
| 46 | /* | ||
| 47 | * synchronous unwinding (e.g. dump_stack) | ||
| 48 | * - uses current values of SP and friends | ||
| 49 | */ | ||
| 46 | if (tsk == NULL && regs == NULL) { | 50 | if (tsk == NULL && regs == NULL) { |
| 47 | unsigned long fp, sp, blink, ret; | 51 | unsigned long fp, sp, blink, ret; |
| 48 | frame_info->task = current; | 52 | frame_info->task = current; |
| @@ -61,6 +65,11 @@ static void seed_unwind_frame_info(struct task_struct *tsk, | |||
| 61 | frame_info->regs.r63 = ret; | 65 | frame_info->regs.r63 = ret; |
| 62 | frame_info->call_frame = 0; | 66 | frame_info->call_frame = 0; |
| 63 | } else if (regs == NULL) { | 67 | } else if (regs == NULL) { |
| 68 | /* | ||
| 69 | * Asynchronous unwinding of sleeping task | ||
| 70 | * - Gets SP etc from task's pt_regs (saved bottom of kernel | ||
| 71 | * mode stack of task) | ||
| 72 | */ | ||
| 64 | 73 | ||
| 65 | frame_info->task = tsk; | 74 | frame_info->task = tsk; |
| 66 | 75 | ||
| @@ -83,6 +92,10 @@ static void seed_unwind_frame_info(struct task_struct *tsk, | |||
| 83 | frame_info->call_frame = 0; | 92 | frame_info->call_frame = 0; |
| 84 | 93 | ||
| 85 | } else { | 94 | } else { |
| 95 | /* | ||
| 96 | * Asynchronous unwinding of intr/exception | ||
| 97 | * - Just uses the pt_regs passed | ||
| 98 | */ | ||
| 86 | frame_info->task = tsk; | 99 | frame_info->task = tsk; |
| 87 | 100 | ||
| 88 | frame_info->regs.r27 = regs->fp; | 101 | frame_info->regs.r27 = regs->fp; |
| @@ -95,7 +108,7 @@ static void seed_unwind_frame_info(struct task_struct *tsk, | |||
| 95 | 108 | ||
| 96 | #endif | 109 | #endif |
| 97 | 110 | ||
| 98 | static noinline unsigned int | 111 | notrace noinline unsigned int |
| 99 | arc_unwind_core(struct task_struct *tsk, struct pt_regs *regs, | 112 | arc_unwind_core(struct task_struct *tsk, struct pt_regs *regs, |
| 100 | int (*consumer_fn) (unsigned int, void *), void *arg) | 113 | int (*consumer_fn) (unsigned int, void *), void *arg) |
| 101 | { | 114 | { |
