1 // SPDX-License-Identifier: GPL-2.0
2 /* Copyright (c) 2022 Meta Platforms, Inc. and affiliates. */
5 #include <bpf/bpf_helpers.h>
6 #include <bpf/usdt.bpf.h>
16 int usdt0(struct pt_regs *ctx)
20 if (my_pid != (bpf_get_current_pid_tgid() >> 32))
23 __sync_fetch_and_add(&usdt0_called, 1);
25 usdt0_cookie = bpf_usdt_cookie(ctx);
26 usdt0_arg_cnt = bpf_usdt_arg_cnt(ctx);
27 /* should return -ENOENT for any arg_num */
28 usdt0_arg_ret = bpf_usdt_arg(ctx, bpf_get_prandom_u32(), &tmp);
35 int usdt3_arg_rets[3];
38 SEC("usdt//proc/self/exe:test:usdt3")
39 int usdt3(struct pt_regs *ctx)
43 if (my_pid != (bpf_get_current_pid_tgid() >> 32))
46 __sync_fetch_and_add(&usdt3_called, 1);
48 usdt3_cookie = bpf_usdt_cookie(ctx);
49 usdt3_arg_cnt = bpf_usdt_arg_cnt(ctx);
51 usdt3_arg_rets[0] = bpf_usdt_arg(ctx, 0, &tmp);
52 usdt3_args[0] = (int)tmp;
54 usdt3_arg_rets[1] = bpf_usdt_arg(ctx, 1, &tmp);
55 usdt3_args[1] = (long)tmp;
57 usdt3_arg_rets[2] = bpf_usdt_arg(ctx, 2, &tmp);
58 usdt3_args[2] = (uintptr_t)tmp;
68 SEC("usdt//proc/self/exe:test:usdt12")
69 int BPF_USDT(usdt12, int a1, int a2, long a3, long a4, unsigned a5,
70 long a6, __u64 a7, uintptr_t a8, int a9, short a10,
71 short a11, signed char a12)
73 if (my_pid != (bpf_get_current_pid_tgid() >> 32))
76 __sync_fetch_and_add(&usdt12_called, 1);
78 usdt12_cookie = bpf_usdt_cookie(ctx);
79 usdt12_arg_cnt = bpf_usdt_arg_cnt(ctx);
91 usdt12_args[10] = a11;
92 usdt12_args[11] = a12;
96 char _license[] SEC("license") = "GPL";