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