define_custom_trace.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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_CUSTOM_TRACE_EVENTS
  19. /* Prevent recursion */
  20. #undef CREATE_CUSTOM_TRACE_EVENTS
  21. #include <linux/stringify.h>
  22. #undef TRACE_CUSTOM_EVENT
  23. #define TRACE_CUSTOM_EVENT(name, proto, args, tstruct, assign, print)
  24. #undef DEFINE_CUSTOM_EVENT
  25. #define DEFINE_CUSTOM_EVENT(template, name, proto, args)
  26. #undef TRACE_INCLUDE
  27. #undef __TRACE_INCLUDE
  28. #ifndef TRACE_INCLUDE_FILE
  29. # define TRACE_INCLUDE_FILE TRACE_SYSTEM
  30. # define UNDEF_TRACE_INCLUDE_FILE
  31. #endif
  32. #ifndef TRACE_INCLUDE_PATH
  33. # define __TRACE_INCLUDE(system) <trace/events/system.h>
  34. # define UNDEF_TRACE_INCLUDE_PATH
  35. #else
  36. # define __TRACE_INCLUDE(system) __stringify(TRACE_INCLUDE_PATH/system.h)
  37. #endif
  38. # define TRACE_INCLUDE(system) __TRACE_INCLUDE(system)
  39. /* Let the trace headers be reread */
  40. #define TRACE_CUSTOM_MULTI_READ
  41. #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
  42. #ifdef TRACEPOINTS_ENABLED
  43. #include <trace/trace_custom_events.h>
  44. #endif
  45. #undef TRACE_CUSTOM_EVENT
  46. #undef DECLARE_CUSTOM_EVENT_CLASS
  47. #undef DEFINE_CUSTOM_EVENT
  48. #undef TRACE_CUSTOM_MULTI_READ
  49. /* Only undef what we defined in this file */
  50. #ifdef UNDEF_TRACE_INCLUDE_FILE
  51. # undef TRACE_INCLUDE_FILE
  52. # undef UNDEF_TRACE_INCLUDE_FILE
  53. #endif
  54. #ifdef UNDEF_TRACE_INCLUDE_PATH
  55. # undef TRACE_INCLUDE_PATH
  56. # undef UNDEF_TRACE_INCLUDE_PATH
  57. #endif
  58. /* We may be processing more files */
  59. #define CREATE_CUSTOM_TRACE_POINTS
  60. #endif /* CREATE_CUSTOM_TRACE_POINTS */