1*576d47bbSDaniel Xu // SPDX-License-Identifier: GPL-2.0
2*576d47bbSDaniel Xu 
3*576d47bbSDaniel Xu #include <linux/ptrace.h>
4*576d47bbSDaniel Xu #include <linux/bpf.h>
5*576d47bbSDaniel Xu #include <bpf/bpf_helpers.h>
6*576d47bbSDaniel Xu #include <bpf/bpf_tracing.h>
7*576d47bbSDaniel Xu 
8*576d47bbSDaniel Xu struct pt_regs current_regs = {};
9*576d47bbSDaniel Xu struct pt_regs ctx_regs = {};
10*576d47bbSDaniel Xu int uprobe_res = 0;
11*576d47bbSDaniel Xu 
12*576d47bbSDaniel Xu SEC("uprobe/trigger_func")
13*576d47bbSDaniel Xu int handle_uprobe(struct pt_regs *ctx)
14*576d47bbSDaniel Xu {
15*576d47bbSDaniel Xu 	struct task_struct *current;
16*576d47bbSDaniel Xu 	struct pt_regs *regs;
17*576d47bbSDaniel Xu 
18*576d47bbSDaniel Xu 	current = bpf_get_current_task_btf();
19*576d47bbSDaniel Xu 	regs = (struct pt_regs *) bpf_task_pt_regs(current);
20*576d47bbSDaniel Xu 	__builtin_memcpy(&current_regs, regs, sizeof(*regs));
21*576d47bbSDaniel Xu 	__builtin_memcpy(&ctx_regs, ctx, sizeof(*ctx));
22*576d47bbSDaniel Xu 
23*576d47bbSDaniel Xu 	/* Prove that uprobe was run */
24*576d47bbSDaniel Xu 	uprobe_res = 1;
25*576d47bbSDaniel Xu 
26*576d47bbSDaniel Xu 	return 0;
27*576d47bbSDaniel Xu }
28*576d47bbSDaniel Xu 
29*576d47bbSDaniel Xu char _license[] SEC("license") = "GPL";
30