backtrace_64bit.c 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #include <linux/kallsyms.h>
  2. #include <linux/uaccess.h>
  3. #include <linux/delay.h>
  4. #include <linux/sched.h>
  5. #include <asm/traps.h>
  6. #include <asm/stacktrace.h>
  7. #include <asm/system_misc.h>
  8. #include <mtk_ram_console.h>
  9. static inline void aee_print_ip_sym(unsigned long ip)
  10. {
  11. char buf[256];
  12. snprintf(buf, sizeof(buf), "[<%p>] %pS\n", (void *)ip, (void *)ip);
  13. aee_sram_fiq_log(buf);
  14. }
  15. static void dump_backtrace_entry(unsigned long where, unsigned long stack)
  16. {
  17. aee_print_ip_sym(where);
  18. }
  19. void aee_dump_backtrace(struct pt_regs *regs, struct task_struct *tsk)
  20. {
  21. struct stackframe frame;
  22. const register unsigned long current_sp asm("sp");
  23. pr_debug("%s(regs = %p tsk = %p)\n", __func__, regs, tsk);
  24. if (!tsk)
  25. tsk = current;
  26. if (regs) {
  27. frame.fp = regs->regs[29];
  28. frame.sp = regs->sp;
  29. frame.pc = regs->pc;
  30. } else if (tsk == current) {
  31. frame.fp = (unsigned long)__builtin_frame_address(0);
  32. frame.sp = current_sp;
  33. frame.pc = (unsigned long)aee_dump_backtrace;
  34. } else {
  35. /*
  36. * task blocked in __switch_to
  37. */
  38. frame.fp = thread_saved_fp(tsk);
  39. frame.sp = thread_saved_sp(tsk);
  40. frame.pc = thread_saved_pc(tsk);
  41. }
  42. aee_sram_fiq_log("Call trace:\n");
  43. while (1) {
  44. unsigned long where = frame.pc;
  45. int ret;
  46. ret = unwind_frame(&frame);
  47. if (ret < 0)
  48. break;
  49. dump_backtrace_entry(where, frame.sp);
  50. }
  51. }