ftrace.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. #ifndef __ASM_SH_FTRACE_H
  2. #define __ASM_SH_FTRACE_H
  3. #ifdef CONFIG_FUNCTION_TRACER
  4. #define MCOUNT_INSN_SIZE 4 /* sizeof mcount call */
  5. #define FTRACE_SYSCALL_MAX NR_syscalls
  6. #ifndef __ASSEMBLY__
  7. extern void mcount(void);
  8. #define MCOUNT_ADDR ((long)(mcount))
  9. #ifdef CONFIG_DYNAMIC_FTRACE
  10. #define CALL_ADDR ((long)(ftrace_call))
  11. #define STUB_ADDR ((long)(ftrace_stub))
  12. #define GRAPH_ADDR ((long)(ftrace_graph_call))
  13. #define CALLER_ADDR ((long)(ftrace_caller))
  14. #define MCOUNT_INSN_OFFSET ((STUB_ADDR - CALL_ADDR) - 4)
  15. #define GRAPH_INSN_OFFSET ((CALLER_ADDR - GRAPH_ADDR) - 4)
  16. struct dyn_arch_ftrace {
  17. /* No extra data needed on sh */
  18. };
  19. #endif /* CONFIG_DYNAMIC_FTRACE */
  20. static inline unsigned long ftrace_call_adjust(unsigned long addr)
  21. {
  22. /* 'addr' is the memory table address. */
  23. return addr;
  24. }
  25. #ifdef CONFIG_DWARF_UNWINDER
  26. #include <asm/dwarf.h>
  27. #define HAVE_ARCH_CALLER_ADDR
  28. static inline unsigned long dwarf_return_address(int depth)
  29. {
  30. struct dwarf_frame *frame;
  31. unsigned long ra;
  32. int i;
  33. for (i = 0, frame = NULL, ra = 0; i <= depth; i++) {
  34. struct dwarf_frame *tmp;
  35. tmp = dwarf_unwind_stack(ra, frame);
  36. if (frame)
  37. dwarf_free_frame(frame);
  38. frame = tmp;
  39. if (!frame || !frame->return_addr)
  40. break;
  41. ra = frame->return_addr;
  42. }
  43. /* Failed to unwind the stack to the specified depth. */
  44. WARN_ON(i != depth + 1);
  45. if (frame)
  46. dwarf_free_frame(frame);
  47. return ra;
  48. }
  49. #define CALLER_ADDR0 ((unsigned long)__builtin_return_address(0))
  50. #define CALLER_ADDR1 dwarf_return_address(1)
  51. #define CALLER_ADDR2 dwarf_return_address(2)
  52. #define CALLER_ADDR3 dwarf_return_address(3)
  53. #define CALLER_ADDR4 dwarf_return_address(4)
  54. #define CALLER_ADDR5 dwarf_return_address(5)
  55. #define CALLER_ADDR6 dwarf_return_address(6)
  56. #endif /* CONFIG_DWARF_UNWINDER */
  57. #endif /* __ASSEMBLY__ */
  58. #endif /* CONFIG_FUNCTION_TRACER */
  59. #endif /* __ASM_SH_FTRACE_H */