backtrace.c 619 B

12345678910111213141516171819202122232425262728
  1. /**
  2. * @file backtrace.c
  3. *
  4. * @remark Copyright 2008 Tensilica Inc.
  5. * Copyright (C) 2015 Cadence Design Systems Inc.
  6. * @remark Read the file COPYING
  7. *
  8. */
  9. #include <linux/oprofile.h>
  10. #include <asm/ptrace.h>
  11. #include <asm/stacktrace.h>
  12. static int xtensa_backtrace_cb(struct stackframe *frame, void *data)
  13. {
  14. oprofile_add_trace(frame->pc);
  15. return 0;
  16. }
  17. void xtensa_backtrace(struct pt_regs * const regs, unsigned int depth)
  18. {
  19. if (user_mode(regs))
  20. xtensa_backtrace_user(regs, depth, xtensa_backtrace_cb, NULL);
  21. else
  22. xtensa_backtrace_kernel(regs, depth, xtensa_backtrace_cb,
  23. xtensa_backtrace_cb, NULL);
  24. }