mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-10-31 16:38:12 +00:00
df8ff35311
Move BPF_PROG, BPF_KPROBE, and BPF_KRETPROBE macro into libbpf's bpf_tracing.h header to make it available for non-selftests users. Signed-off-by: Andrii Nakryiko <andriin@fb.com> Signed-off-by: Alexei Starovoitov <ast@kernel.org> Link: https://lore.kernel.org/bpf/20200229231112.1240137-5-andriin@fb.com
42 lines
713 B
C
42 lines
713 B
C
// SPDX-License-Identifier: GPL-2.0
|
|
// Copyright (c) 2017 Facebook
|
|
|
|
#include <linux/ptrace.h>
|
|
#include <linux/bpf.h>
|
|
#include <bpf/bpf_helpers.h>
|
|
#include <bpf/bpf_tracing.h>
|
|
|
|
int kprobe_res = 0;
|
|
int kretprobe_res = 0;
|
|
int uprobe_res = 0;
|
|
int uretprobe_res = 0;
|
|
|
|
SEC("kprobe/sys_nanosleep")
|
|
int handle_kprobe(struct pt_regs *ctx)
|
|
{
|
|
kprobe_res = 1;
|
|
return 0;
|
|
}
|
|
|
|
SEC("kretprobe/sys_nanosleep")
|
|
int BPF_KRETPROBE(handle_kretprobe)
|
|
{
|
|
kretprobe_res = 2;
|
|
return 0;
|
|
}
|
|
|
|
SEC("uprobe/trigger_func")
|
|
int handle_uprobe(struct pt_regs *ctx)
|
|
{
|
|
uprobe_res = 3;
|
|
return 0;
|
|
}
|
|
|
|
SEC("uretprobe/trigger_func")
|
|
int handle_uretprobe(struct pt_regs *ctx)
|
|
{
|
|
uretprobe_res = 4;
|
|
return 0;
|
|
}
|
|
|
|
char _license[] SEC("license") = "GPL";
|