Detect kernel headers even if they are splitted into source/ and build/ directories
Currently bpftrace uses only /lib/modules/`uname -r`/source/ if it exists. This however leads to failures Debian where generated kernel headers, such as include/generated/autoconf.h are put into a separate directory, for example: ---- 8< ---- (fuse_vs_mmapsem.bt) #include <linux/path.h> #include <linux/dcache.h> #include <linux/sched.h> #include <linux/mm_types.h> kprobe:fuse_readpage,kprobe:fuse_readpages { printf("%s (%d) %s\n", probe, ((task_struct *)curtask)->mm->mmap_sem.count.counter, kstack); } ---- 8< ---- # ./bpftrace fuse_vs_mmapsem.bt /lib/modules/4.19.0-2-amd64/source/include/linux/kconfig.h:5:10: fatal error: 'generated/autoconf.h' file not found Unknown struct/union: 'task_struct' Fix it by using both /lib/modules/`uname -r`/source/ and /lib/modules/`uname -r`/build/ if both are present. /cc @vincentbernat P.S. I was not using C++ for ages, so please forgive me in advance if I missed something.
Showing
Please register or sign in to comment