aboutsummaryrefslogtreecommitdiffstats
path: root/tools/testing/selftests/bpf/bpf_testmod/bpf_testmod-events.h
blob: 11ee801e75e7e048d6c1ea8e3dd4d252f274c35b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/* SPDX-License-Identifier: GPL-2.0 */
/* Copyright (c) 2020 Facebook */
#undef TRACE_SYSTEM
#define TRACE_SYSTEM bpf_testmod

#if !defined(_BPF_TESTMOD_EVENTS_H) || defined(TRACE_HEADER_MULTI_READ)
#define _BPF_TESTMOD_EVENTS_H

#include <linux/tracepoint.h>
#include "bpf_testmod.h"

TRACE_EVENT(bpf_testmod_test_read,
	TP_PROTO(struct task_struct *task, struct bpf_testmod_test_read_ctx *ctx),
	TP_ARGS(task, ctx),
	TP_STRUCT__entry(
		__field(pid_t, pid)
		__array(char, comm, TASK_COMM_LEN)
		__field(loff_t, off)
		__field(size_t, len)
	),
	TP_fast_assign(
		__entry->pid = task->pid;
		memcpy(__entry->comm, task->comm, TASK_COMM_LEN);
		__entry->off = ctx->off;
		__entry->len = ctx->len;
	),
	TP_printk("pid=%d comm=%s off=%llu len=%zu",
		  __entry->pid, __entry->comm, __entry->off, __entry->len)
);

/* A bare tracepoint with no event associated with it */
DECLARE_TRACE(bpf_testmod_test_write_bare,
	TP_PROTO(struct task_struct *task, struct bpf_testmod_test_write_ctx *ctx),
	TP_ARGS(task, ctx)
);

#undef BPF_TESTMOD_DECLARE_TRACE
#ifdef DECLARE_TRACE_WRITABLE
#define BPF_TESTMOD_DECLARE_TRACE(call, proto, args, size) \
	DECLARE_TRACE_WRITABLE(call, PARAMS(proto), PARAMS(args), size)
#else
#define BPF_TESTMOD_DECLARE_TRACE(call, proto, args, size) \
	DECLARE_TRACE(call, PARAMS(proto), PARAMS(args))
#endif

BPF_TESTMOD_DECLARE_TRACE(bpf_testmod_test_writable_bare,
	TP_PROTO(struct bpf_testmod_test_writable_ctx *ctx),
	TP_ARGS(ctx),
	sizeof(struct bpf_testmod_test_writable_ctx)
);

#endif /* _BPF_TESTMOD_EVENTS_H */

#undef TRACE_INCLUDE_PATH
#define TRACE_INCLUDE_PATH .
#define TRACE_INCLUDE_FILE bpf_testmod-events
#include <trace/define_trace.h>