To generate an updated vmlinux.h
:
$ bpftool btf dump file /sys/kernel/btf/vmlinux format c > ./vmlinux.h
bpf_printk will output to
sudo cat /sys/kernel/debug/tracing/trace_pipe
You can execute sudo ls /sys/kernel/debug
to query the kernel debug file system for specific information.
For example, the following command can be executed in order to query the parameter format of the execve system call.
# in case of missing file, try to mount debugfs
# sudo mount -t debugfs debugfs /sys/kernel/debug
sudo cat /sys/kernel/debug/tracing/events/syscalls/sys_enter_execve/format
->
name: sys_enter_execve
ID: 716
format:
field:unsigned short common_type; offset:0; size:2; signed:0;
field:unsigned char common_flags; offset:2; size:1; signed:0;
field:unsigned char common_preempt_count; offset:3; size:1; signed:0;
field:int common_pid; offset:4; size:4; signed:1;
field:int __syscall_nr; offset:8; size:4; signed:1;
field:const char * filename; offset:16; size:8; signed:0;
field:const char *const * argv; offset:24; size:8; signed:0;
field:const char *const * envp; offset:32; size:8; signed:0;
print fmt: "filename: 0x%08lx, argv: 0x%08lx, envp: 0x%08lx", ((unsigned long)(REC->filename)), ((unsigned long)(REC->argv)), ((unsigned long)(REC->envp))