vscode: Refactor and add missing import

Thx to bear project
This commit is contained in:
Florian RICHER 2025-02-08 20:56:42 +01:00
parent 5686c97114
commit ca2332a6c9
Signed by: florian.richer
GPG key ID: C73D37CBED7BFC77
3 changed files with 47 additions and 13 deletions

View file

@ -1,15 +1,38 @@
{
"configurations": [
{
"name": "Linux",
"includePath": [
"${workspaceFolder}/**",
"${env:C_INCLUDE_PATH}"
],
"defines": [],
"cStandard": "c11",
"intelliSenseMode": "linux-gcc-x64"
}
{
"name": "Linux",
// BEGIN: Obtained from compile_commands.json generated with bear command
// Defined with -I args
"includePath": [
"${workspaceFolder}/**",
"${env:LINUX_MODULES_FOLDER}/source/arch/x86/include",
"${env:LINUX_MODULES_FOLDER}/source/include",
"${env:LINUX_MODULES_FOLDER}/source/arch/x86/include/uapi",
"${env:LINUX_MODULES_FOLDER}/source/include/uapi",
"${env:LINUX_MODULES_FOLDER}/build/arch/x86/include/generated",
"${env:LINUX_MODULES_FOLDER}/build/include"
],
// Defined with -include
"forcedInclude": [
"${env:LINUX_MODULES_FOLDER}/source/include/linux/compiler-version.h",
"${env:LINUX_MODULES_FOLDER}/source/include/linux/kconfig.h",
"${env:LINUX_MODULES_FOLDER}/source/include/linux/compiler_types.h"
],
// Defined with -D
"defines": [
"__KERNEL__",
"DCC_USING_FENTRY",
"MODULE",
"KBUILD_BASENAME=\"test_module\"",
"KBUILD_MODNAME=\"test_module\"",
"__KBUILD_MODNAME=kmod_test_module"
],
// END
"cStandard": "c11",
"cppStandard": "c++14",
"intelliSenseMode": "linux-gcc-x64"
}
],
"version": 4
}
}

View file

@ -43,4 +43,16 @@ sudo rmmod [module_name].ko
## Usefull links
- https://www.kernel.org/doc/html/latest/
- https://elixir.bootlin.com/linux/v6.13/source/
- https://elixir.bootlin.com/linux/v6.13/source/
## Notes
1. Find required headers files
```
nix shell nixpkgs#bear
cd 01_basic_module/
bear --append --output ../.vscode/compile_commands.json -- make -C $LINUX_MODULES_FOLDER/build M=$PWD modules
```
Search -I args and -D args

View file

@ -21,7 +21,6 @@
packages = [ linux.moduleBuildDependencies ];
LINUX_MODULES_FOLDER = "${linux.dev}/lib/modules/${linux.modDirVersion}";
C_INCLUDE_PATH = "${linux.dev}/lib/modules/${linux.modDirVersion}/source/include";
shellHook = ''
echo "Current Linux Kernel used : ${linux.version}"