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