bcc
bcc copied to clipboard
#include errors detected. Please update your includePath for #include <uapi/linux/ptrace.h>
While developing eBPF code in C, Visual Studio Code cannot detect some header files. For example, in tcpconnect.c, the vscode editor shows some include path errors.
#include <uapi/linux/ptrace.h>
#include <net/sock.h>
#include <bcc/proto.h>
I get "#include errors detected. Please update your includePath."
How would I properly update my .vscode/c_cpp_properties/ includePath to incorporate the correct headers?
I have tried
{
"configurations": [
{
"name": "Linux",
"includePath": [
"${workspaceFolder}/**"
"/usr/src/linux-headers-5.15.0-69-generic/include"
],
"defines": [],
"compilerPath": "/usr/bin/gcc",
"cStandard": "c17",
"cppStandard": "gnu++14",
"intelliSenseMode": "linux-gcc-x64",
}
],
"version": 4
}
This solves the first header "<uapi/linux/ptrace.h>" but I still get errors for the next two.
#include <net/sock.h> // cannot open source file "asm/bug.h" (dependency of "net/sock.h")C/C++(1696)
#include <bcc/proto.h> // cannot open source file "bcc/proto.h"C/C++(1696)
How do I properly configure my vscode settings to help make developing eBPF code / C code easier?
It seems like most headers are mounted in a virtual directory. I am trying to make sense of how it's done to build a proper makefile. It would be nice to have IDE features working and not have to deal with hundreds of errors all over.
A bit unorthodox, but I got it to work by taking all files in bcc/src/cc/export and including them manually in the project.
Of course, after doing this it still wouldn't work because the BPF "compiler" (actually a clang wrapper) would still try to include its own.
So the spaghetti solution was to just wrap the includes around a block that the python script would remove before passing them to the BPF class.
There has to be a better solution, perhaps a makefile that would sort all this... Oh well.
I encountered a situation where adding ** after /usr/src/linux-headers-5.15.0-69-generic/ made it work.
{
"configurations": [
{
"name": "Linux",
"includePath": [
"${workspaceFolder}/**",
"/usr/src/linux-headers-5.15.0-69-generic/**"
],
"defines": [],
"compilerPath": "/usr/bin/gcc",
"cStandard": "c17",
"cppStandard": "gnu++14",
"intelliSenseMode": "linux-gcc-x64",
}
],
"version": 4
}
I am still getting the red squiggling line for the header 'bcc/proto.h'