trace_events.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #ifndef _LINUX_KERNEL_TRACE_EVENTS_H
  2. #define _LINUX_KERNEL_TRACE_EVENTS_H
  3. #include <linux/debugfs.h>
  4. #include <linux/ftrace.h>
  5. #include "trace.h"
  6. struct ftrace_event_call {
  7. char *name;
  8. struct dentry *dir;
  9. int enabled;
  10. int (*regfunc)(void);
  11. void (*unregfunc)(void);
  12. };
  13. #undef TPFMT
  14. #define TPFMT(fmt, args...) fmt "\n", ##args
  15. #undef DEFINE_TRACE_FMT
  16. #define DEFINE_TRACE_FMT(call, proto, args, fmt) \
  17. static void ftrace_event_##call(proto) \
  18. { \
  19. event_trace_printk(_RET_IP_, "(" #call ") " fmt); \
  20. } \
  21. \
  22. static int ftrace_reg_event_##call(void) \
  23. { \
  24. int ret; \
  25. \
  26. ret = register_trace_##call(ftrace_event_##call); \
  27. if (!ret) \
  28. pr_info("event trace: Could not activate trace point " \
  29. "probe to " #call); \
  30. return ret; \
  31. } \
  32. \
  33. static void ftrace_unreg_event_##call(void) \
  34. { \
  35. unregister_trace_##call(ftrace_event_##call); \
  36. } \
  37. \
  38. static struct ftrace_event_call __used \
  39. __attribute__((__aligned__(4))) \
  40. __attribute__((section("_ftrace_events"))) event_##call = { \
  41. .name = #call, \
  42. .regfunc = ftrace_reg_event_##call, \
  43. .unregfunc = ftrace_unreg_event_##call, \
  44. }
  45. void event_trace_printk(unsigned long ip, const char *fmt, ...);
  46. extern struct ftrace_event_call __start_ftrace_events[];
  47. extern struct ftrace_event_call __stop_ftrace_events[];
  48. #endif /* _LINUX_KERNEL_TRACE_EVENTS_H */