xref: /linux/arch/loongarch/kernel/unwind.c (revision d642ef71)
1 // SPDX-License-Identifier: GPL-2.0
2 /*
3  * Copyright (C) 2022-2023 Loongson Technology Corporation Limited
4  */
5 #include <linux/kernel.h>
6 #include <linux/ftrace.h>
7 
8 #include <asm/unwind.h>
9 
10 bool default_next_frame(struct unwind_state *state)
11 {
12 	struct stack_info *info = &state->stack_info;
13 	unsigned long addr;
14 
15 	if (unwind_done(state))
16 		return false;
17 
18 	do {
19 		for (state->sp += sizeof(unsigned long);
20 		     state->sp < info->end; state->sp += sizeof(unsigned long)) {
21 			addr = *(unsigned long *)(state->sp);
22 			state->pc = unwind_graph_addr(state, addr, state->sp + 8);
23 			if (__kernel_text_address(state->pc))
24 				return true;
25 		}
26 
27 		state->sp = info->next_sp;
28 
29 	} while (!get_stack_info(state->sp, state->task, info));
30 
31 	return false;
32 }
33