arm64: dts: Revert "specify console via command line"
[linux/fpc-iii.git] / arch / openrisc / kernel / stacktrace.c
blob43f140a28bc7257ddbc20a713fe10e900dd371e0
1 /*
2 * Stack trace utility for OpenRISC
4 * Copyright (C) 2017 Stafford Horne <shorne@gmail.com>
6 * This file is licensed under the terms of the GNU General Public License
7 * version 2. This program is licensed "as is" without any warranty of any
8 * kind, whether express or implied.
10 * Losely based on work from sh and powerpc.
13 #include <linux/export.h>
14 #include <linux/sched.h>
15 #include <linux/sched/debug.h>
16 #include <linux/stacktrace.h>
18 #include <asm/processor.h>
19 #include <asm/unwinder.h>
22 * Save stack-backtrace addresses into a stack_trace buffer.
24 static void
25 save_stack_address(void *data, unsigned long addr, int reliable)
27 struct stack_trace *trace = data;
29 if (!reliable)
30 return;
32 if (trace->skip > 0) {
33 trace->skip--;
34 return;
37 if (trace->nr_entries < trace->max_entries)
38 trace->entries[trace->nr_entries++] = addr;
41 void save_stack_trace(struct stack_trace *trace)
43 unwind_stack(trace, (unsigned long *) &trace, save_stack_address);
45 EXPORT_SYMBOL_GPL(save_stack_trace);
47 static void
48 save_stack_address_nosched(void *data, unsigned long addr, int reliable)
50 struct stack_trace *trace = (struct stack_trace *)data;
52 if (!reliable)
53 return;
55 if (in_sched_functions(addr))
56 return;
58 if (trace->skip > 0) {
59 trace->skip--;
60 return;
63 if (trace->nr_entries < trace->max_entries)
64 trace->entries[trace->nr_entries++] = addr;
67 void save_stack_trace_tsk(struct task_struct *tsk, struct stack_trace *trace)
69 unsigned long *sp = NULL;
71 if (tsk == current)
72 sp = (unsigned long *) &sp;
73 else
74 sp = (unsigned long *) KSTK_ESP(tsk);
76 unwind_stack(trace, sp, save_stack_address_nosched);
78 EXPORT_SYMBOL_GPL(save_stack_trace_tsk);
80 void
81 save_stack_trace_regs(struct pt_regs *regs, struct stack_trace *trace)
83 unwind_stack(trace, (unsigned long *) regs->sp,
84 save_stack_address_nosched);
86 EXPORT_SYMBOL_GPL(save_stack_trace_regs);