xref: /linux/arch/loongarch/include/asm/unwind.h (revision 49232773d8233ed70c4998851bc84e465fc1c788)
1*49232773SQing Zhang /* SPDX-License-Identifier: GPL-2.0 */
2*49232773SQing Zhang /*
3*49232773SQing Zhang  * Most of this ideas comes from x86.
4*49232773SQing Zhang  *
5*49232773SQing Zhang  * Copyright (C) 2022 Loongson Technology Corporation Limited
6*49232773SQing Zhang  */
7*49232773SQing Zhang #ifndef _ASM_UNWIND_H
8*49232773SQing Zhang #define _ASM_UNWIND_H
9*49232773SQing Zhang 
10*49232773SQing Zhang #include <linux/sched.h>
11*49232773SQing Zhang 
12*49232773SQing Zhang #include <asm/stacktrace.h>
13*49232773SQing Zhang 
14*49232773SQing Zhang struct unwind_state {
15*49232773SQing Zhang 	struct stack_info stack_info;
16*49232773SQing Zhang 	struct task_struct *task;
17*49232773SQing Zhang 	bool first, error;
18*49232773SQing Zhang 	unsigned long sp, pc;
19*49232773SQing Zhang };
20*49232773SQing Zhang 
21*49232773SQing Zhang void unwind_start(struct unwind_state *state,
22*49232773SQing Zhang 		  struct task_struct *task, struct pt_regs *regs);
23*49232773SQing Zhang bool unwind_next_frame(struct unwind_state *state);
24*49232773SQing Zhang unsigned long unwind_get_return_address(struct unwind_state *state);
25*49232773SQing Zhang 
26*49232773SQing Zhang static inline bool unwind_done(struct unwind_state *state)
27*49232773SQing Zhang {
28*49232773SQing Zhang 	return state->stack_info.type == STACK_TYPE_UNKNOWN;
29*49232773SQing Zhang }
30*49232773SQing Zhang 
31*49232773SQing Zhang static inline bool unwind_error(struct unwind_state *state)
32*49232773SQing Zhang {
33*49232773SQing Zhang 	return state->error;
34*49232773SQing Zhang }
35*49232773SQing Zhang 
36*49232773SQing Zhang #endif /* _ASM_UNWIND_H */
37