unwind.h 926 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  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. #include <linux/sched.h>
  10. #include <asm/stacktrace.h>
  11. enum unwinder_type {
  12. UNWINDER_GUESS,
  13. UNWINDER_PROLOGUE,
  14. };
  15. struct unwind_state {
  16. char type; /* UNWINDER_XXX */
  17. struct stack_info stack_info;
  18. struct task_struct *task;
  19. bool first, error;
  20. unsigned long sp, pc, ra;
  21. };
  22. void unwind_start(struct unwind_state *state,
  23. struct task_struct *task, struct pt_regs *regs);
  24. bool unwind_next_frame(struct unwind_state *state);
  25. unsigned long unwind_get_return_address(struct unwind_state *state);
  26. static inline bool unwind_done(struct unwind_state *state)
  27. {
  28. return state->stack_info.type == STACK_TYPE_UNKNOWN;
  29. }
  30. static inline bool unwind_error(struct unwind_state *state)
  31. {
  32. return state->error;
  33. }
  34. #endif /* _ASM_UNWIND_H */