bpf_test_run.h 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #undef TRACE_SYSTEM
  3. #define TRACE_SYSTEM bpf_test_run
  4. #if !defined(_TRACE_BPF_TEST_RUN_H) || defined(TRACE_HEADER_MULTI_READ)
  5. #define _TRACE_BPF_TEST_RUN_H
  6. #include <linux/tracepoint.h>
  7. TRACE_EVENT(bpf_trigger_tp,
  8. TP_PROTO(int nonce),
  9. TP_ARGS(nonce),
  10. TP_STRUCT__entry(
  11. __field(int, nonce)
  12. ),
  13. TP_fast_assign(
  14. __entry->nonce = nonce;
  15. ),
  16. TP_printk("nonce %d", __entry->nonce)
  17. );
  18. DECLARE_EVENT_CLASS(bpf_test_finish,
  19. TP_PROTO(int *err),
  20. TP_ARGS(err),
  21. TP_STRUCT__entry(
  22. __field(int, err)
  23. ),
  24. TP_fast_assign(
  25. __entry->err = *err;
  26. ),
  27. TP_printk("bpf_test_finish with err=%d", __entry->err)
  28. );
  29. #ifdef DEFINE_EVENT_WRITABLE
  30. #undef BPF_TEST_RUN_DEFINE_EVENT
  31. #define BPF_TEST_RUN_DEFINE_EVENT(template, call, proto, args, size) \
  32. DEFINE_EVENT_WRITABLE(template, call, PARAMS(proto), \
  33. PARAMS(args), size)
  34. #else
  35. #undef BPF_TEST_RUN_DEFINE_EVENT
  36. #define BPF_TEST_RUN_DEFINE_EVENT(template, call, proto, args, size) \
  37. DEFINE_EVENT(template, call, PARAMS(proto), PARAMS(args))
  38. #endif
  39. BPF_TEST_RUN_DEFINE_EVENT(bpf_test_finish, bpf_test_finish,
  40. TP_PROTO(int *err),
  41. TP_ARGS(err),
  42. sizeof(int)
  43. );
  44. #endif
  45. /* This part must be outside protection */
  46. #include <trace/define_trace.h>