ftrace.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. #ifndef _LINUX_FTRACE_H
  2. #define _LINUX_FTRACE_H
  3. #ifdef CONFIG_FTRACE
  4. #include <linux/linkage.h>
  5. extern int ftrace_enabled;
  6. extern int
  7. ftrace_enable_sysctl(struct ctl_table *table, int write,
  8. struct file *filp, void __user *buffer, size_t *lenp,
  9. loff_t *ppos);
  10. typedef void (*ftrace_func_t)(unsigned long ip, unsigned long parent_ip);
  11. struct ftrace_ops {
  12. ftrace_func_t func;
  13. struct ftrace_ops *next;
  14. };
  15. /*
  16. * The ftrace_ops must be a static and should also
  17. * be read_mostly. These functions do modify read_mostly variables
  18. * so use them sparely. Never free an ftrace_op or modify the
  19. * next pointer after it has been registered. Even after unregistering
  20. * it, the next pointer may still be used internally.
  21. */
  22. int register_ftrace_function(struct ftrace_ops *ops);
  23. int unregister_ftrace_function(struct ftrace_ops *ops);
  24. void clear_ftrace_function(void);
  25. extern void ftrace_stub(unsigned long a0, unsigned long a1);
  26. extern void mcount(void);
  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. };
  41. struct dyn_ftrace {
  42. struct hlist_node node;
  43. unsigned long ip;
  44. unsigned long flags;
  45. };
  46. int ftrace_force_update(void);
  47. void ftrace_set_filter(unsigned char *buf, int len, int reset);
  48. /* defined in arch */
  49. extern int ftrace_ip_converted(unsigned long ip);
  50. extern unsigned char *ftrace_nop_replace(void);
  51. extern unsigned char *ftrace_call_replace(unsigned long ip, unsigned long addr);
  52. extern int ftrace_dyn_arch_init(void *data);
  53. extern int ftrace_mcount_set(unsigned long *data);
  54. extern int ftrace_modify_code(unsigned long ip, unsigned char *old_code,
  55. unsigned char *new_code);
  56. extern int ftrace_update_ftrace_func(ftrace_func_t func);
  57. extern void ftrace_caller(void);
  58. extern void ftrace_call(void);
  59. extern void mcount_call(void);
  60. #else
  61. # define ftrace_force_update() ({ 0; })
  62. # define ftrace_set_filter(buf, len, reset) do { } while (0)
  63. #endif
  64. static inline void tracer_disable(void)
  65. {
  66. #ifdef CONFIG_FTRACE
  67. ftrace_enabled = 0;
  68. #endif
  69. }
  70. #ifdef CONFIG_FRAME_POINTER
  71. /* TODO: need to fix this for ARM */
  72. # define CALLER_ADDR0 ((unsigned long)__builtin_return_address(0))
  73. # define CALLER_ADDR1 ((unsigned long)__builtin_return_address(1))
  74. # define CALLER_ADDR2 ((unsigned long)__builtin_return_address(2))
  75. # define CALLER_ADDR3 ((unsigned long)__builtin_return_address(3))
  76. # define CALLER_ADDR4 ((unsigned long)__builtin_return_address(4))
  77. # define CALLER_ADDR5 ((unsigned long)__builtin_return_address(5))
  78. #else
  79. # define CALLER_ADDR0 ((unsigned long)__builtin_return_address(0))
  80. # define CALLER_ADDR1 0UL
  81. # define CALLER_ADDR2 0UL
  82. # define CALLER_ADDR3 0UL
  83. # define CALLER_ADDR4 0UL
  84. # define CALLER_ADDR5 0UL
  85. #endif
  86. #ifdef CONFIG_IRQSOFF_TRACER
  87. extern void notrace time_hardirqs_on(unsigned long a0, unsigned long a1);
  88. extern void notrace time_hardirqs_off(unsigned long a0, unsigned long a1);
  89. #else
  90. # define time_hardirqs_on(a0, a1) do { } while (0)
  91. # define time_hardirqs_off(a0, a1) do { } while (0)
  92. #endif
  93. #ifdef CONFIG_PREEMPT_TRACER
  94. extern void notrace trace_preempt_on(unsigned long a0, unsigned long a1);
  95. extern void notrace trace_preempt_off(unsigned long a0, unsigned long a1);
  96. #else
  97. # define trace_preempt_on(a0, a1) do { } while (0)
  98. # define trace_preempt_off(a0, a1) do { } while (0)
  99. #endif
  100. #endif /* _LINUX_FTRACE_H */