1 // SPDX-License-Identifier: GPL-2.0
2 /* Copyright (c) 2021 Facebook */
3
4 #include "vmlinux.h"
5 #include <bpf/bpf_helpers.h>
6 #include <bpf/bpf_tracing.h>
7
8 char _license[] SEC("license") = "GPL";
9
10 int null_data_vprintk_ret = 0;
11 int trace_vprintk_ret = 0;
12 int trace_vprintk_ran = 0;
13
14 SEC("fentry/__x64_sys_nanosleep")
sys_enter(void * ctx)15 int sys_enter(void *ctx)
16 {
17 static const char one[] = "1";
18 static const char three[] = "3";
19 static const char five[] = "5";
20 static const char seven[] = "7";
21 static const char nine[] = "9";
22 static const char f[] = "%pS\n";
23
24 /* runner doesn't search for \t, just ensure it compiles */
25 bpf_printk("\t");
26
27 trace_vprintk_ret = __bpf_vprintk("%s,%d,%s,%d,%s,%d,%s,%d,%s,%d %d\n",
28 one, 2, three, 4, five, 6, seven, 8, nine, 10, ++trace_vprintk_ran);
29
30 /* non-NULL fmt w/ NULL data should result in error */
31 null_data_vprintk_ret = bpf_trace_vprintk(f, sizeof(f), NULL, 0);
32 return 0;
33 }
34