unwind_guess.c 1006 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #include <linux/sched.h>
  2. #include <linux/ftrace.h>
  3. #include <asm/ptrace.h>
  4. #include <asm/bitops.h>
  5. #include <asm/stacktrace.h>
  6. #include <asm/unwind.h>
  7. bool unwind_next_frame(struct unwind_state *state)
  8. {
  9. struct stack_info *info = &state->stack_info;
  10. if (unwind_done(state))
  11. return false;
  12. do {
  13. for (state->sp++; state->sp < info->end; state->sp++)
  14. if (__kernel_text_address(*state->sp))
  15. return true;
  16. state->sp = info->next_sp;
  17. } while (!get_stack_info(state->sp, state->task, info,
  18. &state->stack_mask));
  19. return false;
  20. }
  21. EXPORT_SYMBOL_GPL(unwind_next_frame);
  22. void __unwind_start(struct unwind_state *state, struct task_struct *task,
  23. struct pt_regs *regs, unsigned long *first_frame)
  24. {
  25. memset(state, 0, sizeof(*state));
  26. state->task = task;
  27. state->sp = first_frame;
  28. get_stack_info(first_frame, state->task, &state->stack_info,
  29. &state->stack_mask);
  30. if (!__kernel_text_address(*first_frame))
  31. unwind_next_frame(state);
  32. }
  33. EXPORT_SYMBOL_GPL(__unwind_start);