xref: /linux/tools/testing/selftests/bpf/progs/test_build_id.c (revision 3a39d672e7f48b8d6b91a09afa4b55352773b4b5)
1 // SPDX-License-Identifier: GPL-2.0
2 /* Copyright (c) 2024 Meta Platforms, Inc. and affiliates. */
3 
4 #include "vmlinux.h"
5 #include <bpf/bpf_helpers.h>
6 
7 struct bpf_stack_build_id stack_sleepable[128];
8 int res_sleepable;
9 
10 struct bpf_stack_build_id stack_nofault[128];
11 int res_nofault;
12 
13 SEC("uprobe.multi/./uprobe_multi:uprobe")
uprobe_nofault(struct pt_regs * ctx)14 int uprobe_nofault(struct pt_regs *ctx)
15 {
16 	res_nofault = bpf_get_stack(ctx, stack_nofault, sizeof(stack_nofault),
17 				    BPF_F_USER_STACK | BPF_F_USER_BUILD_ID);
18 
19 	return 0;
20 }
21 
22 SEC("uprobe.multi.s/./uprobe_multi:uprobe")
uprobe_sleepable(struct pt_regs * ctx)23 int uprobe_sleepable(struct pt_regs *ctx)
24 {
25 	res_sleepable = bpf_get_stack(ctx, stack_sleepable, sizeof(stack_sleepable),
26 				      BPF_F_USER_STACK | BPF_F_USER_BUILD_ID);
27 
28 	return 0;
29 }
30 
31 char _license[] SEC("license") = "GPL";
32