stacktrace.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef __ASM_STACKTRACE_H
  3. #define __ASM_STACKTRACE_H
  4. #include <asm/ptrace.h>
  5. #include <linux/llist.h>
  6. struct stackframe {
  7. /*
  8. * FP member should hold R7 when CONFIG_THUMB2_KERNEL is enabled
  9. * and R11 otherwise.
  10. */
  11. unsigned long fp;
  12. unsigned long sp;
  13. unsigned long lr;
  14. unsigned long pc;
  15. /* address of the LR value on the stack */
  16. unsigned long *lr_addr;
  17. #ifdef CONFIG_KRETPROBES
  18. struct llist_node *kr_cur;
  19. struct task_struct *tsk;
  20. #endif
  21. #ifdef CONFIG_UNWINDER_FRAME_POINTER
  22. bool ex_frame;
  23. #endif
  24. };
  25. static __always_inline
  26. void arm_get_current_stackframe(struct pt_regs *regs, struct stackframe *frame)
  27. {
  28. frame->fp = frame_pointer(regs);
  29. frame->sp = regs->ARM_sp;
  30. frame->lr = regs->ARM_lr;
  31. frame->pc = regs->ARM_pc;
  32. #ifdef CONFIG_KRETPROBES
  33. frame->kr_cur = NULL;
  34. frame->tsk = current;
  35. #endif
  36. #ifdef CONFIG_UNWINDER_FRAME_POINTER
  37. frame->ex_frame = in_entry_text(frame->pc);
  38. #endif
  39. }
  40. extern int unwind_frame(struct stackframe *frame);
  41. extern void walk_stackframe(struct stackframe *frame,
  42. int (*fn)(struct stackframe *, void *), void *data);
  43. extern void dump_mem(const char *lvl, const char *str, unsigned long bottom,
  44. unsigned long top);
  45. extern void dump_backtrace(struct pt_regs *regs, struct task_struct *tsk,
  46. const char *loglvl);
  47. #endif /* __ASM_STACKTRACE_H */