Files
linux/tools/testing/selftests/bpf/progs/uprobe_syscall_executed.c
Jiri Olsa d5c86c3370 selftests/bpf: Add uprobe/usdt syscall tests
Adding tests for optimized uprobe/usdt probes.

Checking that we get expected trampoline and attached bpf programs
get executed properly.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Acked-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/r/20250720112133.244369-15-jolsa@kernel.org
2025-08-21 20:09:24 +02:00

74 lines
1.1 KiB
C

// SPDX-License-Identifier: GPL-2.0
#include "vmlinux.h"
#include <bpf/bpf_helpers.h>
#include <bpf/bpf_tracing.h>
#include <bpf/usdt.bpf.h>
#include <string.h>
struct pt_regs regs;
char _license[] SEC("license") = "GPL";
int executed = 0;
int pid;
SEC("uprobe")
int BPF_UPROBE(test_uprobe)
{
if (bpf_get_current_pid_tgid() >> 32 != pid)
return 0;
executed++;
return 0;
}
SEC("uretprobe")
int BPF_URETPROBE(test_uretprobe)
{
if (bpf_get_current_pid_tgid() >> 32 != pid)
return 0;
executed++;
return 0;
}
SEC("uprobe.multi")
int test_uprobe_multi(struct pt_regs *ctx)
{
if (bpf_get_current_pid_tgid() >> 32 != pid)
return 0;
executed++;
return 0;
}
SEC("uretprobe.multi")
int test_uretprobe_multi(struct pt_regs *ctx)
{
if (bpf_get_current_pid_tgid() >> 32 != pid)
return 0;
executed++;
return 0;
}
SEC("uprobe.session")
int test_uprobe_session(struct pt_regs *ctx)
{
if (bpf_get_current_pid_tgid() >> 32 != pid)
return 0;
executed++;
return 0;
}
SEC("usdt")
int test_usdt(struct pt_regs *ctx)
{
if (bpf_get_current_pid_tgid() >> 32 != pid)
return 0;
executed++;
return 0;
}