define_trace.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * Trace files that want to automate creation of all tracepoints defined
  4. * in their file should include this file. The following are macros that the
  5. * trace file may define:
  6. *
  7. * TRACE_SYSTEM defines the system the tracepoint is for
  8. *
  9. * TRACE_INCLUDE_FILE if the file name is something other than TRACE_SYSTEM.h
  10. * This macro may be defined to tell define_trace.h what file to include.
  11. * Note, leave off the ".h".
  12. *
  13. * TRACE_INCLUDE_PATH if the path is something other than core kernel include/trace
  14. * then this macro can define the path to use. Note, the path is relative to
  15. * define_trace.h, not the file including it. Full path names for out of tree
  16. * modules must be used.
  17. */
  18. #ifdef CREATE_TRACE_POINTS
  19. /* Prevent recursion */
  20. #undef CREATE_TRACE_POINTS
  21. #include <linux/stringify.h>
  22. #undef TRACE_EVENT
  23. #define TRACE_EVENT(name, proto, args, tstruct, assign, print) \
  24. DEFINE_TRACE(name, PARAMS(proto), PARAMS(args))
  25. #undef TRACE_EVENT_CONDITION
  26. #define TRACE_EVENT_CONDITION(name, proto, args, cond, tstruct, assign, print) \
  27. TRACE_EVENT(name, \
  28. PARAMS(proto), \
  29. PARAMS(args), \
  30. PARAMS(tstruct), \
  31. PARAMS(assign), \
  32. PARAMS(print))
  33. #undef TRACE_EVENT_FN
  34. #define TRACE_EVENT_FN(name, proto, args, tstruct, \
  35. assign, print, reg, unreg) \
  36. DEFINE_TRACE_FN(name, reg, unreg, PARAMS(proto), PARAMS(args))
  37. #undef TRACE_EVENT_FN_COND
  38. #define TRACE_EVENT_FN_COND(name, proto, args, cond, tstruct, \
  39. assign, print, reg, unreg) \
  40. DEFINE_TRACE_FN(name, reg, unreg, PARAMS(proto), PARAMS(args))
  41. #undef TRACE_EVENT_NOP
  42. #define TRACE_EVENT_NOP(name, proto, args, struct, assign, print)
  43. #undef DEFINE_EVENT_NOP
  44. #define DEFINE_EVENT_NOP(template, name, proto, args)
  45. #undef DEFINE_EVENT
  46. #define DEFINE_EVENT(template, name, proto, args) \
  47. DEFINE_TRACE(name, PARAMS(proto), PARAMS(args))
  48. #undef DEFINE_EVENT_FN
  49. #define DEFINE_EVENT_FN(template, name, proto, args, reg, unreg) \
  50. DEFINE_TRACE_FN(name, reg, unreg, PARAMS(proto), PARAMS(args))
  51. #undef DEFINE_EVENT_PRINT
  52. #define DEFINE_EVENT_PRINT(template, name, proto, args, print) \
  53. DEFINE_TRACE(name, PARAMS(proto), PARAMS(args))
  54. #undef DEFINE_EVENT_CONDITION
  55. #define DEFINE_EVENT_CONDITION(template, name, proto, args, cond) \
  56. DEFINE_EVENT(template, name, PARAMS(proto), PARAMS(args))
  57. #undef DECLARE_TRACE
  58. #define DECLARE_TRACE(name, proto, args) \
  59. DEFINE_TRACE(name, PARAMS(proto), PARAMS(args))
  60. #undef TRACE_INCLUDE
  61. #undef __TRACE_INCLUDE
  62. #ifndef TRACE_INCLUDE_FILE
  63. # define TRACE_INCLUDE_FILE TRACE_SYSTEM
  64. # define UNDEF_TRACE_INCLUDE_FILE
  65. #endif
  66. #ifndef TRACE_INCLUDE_PATH
  67. # define __TRACE_INCLUDE(system) <trace/events/system.h>
  68. # define UNDEF_TRACE_INCLUDE_PATH
  69. #else
  70. # define __TRACE_INCLUDE(system) __stringify(TRACE_INCLUDE_PATH/system.h)
  71. #endif
  72. # define TRACE_INCLUDE(system) __TRACE_INCLUDE(system)
  73. /* Let the trace headers be reread */
  74. #define TRACE_HEADER_MULTI_READ
  75. #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
  76. /* Make all open coded DECLARE_TRACE nops */
  77. #undef DECLARE_TRACE
  78. #define DECLARE_TRACE(name, proto, args)
  79. #ifdef TRACEPOINTS_ENABLED
  80. #include <trace/trace_events.h>
  81. #include <trace/perf.h>
  82. #include <trace/bpf_probe.h>
  83. #endif
  84. #undef TRACE_EVENT
  85. #undef TRACE_EVENT_FN
  86. #undef TRACE_EVENT_FN_COND
  87. #undef TRACE_EVENT_CONDITION
  88. #undef TRACE_EVENT_NOP
  89. #undef DEFINE_EVENT_NOP
  90. #undef DECLARE_EVENT_CLASS
  91. #undef DEFINE_EVENT
  92. #undef DEFINE_EVENT_FN
  93. #undef DEFINE_EVENT_PRINT
  94. #undef DEFINE_EVENT_CONDITION
  95. #undef TRACE_HEADER_MULTI_READ
  96. #undef DECLARE_TRACE
  97. /* Only undef what we defined in this file */
  98. #ifdef UNDEF_TRACE_INCLUDE_FILE
  99. # undef TRACE_INCLUDE_FILE
  100. # undef UNDEF_TRACE_INCLUDE_FILE
  101. #endif
  102. #ifdef UNDEF_TRACE_INCLUDE_PATH
  103. # undef TRACE_INCLUDE_PATH
  104. # undef UNDEF_TRACE_INCLUDE_PATH
  105. #endif
  106. /* We may be processing more files */
  107. #define CREATE_TRACE_POINTS
  108. #endif /* CREATE_TRACE_POINTS */