ftrace.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. #ifndef _LINUX_FTRACE_H
  2. #define _LINUX_FTRACE_H
  3. #ifdef CONFIG_FTRACE
  4. #include <linux/linkage.h>
  5. #include <linux/fs.h>
  6. extern int ftrace_enabled;
  7. extern int
  8. ftrace_enable_sysctl(struct ctl_table *table, int write,
  9. struct file *filp, void __user *buffer, size_t *lenp,
  10. loff_t *ppos);
  11. typedef void (*ftrace_func_t)(unsigned long ip, unsigned long parent_ip);
  12. struct ftrace_ops {
  13. ftrace_func_t func;
  14. struct ftrace_ops *next;
  15. };
  16. /*
  17. * The ftrace_ops must be a static and should also
  18. * be read_mostly. These functions do modify read_mostly variables
  19. * so use them sparely. Never free an ftrace_op or modify the
  20. * next pointer after it has been registered. Even after unregistering
  21. * it, the next pointer may still be used internally.
  22. */
  23. int register_ftrace_function(struct ftrace_ops *ops);
  24. int unregister_ftrace_function(struct ftrace_ops *ops);
  25. void clear_ftrace_function(void);
  26. extern void ftrace_stub(unsigned long a0, unsigned long a1);
  27. #else /* !CONFIG_FTRACE */
  28. # define register_ftrace_function(ops) do { } while (0)
  29. # define unregister_ftrace_function(ops) do { } while (0)
  30. # define clear_ftrace_function(ops) do { } while (0)
  31. #endif /* CONFIG_FTRACE */
  32. #ifdef CONFIG_DYNAMIC_FTRACE
  33. # define FTRACE_HASHBITS 10
  34. # define FTRACE_HASHSIZE (1<<FTRACE_HASHBITS)
  35. enum {
  36. FTRACE_FL_FREE = (1 << 0),
  37. FTRACE_FL_FAILED = (1 << 1),
  38. FTRACE_FL_FILTER = (1 << 2),
  39. FTRACE_FL_ENABLED = (1 << 3),
  40. FTRACE_FL_NOTRACE = (1 << 4),
  41. FTRACE_FL_CONVERTED = (1 << 5),
  42. FTRACE_FL_FROZEN = (1 << 6),
  43. };
  44. struct dyn_ftrace {
  45. struct hlist_node node;
  46. unsigned long ip; /* address of mcount call-site */
  47. unsigned long flags;
  48. };
  49. int ftrace_force_update(void);
  50. void ftrace_set_filter(unsigned char *buf, int len, int reset);
  51. /* defined in arch */
  52. extern int ftrace_ip_converted(unsigned long ip);
  53. extern unsigned char *ftrace_nop_replace(void);
  54. extern unsigned char *ftrace_call_replace(unsigned long ip, unsigned long addr);
  55. extern int ftrace_dyn_arch_init(void *data);
  56. extern int ftrace_mcount_set(unsigned long *data);
  57. extern int ftrace_modify_code(unsigned long ip, unsigned char *old_code,
  58. unsigned char *new_code);
  59. extern int ftrace_update_ftrace_func(ftrace_func_t func);
  60. extern void ftrace_caller(void);
  61. extern void ftrace_call(void);
  62. extern void mcount_call(void);
  63. extern int skip_trace(unsigned long ip);
  64. void ftrace_disable_daemon(void);
  65. void ftrace_enable_daemon(void);
  66. #else
  67. # define skip_trace(ip) ({ 0; })
  68. # define ftrace_force_update() ({ 0; })
  69. # define ftrace_set_filter(buf, len, reset) do { } while (0)
  70. # define ftrace_disable_daemon() do { } while (0)
  71. # define ftrace_enable_daemon() do { } while (0)
  72. #endif /* CONFIG_DYNAMIC_FTRACE */
  73. /* totally disable ftrace - can not re-enable after this */
  74. void ftrace_kill(void);
  75. static inline void tracer_disable(void)
  76. {
  77. #ifdef CONFIG_FTRACE
  78. ftrace_enabled = 0;
  79. #endif
  80. }
  81. #ifdef CONFIG_FRAME_POINTER
  82. /* TODO: need to fix this for ARM */
  83. # define CALLER_ADDR0 ((unsigned long)__builtin_return_address(0))
  84. # define CALLER_ADDR1 ((unsigned long)__builtin_return_address(1))
  85. # define CALLER_ADDR2 ((unsigned long)__builtin_return_address(2))
  86. # define CALLER_ADDR3 ((unsigned long)__builtin_return_address(3))
  87. # define CALLER_ADDR4 ((unsigned long)__builtin_return_address(4))
  88. # define CALLER_ADDR5 ((unsigned long)__builtin_return_address(5))
  89. # define CALLER_ADDR6 ((unsigned long)__builtin_return_address(6))
  90. #else
  91. # define CALLER_ADDR0 ((unsigned long)__builtin_return_address(0))
  92. # define CALLER_ADDR1 0UL
  93. # define CALLER_ADDR2 0UL
  94. # define CALLER_ADDR3 0UL
  95. # define CALLER_ADDR4 0UL
  96. # define CALLER_ADDR5 0UL
  97. # define CALLER_ADDR6 0UL
  98. #endif
  99. #ifdef CONFIG_IRQSOFF_TRACER
  100. extern void time_hardirqs_on(unsigned long a0, unsigned long a1);
  101. extern void time_hardirqs_off(unsigned long a0, unsigned long a1);
  102. #else
  103. # define time_hardirqs_on(a0, a1) do { } while (0)
  104. # define time_hardirqs_off(a0, a1) do { } while (0)
  105. #endif
  106. #ifdef CONFIG_PREEMPT_TRACER
  107. extern void trace_preempt_on(unsigned long a0, unsigned long a1);
  108. extern void trace_preempt_off(unsigned long a0, unsigned long a1);
  109. #else
  110. # define trace_preempt_on(a0, a1) do { } while (0)
  111. # define trace_preempt_off(a0, a1) do { } while (0)
  112. #endif
  113. #ifdef CONFIG_TRACING
  114. extern void
  115. ftrace_special(unsigned long arg1, unsigned long arg2, unsigned long arg3);
  116. #else
  117. static inline void
  118. ftrace_special(unsigned long arg1, unsigned long arg2, unsigned long arg3) { }
  119. #endif
  120. #endif /* _LINUX_FTRACE_H */