xref: /openbmc/linux/tools/testing/selftests/bpf/progs/trace_printk.c (revision 67bb66d32905627e29400e2cb7f87a7c4c8cf667)
1 // SPDX-License-Identifier: GPL-2.0
2 // Copyright (c) 2020, Oracle and/or its affiliates.
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 trace_printk_ret = 0;
11 int trace_printk_ran = 0;
12 
13 const char fmt[] = "Testing,testing %d\n";
14 
15 SEC("fentry/__x64_sys_nanosleep")
16 int sys_enter(void *ctx)
17 {
18 	trace_printk_ret = bpf_trace_printk(fmt, sizeof(fmt),
19 					    ++trace_printk_ran);
20 	return 0;
21 }
22