define_trace.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  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)
  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)
  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)
  41. #undef DEFINE_EVENT
  42. #define DEFINE_EVENT(template, name, proto, args) \
  43. DEFINE_TRACE(name)
  44. #undef DEFINE_EVENT_FN
  45. #define DEFINE_EVENT_FN(template, name, proto, args, reg, unreg) \
  46. DEFINE_TRACE_FN(name, reg, unreg)
  47. #undef DEFINE_EVENT_PRINT
  48. #define DEFINE_EVENT_PRINT(template, name, proto, args, print) \
  49. DEFINE_TRACE(name)
  50. #undef DEFINE_EVENT_CONDITION
  51. #define DEFINE_EVENT_CONDITION(template, name, proto, args, cond) \
  52. DEFINE_EVENT(template, name, PARAMS(proto), PARAMS(args))
  53. #undef DECLARE_TRACE
  54. #define DECLARE_TRACE(name, proto, args) \
  55. DEFINE_TRACE(name)
  56. #undef TRACE_INCLUDE
  57. #undef __TRACE_INCLUDE
  58. #ifndef TRACE_INCLUDE_FILE
  59. # define TRACE_INCLUDE_FILE TRACE_SYSTEM
  60. # define UNDEF_TRACE_INCLUDE_FILE
  61. #endif
  62. #ifndef TRACE_INCLUDE_PATH
  63. # define __TRACE_INCLUDE(system) <trace/events/system.h>
  64. # define UNDEF_TRACE_INCLUDE_PATH
  65. #else
  66. # define __TRACE_INCLUDE(system) __stringify(TRACE_INCLUDE_PATH/system.h)
  67. #endif
  68. # define TRACE_INCLUDE(system) __TRACE_INCLUDE(system)
  69. /* Let the trace headers be reread */
  70. #define TRACE_HEADER_MULTI_READ
  71. #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
  72. /* Make all open coded DECLARE_TRACE nops */
  73. #undef DECLARE_TRACE
  74. #define DECLARE_TRACE(name, proto, args)
  75. #ifdef TRACEPOINTS_ENABLED
  76. #include <trace/trace_events.h>
  77. #include <trace/perf.h>
  78. #endif
  79. #undef TRACE_EVENT
  80. #undef TRACE_EVENT_FN
  81. #undef TRACE_EVENT_FN_COND
  82. #undef TRACE_EVENT_CONDITION
  83. #undef DECLARE_EVENT_CLASS
  84. #undef DEFINE_EVENT
  85. #undef DEFINE_EVENT_FN
  86. #undef DEFINE_EVENT_PRINT
  87. #undef DEFINE_EVENT_CONDITION
  88. #undef TRACE_HEADER_MULTI_READ
  89. #undef DECLARE_TRACE
  90. /* Only undef what we defined in this file */
  91. #ifdef UNDEF_TRACE_INCLUDE_FILE
  92. # undef TRACE_INCLUDE_FILE
  93. # undef UNDEF_TRACE_INCLUDE_FILE
  94. #endif
  95. #ifdef UNDEF_TRACE_INCLUDE_PATH
  96. # undef TRACE_INCLUDE_PATH
  97. # undef UNDEF_TRACE_INCLUDE_PATH
  98. #endif
  99. /* We may be processing more files */
  100. #define CREATE_TRACE_POINTS
  101. #endif /* CREATE_TRACE_POINTS */