bpf_testmod-events.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /* Copyright (c) 2020 Facebook */
  3. #undef TRACE_SYSTEM
  4. #define TRACE_SYSTEM bpf_testmod
  5. #if !defined(_BPF_TESTMOD_EVENTS_H) || defined(TRACE_HEADER_MULTI_READ)
  6. #define _BPF_TESTMOD_EVENTS_H
  7. #include <linux/tracepoint.h>
  8. #include "bpf_testmod.h"
  9. TRACE_EVENT(bpf_testmod_test_read,
  10. TP_PROTO(struct task_struct *task, struct bpf_testmod_test_read_ctx *ctx),
  11. TP_ARGS(task, ctx),
  12. TP_STRUCT__entry(
  13. __field(pid_t, pid)
  14. __array(char, comm, TASK_COMM_LEN)
  15. __field(loff_t, off)
  16. __field(size_t, len)
  17. ),
  18. TP_fast_assign(
  19. __entry->pid = task->pid;
  20. memcpy(__entry->comm, task->comm, TASK_COMM_LEN);
  21. __entry->off = ctx->off;
  22. __entry->len = ctx->len;
  23. ),
  24. TP_printk("pid=%d comm=%s off=%llu len=%zu",
  25. __entry->pid, __entry->comm, __entry->off, __entry->len)
  26. );
  27. /* A bare tracepoint with no event associated with it */
  28. DECLARE_TRACE(bpf_testmod_test_write_bare,
  29. TP_PROTO(struct task_struct *task, struct bpf_testmod_test_write_ctx *ctx),
  30. TP_ARGS(task, ctx)
  31. );
  32. /* Used in bpf_testmod_test_read() to test __nullable suffix */
  33. DECLARE_TRACE(bpf_testmod_test_nullable_bare,
  34. TP_PROTO(struct bpf_testmod_test_read_ctx *ctx__nullable),
  35. TP_ARGS(ctx__nullable)
  36. );
  37. struct sk_buff;
  38. DECLARE_TRACE(bpf_testmod_test_raw_tp_null,
  39. TP_PROTO(struct sk_buff *skb),
  40. TP_ARGS(skb)
  41. );
  42. #undef BPF_TESTMOD_DECLARE_TRACE
  43. #ifdef DECLARE_TRACE_WRITABLE
  44. #define BPF_TESTMOD_DECLARE_TRACE(call, proto, args, size) \
  45. DECLARE_TRACE_WRITABLE(call, PARAMS(proto), PARAMS(args), size)
  46. #else
  47. #define BPF_TESTMOD_DECLARE_TRACE(call, proto, args, size) \
  48. DECLARE_TRACE(call, PARAMS(proto), PARAMS(args))
  49. #endif
  50. BPF_TESTMOD_DECLARE_TRACE(bpf_testmod_test_writable_bare,
  51. TP_PROTO(struct bpf_testmod_test_writable_ctx *ctx),
  52. TP_ARGS(ctx),
  53. sizeof(struct bpf_testmod_test_writable_ctx)
  54. );
  55. #endif /* _BPF_TESTMOD_EVENTS_H */
  56. #undef TRACE_INCLUDE_PATH
  57. #define TRACE_INCLUDE_PATH .
  58. #define TRACE_INCLUDE_FILE bpf_testmod-events
  59. #include <trace/define_trace.h>