1*c574bcd6SJiri Olsa // SPDX-License-Identifier: GPL-2.0 2*c574bcd6SJiri Olsa #include <linux/bpf.h> 3*c574bcd6SJiri Olsa #include <bpf/bpf_helpers.h> 4*c574bcd6SJiri Olsa #include <bpf/bpf_tracing.h> 5*c574bcd6SJiri Olsa #include <stdbool.h> 6*c574bcd6SJiri Olsa #include "bpf_kfuncs.h" 7*c574bcd6SJiri Olsa #include "bpf_misc.h" 8*c574bcd6SJiri Olsa 9*c574bcd6SJiri Olsa char _license[] SEC("license") = "GPL"; 10*c574bcd6SJiri Olsa 11*c574bcd6SJiri Olsa __u64 uprobe_session_result[3] = {}; 12*c574bcd6SJiri Olsa int pid = 0; 13*c574bcd6SJiri Olsa 14*c574bcd6SJiri Olsa static int uprobe_multi_check(void *ctx, int idx) 15*c574bcd6SJiri Olsa { 16*c574bcd6SJiri Olsa if (bpf_get_current_pid_tgid() >> 32 != pid) 17*c574bcd6SJiri Olsa return 1; 18*c574bcd6SJiri Olsa 19*c574bcd6SJiri Olsa uprobe_session_result[idx]++; 20*c574bcd6SJiri Olsa 21*c574bcd6SJiri Olsa /* only consumer 1 executes return probe */ 22*c574bcd6SJiri Olsa if (idx == 0 || idx == 2) 23*c574bcd6SJiri Olsa return 1; 24*c574bcd6SJiri Olsa 25*c574bcd6SJiri Olsa return 0; 26*c574bcd6SJiri Olsa } 27*c574bcd6SJiri Olsa 28*c574bcd6SJiri Olsa SEC("uprobe.session//proc/self/exe:uprobe_multi_func_1") 29*c574bcd6SJiri Olsa int uprobe_0(struct pt_regs *ctx) 30*c574bcd6SJiri Olsa { 31*c574bcd6SJiri Olsa return uprobe_multi_check(ctx, 0); 32*c574bcd6SJiri Olsa } 33*c574bcd6SJiri Olsa 34*c574bcd6SJiri Olsa SEC("uprobe.session//proc/self/exe:uprobe_multi_func_1") 35*c574bcd6SJiri Olsa int uprobe_1(struct pt_regs *ctx) 36*c574bcd6SJiri Olsa { 37*c574bcd6SJiri Olsa return uprobe_multi_check(ctx, 1); 38*c574bcd6SJiri Olsa } 39*c574bcd6SJiri Olsa 40*c574bcd6SJiri Olsa SEC("uprobe.session//proc/self/exe:uprobe_multi_func_1") 41*c574bcd6SJiri Olsa int uprobe_2(struct pt_regs *ctx) 42*c574bcd6SJiri Olsa { 43*c574bcd6SJiri Olsa return uprobe_multi_check(ctx, 2); 44*c574bcd6SJiri Olsa } 45