xref: /linux/tools/testing/selftests/bpf/progs/uprobe_syscall_executed.c (revision 07fdad3a93756b872da7b53647715c48d0f4a2d0)
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 
8 struct pt_regs regs;
9 
10 char _license[] SEC("license") = "GPL";
11 
12 int executed = 0;
13 int pid;
14 
15 SEC("uprobe")
16 int 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 
25 SEC("uretprobe")
26 int 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 
35 SEC("uprobe.multi")
36 int 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 
45 SEC("uretprobe.multi")
46 int 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 
55 SEC("uprobe.session")
56 int 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 
65 SEC("usdt")
66 int 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 }
74