xref: /openbmc/linux/arch/ia64/kernel/stacktrace.c (revision c4f7ac64)
1 // SPDX-License-Identifier: GPL-2.0
2 /*
3  * arch/ia64/kernel/stacktrace.c
4  *
5  * Stack trace management functions
6  *
7  */
8 #include <linux/sched.h>
9 #include <linux/stacktrace.h>
10 #include <linux/module.h>
11 
12 static void
13 ia64_do_save_stack(struct unw_frame_info *info, void *arg)
14 {
15 	struct stack_trace *trace = arg;
16 	unsigned long ip;
17 	int skip = trace->skip;
18 
19 	trace->nr_entries = 0;
20 	do {
21 		unw_get_ip(info, &ip);
22 		if (ip == 0)
23 			break;
24 		if (skip == 0) {
25 			trace->entries[trace->nr_entries++] = ip;
26 			if (trace->nr_entries == trace->max_entries)
27 				break;
28 		} else
29 			skip--;
30 	} while (unw_unwind(info) >= 0);
31 }
32 
33 /*
34  * Save stack-backtrace addresses into a stack_trace buffer.
35  */
36 void save_stack_trace(struct stack_trace *trace)
37 {
38 	unw_init_running(ia64_do_save_stack, trace);
39 }
40 EXPORT_SYMBOL(save_stack_trace);
41