Linux kernel mirror (for testing)
git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel
os
linux
1// SPDX-License-Identifier: GPL-2.0
2#include "vmlinux.h"
3#include <bpf/bpf_helpers.h>
4#include <bpf/bpf_tracing.h>
5#include <bpf/usdt.bpf.h>
6#include <string.h>
7
8struct pt_regs regs;
9
10char _license[] SEC("license") = "GPL";
11
12int executed = 0;
13int pid;
14
15SEC("uprobe")
16int BPF_UPROBE(test_uprobe)
17{
18 if (bpf_get_current_pid_tgid() >> 32 != pid)
19 return 0;
20
21 executed++;
22 return 0;
23}
24
25SEC("uretprobe")
26int BPF_URETPROBE(test_uretprobe)
27{
28 if (bpf_get_current_pid_tgid() >> 32 != pid)
29 return 0;
30
31 executed++;
32 return 0;
33}
34
35SEC("uprobe.multi")
36int test_uprobe_multi(struct pt_regs *ctx)
37{
38 if (bpf_get_current_pid_tgid() >> 32 != pid)
39 return 0;
40
41 executed++;
42 return 0;
43}
44
45SEC("uretprobe.multi")
46int test_uretprobe_multi(struct pt_regs *ctx)
47{
48 if (bpf_get_current_pid_tgid() >> 32 != pid)
49 return 0;
50
51 executed++;
52 return 0;
53}
54
55SEC("uprobe.session")
56int test_uprobe_session(struct pt_regs *ctx)
57{
58 if (bpf_get_current_pid_tgid() >> 32 != pid)
59 return 0;
60
61 executed++;
62 return 0;
63}
64
65SEC("usdt")
66int test_usdt(struct pt_regs *ctx)
67{
68 if (bpf_get_current_pid_tgid() >> 32 != pid)
69 return 0;
70
71 executed++;
72 return 0;
73}