unwind.c 742 B

1234567891011121314151617181920212223242526272829303132
  1. // SPDX-License-Identifier: GPL-2.0
  2. /*
  3. * Copyright (C) 2022-2023 Loongson Technology Corporation Limited
  4. */
  5. #include <linux/kernel.h>
  6. #include <linux/ftrace.h>
  7. #include <asm/unwind.h>
  8. bool default_next_frame(struct unwind_state *state)
  9. {
  10. struct stack_info *info = &state->stack_info;
  11. unsigned long addr;
  12. if (unwind_done(state))
  13. return false;
  14. do {
  15. for (state->sp += sizeof(unsigned long);
  16. state->sp < info->end; state->sp += sizeof(unsigned long)) {
  17. addr = *(unsigned long *)(state->sp);
  18. state->pc = unwind_graph_addr(state, addr, state->sp + 8);
  19. if (__kernel_text_address(state->pc))
  20. return true;
  21. }
  22. state->sp = info->next_sp;
  23. } while (!get_stack_info(state->sp, state->task, info));
  24. return false;
  25. }