Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error message in Multi-root project using compile_commands.json does not have enough information #5160

Closed
bobbrow opened this issue Mar 20, 2020 · 24 comments
Assignees
Labels
bug embedded Feature: Compile Commands fixed Check the Milestone for the release in which the fix is or will be available. quick fix
Projects
Milestone

Comments

@bobbrow
Copy link
Member

bobbrow commented Mar 20, 2020

Copying this issue over to cpptools where it would need to be addressed.

Originally posted by @sslupsky in microsoft/vscode-cmake-tools#1120 (comment)

One observation is that the error message that indicates an error with the configuration would benefit with additional information about what exactly it is referring to. Here is a screen shot:
Screen Shot 2020-03-20 at 12 52 50 PM
What is not clear is which configuration it is referring to. Does the message refer to the configuration in the .code-workspace file or one of the configurations in the c_cpp_properties.json file?

I copied a project directory and renamed it. I have opened the copy and I get the message in the screen shot above. I'm trying to run down where the problem is and it is not obvious.

@bobbrow
Copy link
Member Author

bobbrow commented Mar 20, 2020

This is referring to the configuration for one of the folders. cpptools should update the message to indicate which folder the configuration belongs to.

@sean-mcmanus
Copy link
Collaborator

What is meant by "configuration". The warning message doesn't mention "configuration". Is this a multi-root only issue? Should the ${workspaceFolder} be replaced by the workspace's name?

@sslupsky
Copy link

By "configuration", I am referring to the c/cpp extension configuration. In the screen shot, the configuration is set to "CMake-Tools" (instead of "Mac"). My c_cpp_properties.json file has the following "configurations":

{
	"configurations": [
		{
			"name": "Mac",
			"includePath": [],
			"forcedInclude": [],
			"defines": [],
			"compilerPath": "/usr/local/bin/arm-none-eabi-gcc",
			"cStandard": "c11",
			"cppStandard": "c++17",
			"intelliSenseMode": "gcc-x64"
		},
		{
			"name": "CMake-Tools",
			"configurationProvider": "vector-of-bool.cmake-tools",
			"forcedInclude": [
				"${workspaceFolder}/.vscode/c_cpp_undef.h"
			]
		}
	],
	"version": 4
}

I am using a multi-root workspace and CMake-Tools is set as the configurationProvider.

The following is the contents of my .code-workspace file:

{
	"folders": [
		{
			"path": "dock1500",
			"name": "app"
		},
		{
			"path": "zephyrproject/zephyr/boards/arm/scanimetrics_witap_isb",
			"name": "board"
		},
		{
			"path": "zephyrproject/zephyr",
			"name": "zephyr"
		},
		{
			"path": "zephyrproject/modules",
			"name": "modules"
		}
	],
	"settings": {
		"C_Cpp.default.includePath": [
			"${workspaceFolder:modules}/include",
			"${workspaceFolder:modules}/include/drivers",
			"${workspaceFolder:modules}/soc/arm/atmel_sam0/samd21",
			"${workspaceFolder:modules}/soc/arm/atmel_sam0/common/.",
			"${workspaceFolder:modules}/drivers",
			"${workspaceFolder:modules}/ext/lib/fnmatch/.",
			"${workspaceFolder:modules}/ext/hal/cmsis/Core/Include",
			"${workspaceFolder:modules}/subsys/usb",
			"${workspaceFolder:modules}/hal/atmel/asf/sam0/include/samd21",
			"${workspaceFolder:modules}/fs/littlefs",
			"${workspaceFolder:modules}/fs/fatfs/include",
			"${workspaceFolder:modules}/fs/nffs/include/nfss",
			"${workspaceFolder:modules}/lib/libc/minimal/include",
			"/usr/local/Cellar/arm-none-eabi-gcc/8-2018-q4-major/gcc/bin/../lib/gcc/arm-none-eabi/8.2.1/include",
			"/usr/local/Cellar/arm-none-eabi-gcc/8-2018-q4-major/gcc/bin/../lib/gcc/arm-none-eabi/8.2.1/include-fixed",
			"${workspaceFolder:app}/build/zephyr/include/generated"
		],
		"C_Cpp.default.forcedInclude": [
			"${workspaceFolder:app}/build/zephyr/include/generated/autoconf.h",
			"${workspaceFolder:modules}/include/toolchain/zephyr_stdint.h",
			"${workspaceFolder:app}/.vscode/c_cpp_undef.h"
		],
		"C_Cpp.default.defines": [
			"BUILD_VERSION=v2.1.0-rc1-141-g3cc5bda2fa10",
			"KERNEL",
			"_FORTIFY_SOURCE=2",
			"__PROGRAM_START",
			"__ZEPHYR__=1"
		],
		"C_Cpp.default.compilerPath": "/usr/local/bin/arm-none-eabi-gcc",
		"C_Cpp.default.cStandard": "c11",
		"C_Cpp.default.cppStandard": "c++17",
		"C_Cpp.default.intelliSenseMode": "gcc-x64",
		"C_Cpp.default.compileCommands": "${workspaceFolder:app}/build/compile_commands.json",
		"files.associations": {
			"zephyr.h": "c",
			"kernel.h": "c",
			"kernel_includes.h": "c",
			"log.h": "c",
			"printk.h": "c",
			"littlefs.h": "c",
			"i2c.h": "c",
			"usb_device.h": "c",
			"soc.h": "c",
			"samd21g18a.h": "c",
			"power.h": "c",
			"watchdog.h": "c",
			"i2c_ll_stm32.h": "c",
			"init.h": "c",
			"device.h": "c",
			"cpu.h": "c",
			"generated_dts_board.h": "c",
			"system_timer.h": "c",
			"clock_control.h": "c",
			"sys_clock.h": "c",
			"dma.h": "c",
			"hwinfo.h": "c",
			"gpio.h": "c",
			"errno.h": "c",
			"stdio.h": "c",
			"version.h": "c",
			"spi.h": "c",
			"*.overlay": "dts"
		},
		"terminal.integrated.env.osx": {
			"ZEPHYR_BASE": "${workspaceFolder:zephyr}",
			"ZEPHYR_TOOLCHAIN_VARIANT": "gnuarmemb",
			"GNUARMEMB_TOOLCHAIN_PATH": "/usr/local/",
			"PATH": "$ZEPHYR_BASE/scripts:${env:PATH}"
		},
		"cmake.configureOnOpen": true,
		"editor.tabSize": 8,
		"editor.insertSpaces": false
	}
}

Resolving the location of a header file can result in multiple paths when using a configurationProvider for a multi root workspace. I have noticed this happens when there is a header that does not have a corresponding ".c" target in compile_commands.json.

For instance, my main.c located in the "app" root folder, has the following include:

#include <kernel.h>

When I right click and select "Go to Definition", I get a window showing multiple paths.
Screen Shot 2020-03-22 at 12 44 42 PM

<kernel.h> is not located in the app folder, rather it is located in the "zephyr" root folder.

I think perhaps the c/cpp extension appears to be attempting to find a "kernel.c" target. Since "kernel.c" is not a target in compile_commands.json, the c/cpp extension defaults to another search process (default include paths) and comes up with multiple paths.

It seems that c/cpp should have used the "main.c" target in compile_commands.json?

@sslupsky
Copy link

Screen Shot 2020-03-22 at 12 46 44 PM

@sslupsky
Copy link

I removed the defaults from the .code-workspace file and have only one default setting:

{
	"folders": [
		{
			"path": "dock1500",
			"name": "app"
		},
		{
			"path": "zephyrproject/zephyr/boards/arm/scanimetrics_witap_isb",
			"name": "board"
		},
		{
			"path": "zephyrproject/zephyr",
			"name": "zephyr"
		},
		{
			"path": "zephyrproject/modules",
			"name": "modules"
		}
	],
	"settings": {
		"C_Cpp.default.compileCommands": "${workspaceFolder:app}/build/compile_commands.json",
		"files.associations": {
			"zephyr.h": "c",
			"kernel.h": "c",
			"kernel_includes.h": "c",
			"log.h": "c",
			"printk.h": "c",
			"littlefs.h": "c",
			"i2c.h": "c",
			"usb_device.h": "c",
			"soc.h": "c",
			"samd21g18a.h": "c",
			"power.h": "c",
			"watchdog.h": "c",
			"i2c_ll_stm32.h": "c",
			"init.h": "c",
			"device.h": "c",
			"cpu.h": "c",
			"generated_dts_board.h": "c",
			"system_timer.h": "c",
			"clock_control.h": "c",
			"sys_clock.h": "c",
			"dma.h": "c",
			"hwinfo.h": "c",
			"gpio.h": "c",
			"errno.h": "c",
			"stdio.h": "c",
			"version.h": "c",
			"spi.h": "c",
			"*.overlay": "dts",
			"sam0_eic.h": "c",
			"gpio_utils.h": "c",
			"led.h": "c"
		},
		"terminal.integrated.env.osx": {
			"ZEPHYR_BASE": "${workspaceFolder:zephyr}",
			"ZEPHYR_TOOLCHAIN_VARIANT": "gnuarmemb",
			"GNUARMEMB_TOOLCHAIN_PATH": "/usr/local/",
			"PATH": "$ZEPHYR_BASE/scripts:${env:PATH}"
		},
		"cmake.configureOnOpen": true,
		"editor.tabSize": 8,
		"editor.insertSpaces": false
	}
}

c_cpp_properties:

{
	"configurations": [
		{
			"name": "Mac",
			"includePath": [],
			"forcedInclude": [],
			"defines": [],
			"compilerPath": "/usr/local/bin/arm-none-eabi-gcc",
			"cStandard": "c11",
			"cppStandard": "c++17",
			"intelliSenseMode": "gcc-x64"
		},
		{
			"name": "CMake-Tools",
			"configurationProvider": "vector-of-bool.cmake-tools"
		}
	],
	"version": 4
}

I restarted VSCode. Now, all the red squiggles are gone and the log diagnostics shows the correct include paths:

-------- Diagnostics - 3/22/2020, 3:28:12 PM
Version: 0.27.0-insiders3
Current Configuration:
{
    "name": "CMake-Tools",
    "configurationProvider": "vector-of-bool.cmake-tools",
    "compileCommands": "/Users/stevenslupsky/Documents/source/dock1500/build/compile_commands.json",
    "compilerArgs": [],
    "browse": {
        "limitSymbolsToIncludedHeaders": true
    }
}
Translation Unit Mappings:
[ /Users/stevenslupsky/Documents/source/dock1500/src/main.c ]:
    /Users/stevenslupsky/Documents/source/dock1500/src/main.c
Translation Unit Configurations:
[ /Users/stevenslupsky/Documents/source/dock1500/src/main.c ]:
    Process ID: 17838
    Memory Usage: 39 MB
    Compiler Path: /usr/local/bin/arm-none-eabi-gcc
    Includes:
        /Users/stevenslupsky/Documents/source/zephyrproject/zephyr/include
        /Users/stevenslupsky/Documents/source/zephyrproject/zephyr/include/drivers
        /Users/stevenslupsky/Documents/source/dock1500/build/zephyr/include/generated
        /Users/stevenslupsky/Documents/source/zephyrproject/zephyr/soc/arm/atmel_sam0/samd21
        /Users/stevenslupsky/Documents/source/zephyrproject/zephyr/drivers
        /Users/stevenslupsky/Documents/source/zephyrproject/zephyr/soc/arm/atmel_sam0/common
        /Users/stevenslupsky/Documents/source/zephyrproject/zephyr/ext/lib/fnmatch
        /Users/stevenslupsky/Documents/source/zephyrproject/zephyr/ext/hal/cmsis/Core/Include
        /Users/stevenslupsky/Documents/source/zephyrproject/zephyr/subsys/usb
        /Users/stevenslupsky/Documents/source/zephyrproject/modules/hal/atmel/asf/sam0/include/samd21
        /Users/stevenslupsky/Documents/source/zephyrproject/modules/debug/segger/rtt
        /Users/stevenslupsky/Documents/source/zephyrproject/modules/fs/littlefs
        /Users/stevenslupsky/Documents/source/zephyrproject/zephyr/lib/libc/minimal/include
        /usr/local/Cellar/arm-none-eabi-gcc/8-2018-q4-major/gcc/lib/gcc/arm-none-eabi/8.2.1/include
        /usr/local/Cellar/arm-none-eabi-gcc/8-2018-q4-major/gcc/lib/gcc/arm-none-eabi/8.2.1/include-fixed
        /usr/local/Cellar/arm-none-eabi-gcc/8-2018-q4-major/gcc/arm-none-eabi/include
    Defines:
        BUILD_VERSION=v2.1.0-rc1-182-gb54ee41160d6
        KERNEL
        _FORTIFY_SOURCE=2
        __PROGRAM_START
        __ZEPHYR__=1
    Forced Includes:
        /Users/stevenslupsky/Documents/source/dock1500/build/zephyr/include/generated/autoconf.h
        /Users/stevenslupsky/Documents/source/zephyrproject/zephyr/include/toolchain/zephyr_stdint.h
    Standard Version: c11
    IntelliSense Mode: gcc-x64
    Other Flags:
        --gcc
        --gnu_version=80201
Total Memory Usage: 39 MB

The linting appears to be ok but I cannot "Go to Definition" for any include file now. I do not even see a popup with a list of definitions anymore. I see a message "no definition found for ".

If I select a function or type and "Go to Definition", VSCode appears to open the correct file with the definition.

This is the cleanest it has ever been for me, which is an improvement. The only remaining issue now is I cannot directly open the include files from #include statements. I have to indirectly open them by finding something that references them and then use "Go to Definition". Or, of course, open the include manually.

I read the open issue #2564 describing the problem of using Go to Definition on a #include statement. And idea what the ETA on a fix for this is?

@sean-mcmanus
Copy link
Collaborator

sean-mcmanus commented Mar 23, 2020

The browse.path isn't set automatically when compileCommands is set. See #1163 . If you're using CMake Tools, it's recommended that you not set compileCommands, because the CMake Tools extension will correctly set the browse.path. Sounds like you hit some issue using CMake Tools.

@sslupsky
Copy link

Unfortunately, CMake Tools does not appear to be providing the configuration so I changed my configuration to use compile_commands.json.

@bobbrow
Copy link
Member Author

bobbrow commented Mar 27, 2020

This seems more like an issue with the header to source file mappings. @Colengms I'm not sure if there's anything generic we can do here since this file is likely included by multiple source files and we don't know which one to pick. Are we defaulting to header-only IntelliSense in those cases now?

@sslupsky can you share the output of "Log Diagnostics" when just the header file is open so we can see whether it is being mapped to a source file?

@sslupsky
Copy link

Here is Log Diagnostics when I right click "Go To Definition" on "#include <device.h>" in "main.c" and then selected the "correct" item from the list:

-------- Diagnostics - 3/27/2020, 1:35:26 PM
Version: 0.27.0-insiders5
Current Configuration:
{
    "name": "Mac",
    "includePath": [],
    "forcedInclude": [],
    "defines": [],
    "compilerPath": "/usr/local/bin/arm-none-eabi-gcc",
    "cStandard": "c11",
    "cppStandard": "c++17",
    "intelliSenseMode": "gcc-x64",
    "compileCommands": "/Users/stevenslupsky/Documents/source/zephyrproject/dock1310/build/compile_commands.json",
    "compilerArgs": [],
    "browse": {
        "path": [
            "${workspaceFolder}"
        ],
        "limitSymbolsToIncludedHeaders": true
    }
}
Translation Unit Mappings:
[ /Users/stevenslupsky/Documents/source/zephyrproject/dock1310/src/main.c ]:
    /Users/stevenslupsky/Documents/source/zephyrproject/dock1310/src/main.c
    /Users/stevenslupsky/Documents/source/zephyrproject/zephyr/include/device.h
Translation Unit Configurations:
[ /Users/stevenslupsky/Documents/source/zephyrproject/dock1310/src/main.c ]:
    Process ID: 32499
    Memory Usage: 40 MB
    Compiler Path: /usr/local/bin/arm-none-eabi-gcc
    Includes:
        /Users/stevenslupsky/Documents/source/zephyrproject/zephyr/include
        /Users/stevenslupsky/Documents/source/zephyrproject/zephyr/include/drivers
        /Users/stevenslupsky/Documents/source/zephyrproject/dock1310/build/zephyr/include/generated
        /Users/stevenslupsky/Documents/source/zephyrproject/zephyr/soc/arm/atmel_sam0/samd21
        /Users/stevenslupsky/Documents/source/zephyrproject/zephyr/drivers
        /Users/stevenslupsky/Documents/source/zephyrproject/zephyr/soc/arm/atmel_sam0/common
        /Users/stevenslupsky/Documents/source/zephyrproject/zephyr/ext/lib/fnmatch
        /Users/stevenslupsky/Documents/source/zephyrproject/zephyr/ext/hal/cmsis/Core/Include
        /Users/stevenslupsky/Documents/source/zephyrproject/zephyr/subsys/net/lib/sockets
        /Users/stevenslupsky/Documents/source/zephyrproject/zephyr/subsys/usb
        /Users/stevenslupsky/Documents/source/zephyrproject/modules/hal/atmel/asf/sam0/include/samd21
        /Users/stevenslupsky/Documents/source/zephyrproject/modules/debug/segger/rtt
        /Users/stevenslupsky/Documents/source/zephyrproject/modules/fs/littlefs
        /Users/stevenslupsky/Documents/source/zephyrproject/zephyr/lib/libc/minimal/include
        /usr/local/Cellar/arm-none-eabi-gcc/8-2018-q4-major/gcc/lib/gcc/arm-none-eabi/8.2.1/include
        /usr/local/Cellar/arm-none-eabi-gcc/8-2018-q4-major/gcc/lib/gcc/arm-none-eabi/8.2.1/include-fixed
        /usr/local/Cellar/arm-none-eabi-gcc/8-2018-q4-major/gcc/arm-none-eabi/include
    Defines:
        BUILD_VERSION=v2.1.0-rc1-188-g58c7211ee603
        KERNEL
        _FORTIFY_SOURCE=2
        __PROGRAM_START
        __ZEPHYR__=1
    Forced Includes:
        /Users/stevenslupsky/Documents/source/zephyrproject/dock1310/build/zephyr/include/generated/autoconf.h
        /Users/stevenslupsky/Documents/source/zephyrproject/zephyr/include/toolchain/zephyr_stdint.h
    Standard Version: c11
    IntelliSense Mode: gcc-x64
    Other Flags:
        --gcc
        --gnu_version=80201
Total Memory Usage: 40 MB

The "device.h" file appears to be mapped to the configuration used for "main.c". I think that is correct.

@bobbrow
Copy link
Member Author

bobbrow commented Mar 27, 2020

Did you have main.c open in the editor before device.h was opened? Here's a test. Close all editor tabs except for device.h and then run the "Reload Window" command. When IntelliSense is ready, run the "Log Diagnostics" command and check the mapping for device.h.

@bobbrow
Copy link
Member Author

bobbrow commented Mar 27, 2020

In your earlier comment you said that switching to compile_commands.json fixed your problem, but that shouldn't be the case for header files. compile_commands.json doesn't have entries for header files but the configuration provider would have entries if the header files were listed in the CMakeLists.txt file. I would expect compile_commands.json to work only if the source file (e.g. main.c) is also open in the editor.

@sslupsky
Copy link

sslupsky commented Apr 2, 2020

Here are a couple snap shots of the log diagnostics. They were generated with all tabs closed except device.h. I also reloaded with window.
The first log was taken shortly after the window was reloaded.
The second log was taken about 30 seconds later.

-------- Diagnostics - 4/2/2020, 10:02:06 AM
Version: 0.27.0
Current Configuration:
{
    "name": "Mac",
    "includePath": [],
    "forcedInclude": [],
    "defines": [],
    "compilerPath": "/usr/local/bin/arm-none-eabi-gcc",
    "cStandard": "c11",
    "cppStandard": "c++17",
    "intelliSenseMode": "gcc-x64",
    "compileCommands": "/Users/stevenslupsky/Documents/source/zephyrproject/dock1310/build/compile_commands.json",
    "compilerArgs": [],
    "browse": {
        "path": [
            "${workspaceFolder}"
        ],
        "limitSymbolsToIncludedHeaders": true
    }
}
No active translation units.

-------- Diagnostics - 4/2/2020, 10:02:29 AM
Version: 0.27.0
Current Configuration:
{
    "name": "Mac",
    "includePath": [],
    "forcedInclude": [],
    "defines": [],
    "compilerPath": "/usr/local/bin/arm-none-eabi-gcc",
    "cStandard": "c11",
    "cppStandard": "c++17",
    "intelliSenseMode": "gcc-x64",
    "compileCommands": "/Users/stevenslupsky/Documents/source/zephyrproject/dock1310/build/compile_commands.json",
    "compilerArgs": [],
    "browse": {
        "path": [
            "${workspaceFolder}"
        ],
        "limitSymbolsToIncludedHeaders": true
    }
}
Translation Unit Mappings:
[ /Users/stevenslupsky/Documents/source/zephyrproject/zephyr/kernel/device.c ]:
    /Users/stevenslupsky/Documents/source/zephyrproject/zephyr/include/device.h
Translation Unit Configurations:
[ /Users/stevenslupsky/Documents/source/zephyrproject/zephyr/kernel/device.c ]:
    Process ID: 6036
    Memory Usage: 18 MB
    Compiler Path: /usr/local/bin/arm-none-eabi-gcc
    Includes:
        /Users/stevenslupsky/Documents/source/zephyrproject/zephyr/kernel/include
        /Users/stevenslupsky/Documents/source/zephyrproject/zephyr/arch/arm/include
        /Users/stevenslupsky/Documents/source/zephyrproject/zephyr/include
        /Users/stevenslupsky/Documents/source/zephyrproject/dock1310/build/zephyr/include/generated
        /Users/stevenslupsky/Documents/source/zephyrproject/zephyr/soc/arm/atmel_sam0/samd21
        /Users/stevenslupsky/Documents/source/zephyrproject/zephyr/drivers
        /Users/stevenslupsky/Documents/source/zephyrproject/zephyr/soc/arm/atmel_sam0/common
        /Users/stevenslupsky/Documents/source/zephyrproject/zephyr/ext/lib/fnmatch
        /Users/stevenslupsky/Documents/source/zephyrproject/zephyr/ext/hal/cmsis/Core/Include
        /Users/stevenslupsky/Documents/source/zephyrproject/zephyr/subsys/usb
        /Users/stevenslupsky/Documents/source/zephyrproject/modules/hal/cmsis/CMSIS/Core/Include
        /Users/stevenslupsky/Documents/source/zephyrproject/modules/hal/atmel/asf/sam0/include/samd21
        /Users/stevenslupsky/Documents/source/zephyrproject/modules/debug/segger/rtt
        /Users/stevenslupsky/Documents/source/zephyrproject/zephyr/lib/libc/minimal/include
        /usr/local/Cellar/arm-none-eabi-gcc/8-2018-q4-major/gcc/lib/gcc/arm-none-eabi/8.2.1/include
        /usr/local/Cellar/arm-none-eabi-gcc/8-2018-q4-major/gcc/lib/gcc/arm-none-eabi/8.2.1/include-fixed
        /usr/local/Cellar/arm-none-eabi-gcc/8-2018-q4-major/gcc/arm-none-eabi/include
        /Users/stevenslupsky/Documents/source/zephyrproject/zephyr/include
    Defines:
        BUILD_VERSION=v2.2.0-rc2-61-g2836fe16a974
        KERNEL
        _FORTIFY_SOURCE=2
        __PROGRAM_START
        __ZEPHYR_SUPERVISOR__
        __ZEPHYR__=1
    Forced Includes:
        /Users/stevenslupsky/Documents/source/zephyrproject/dock1310/build/zephyr/include/generated/autoconf.h
        /Users/stevenslupsky/Documents/source/zephyrproject/zephyr/include/toolchain/zephyr_stdint.h
    Standard Version: c11
    IntelliSense Mode: gcc-x64
    Other Flags:
        --gcc
        --gnu_version=80201
Total Memory Usage: 18 MB

@sslupsky
Copy link

sslupsky commented Apr 2, 2020

I think in this case, the compile_commands.json has an entry for "device.c", so it picked that up for the translation unit mapping.

@sslupsky
Copy link

sslupsky commented Apr 2, 2020

Here is a copy of the entry in compile_commands.json:

{
  "directory": "/Users/stevenslupsky/Documents/source/zephyrproject/dock1310/build",
  "command": "/usr/local/bin/arm-none-eabi-gcc -DBUILD_VERSION=v2.2.0-rc2-61-g2836fe16a974 -DKERNEL -D_FORTIFY_SOURCE=2 -D__PROGRAM_START -D__ZEPHYR__=1 -I/Users/stevenslupsky/Documents/source/zephyrproject/zephyr/include -Izephyr/include/generated -I/Users/stevenslupsky/Documents/source/zephyrproject/zephyr/soc/arm/atmel_sam0/samd21 -I/Users/stevenslupsky/Documents/source/zephyrproject/zephyr/drivers -I/Users/stevenslupsky/Documents/source/zephyrproject/zephyr/soc/arm/atmel_sam0/common/. -I/Users/stevenslupsky/Documents/source/zephyrproject/zephyr/ext/lib/fnmatch/. -I/Users/stevenslupsky/Documents/source/zephyrproject/zephyr/ext/hal/cmsis/Core/Include -I/Users/stevenslupsky/Documents/source/zephyrproject/zephyr/subsys/usb -I/Users/stevenslupsky/Documents/source/zephyrproject/modules/hal/cmsis/CMSIS/Core/Include -I/Users/stevenslupsky/Documents/source/zephyrproject/modules/hal/atmel/asf/sam0/include/samd21 -I/Users/stevenslupsky/Documents/source/zephyrproject/modules/debug/segger/rtt -isystem /Users/stevenslupsky/Documents/source/zephyrproject/zephyr/lib/libc/minimal/include -isystem /usr/local/Cellar/arm-none-eabi-gcc/8-2018-q4-major/gcc/bin/../lib/gcc/arm-none-eabi/8.2.1/include -isystem /usr/local/Cellar/arm-none-eabi-gcc/8-2018-q4-major/gcc/bin/../lib/gcc/arm-none-eabi/8.2.1/include-fixed    -Og -imacros/Users/stevenslupsky/Documents/source/zephyrproject/dock1310/build/zephyr/include/generated/autoconf.h -ffreestanding -fno-common -g -mthumb -mcpu=cortex-m0plus -imacros/Users/stevenslupsky/Documents/source/zephyrproject/zephyr/include/toolchain/zephyr_stdint.h -Wall -Wformat -Wformat-security -Wno-format-zero-length -Wno-main -Wno-pointer-sign -Wpointer-arith -Wno-unused-but-set-variable -Werror=implicit-int -fno-asynchronous-unwind-tables -fno-pie -fno-pic -fno-strict-overflow -fno-reorder-functions -fno-defer-pop -fstack-usage -fmacro-prefix-map=/Users/stevenslupsky/Documents/source/zephyrproject/dock1310=CMAKE_SOURCE_DIR -fmacro-prefix-map=/Users/stevenslupsky/Documents/source/zephyrproject/zephyr=ZEPHYR_BASE -fmacro-prefix-map=/Users/stevenslupsky/Documents/source/zephyrproject=WEST_TOPDIR -ffunction-sections -fdata-sections -mabi=aapcs -march=armv6s-m -std=c99 -nostdinc -o zephyr/CMakeFiles/zephyr.dir/subsys/usb/usb_device.c.obj   -c /Users/stevenslupsky/Documents/source/zephyrproject/zephyr/subsys/usb/usb_device.c",
  "file": "/Users/stevenslupsky/Documents/source/zephyrproject/zephyr/subsys/usb/usb_device.c"
},

@bobbrow
Copy link
Member Author

bobbrow commented Apr 2, 2020

And when you do the same exercise with the Configuration Provider set to CMake Tools, what do you get?

@bobbrow
Copy link
Member Author

bobbrow commented Apr 2, 2020

Just a note for @elahehrashedi, the original issue here is about the warning message, but we have been discussing additional issues related to this project which will likely need to be split out into another issue.

@sslupsky
Copy link

sslupsky commented Apr 2, 2020

When I switched my configuration to use CMake Tools as the configuration provider, I saw this message displayed in the output window:

Failed to read response from server: 22

After reloading the window, I did not see this message.
Here is the log diagnostics:

-------- Diagnostics - 4/2/2020, 10:43:38 AM
Version: 0.27.0
Current Configuration:
{
    "name": "CMake-Tools",
    "configurationProvider": "vector-of-bool.cmake-tools",
    "compileCommands": "/Users/stevenslupsky/Documents/source/zephyrproject/dock1310/build/compile_commands.json",
    "compilerArgs": [],
    "browse": {
        "limitSymbolsToIncludedHeaders": true
    }
}
Translation Unit Mappings:
[ /Users/stevenslupsky/Documents/source/zephyrproject/zephyr/drivers/modem/modem_iface_uart.c ]:
    /Users/stevenslupsky/Documents/source/zephyrproject/zephyr/include/device.h
Translation Unit Configurations:
[ /Users/stevenslupsky/Documents/source/zephyrproject/zephyr/drivers/modem/modem_iface_uart.c ]:
    Process ID: 6929
    Memory Usage: 22 MB
    Compiler Path: /usr/local/bin/arm-none-eabi-gcc
    Includes:
        /Users/stevenslupsky/Documents/source/zephyrproject/zephyr/include
        /Users/stevenslupsky/Documents/source/zephyrproject/dock1310/build/zephyr/include/generated
        /Users/stevenslupsky/Documents/source/zephyrproject/zephyr/soc/arm/atmel_sam0/samd21
        /Users/stevenslupsky/Documents/source/zephyrproject/zephyr/drivers
        /Users/stevenslupsky/Documents/source/zephyrproject/zephyr/soc/arm/atmel_sam0/common
        /Users/stevenslupsky/Documents/source/zephyrproject/zephyr/ext/lib/fnmatch
        /Users/stevenslupsky/Documents/source/zephyrproject/zephyr/ext/hal/cmsis/Core/Include
        /Users/stevenslupsky/Documents/source/zephyrproject/zephyr/subsys/usb
        /Users/stevenslupsky/Documents/source/zephyrproject/modules/hal/cmsis/CMSIS/Core/Include
        /Users/stevenslupsky/Documents/source/zephyrproject/modules/hal/atmel/asf/sam0/include/samd21
        /Users/stevenslupsky/Documents/source/zephyrproject/modules/debug/segger/rtt
        /Users/stevenslupsky/Documents/source/zephyrproject/zephyr/lib/libc/minimal/include
        /usr/local/Cellar/arm-none-eabi-gcc/8-2018-q4-major/gcc/lib/gcc/arm-none-eabi/8.2.1/include
        /usr/local/Cellar/arm-none-eabi-gcc/8-2018-q4-major/gcc/lib/gcc/arm-none-eabi/8.2.1/include-fixed
        /usr/local/Cellar/arm-none-eabi-gcc/8-2018-q4-major/gcc/arm-none-eabi/include
        /Users/stevenslupsky/Documents/source/zephyrproject/zephyr/include
    Defines:
        BUILD_VERSION=v2.2.0-rc2-61-g2836fe16a974
        KERNEL
        _FORTIFY_SOURCE=2
        __PROGRAM_START
        __ZEPHYR__=1
    Forced Includes:
        /Users/stevenslupsky/Documents/source/zephyrproject/dock1310/build/zephyr/include/generated/autoconf.h
        /Users/stevenslupsky/Documents/source/zephyrproject/zephyr/include/toolchain/zephyr_stdint.h
    Standard Version: c11
    IntelliSense Mode: gcc-x64
    Other Flags:
        --gcc
        --gnu_version=80201
Total Memory Usage: 22 MB

So in this instance, it appears to have provided the configuration. It appears to have picked a seemingly random translation unit mapping modem_iface_uart.c. Maybe not so random, I believe that was one of the last files I was working on. I did reload the window and the modem_iface_uart.c tab is not open.

@bobbrow
Copy link
Member Author

bobbrow commented Apr 2, 2020

When a header file is included by multiple translation units and none of them are open in the editor, we have to guess one. If you end up opening a source file in the editor (e.g. main.c), we will switch over to using that one.

The important question is whether you get correct IntelliSense or not in this case. Do you? The configurations are very similar but not exactly the same. I'm just wondering if there are any issues left to track for your setup besides #2564?

@sslupsky
Copy link

sslupsky commented Apr 2, 2020

Yes, it appears intellisense was linting the code properly in this instance.

I am still uncertain why CMake Tools was not providing a configuration for main.c?

I removed the default configuration from .code-workspace and switched the configuration for main.c to use CMake Tools as the configuration provider. I reloaded the window. I waited about 30 seconds, all the includes have squiggles. The only open tab is main.c. Here is the log diagnostics:

-------- Diagnostics - 4/2/2020, 11:34:19 AM
Version: 0.27.0
Current Configuration:
{
    "name": "CMake-Tools",
    "configurationProvider": "vector-of-bool.cmake-tools",
    "compilerArgs": [],
    "browse": {
        "limitSymbolsToIncludedHeaders": true
    }
}
Translation Unit Mappings:
[ /Users/stevenslupsky/Documents/source/zephyrproject/dock1310/src/main.c ]:
    /Users/stevenslupsky/Documents/source/zephyrproject/dock1310/src/main.c
Translation Unit Configurations:
[ /Users/stevenslupsky/Documents/source/zephyrproject/dock1310/src/main.c ]:
    Process ID: 8160
    Memory Usage: 55 MB
    Compiler Path: /usr/bin/clang
    Includes:
        /usr/local/include
        /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/11.0.0/include
        /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include
        /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include
    Frameworks:
        /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks
    Standard Version: c11
    IntelliSense Mode: clang-x64
    Other Flags:
        --clang
        --clang_version=110000
Total Memory Usage: 55 MB

@sslupsky
Copy link

sslupsky commented Apr 2, 2020

I do not even know where it is getting that configuration above. I do not have any defaults in the code-workspace and c-cpp-properties default specifies gcc with no includes or defines. So, this must be some sort of system default provided by CMake Tools?

@sean-mcmanus
Copy link
Collaborator

Yes, CMake Tools will provide system info. You can see it in the logging via setting C_Cpp.loggingLevel to "Debug" and looking for "Custom configurations received:".

@bobbrow
Copy link
Member Author

bobbrow commented Apr 3, 2020

The configuration for main.c looks wrong and possibly isn't provided by CMake Tools. Checking the logging as @sean-mcmanus mentions would remove all doubt. If that's the case, then we move the investigation back over to CMake Tools.

elahehrashedi pushed a commit that referenced this issue Apr 7, 2020
@elahehrashedi elahehrashedi added the fixed Check the Milestone for the release in which the fix is or will be available. label Apr 7, 2020
@bobbrow bobbrow added this to To do in 0.28.0 via automation Apr 7, 2020
@bobbrow bobbrow moved this from To do to In progress in 0.28.0 Apr 7, 2020
@bobbrow bobbrow moved this from In progress to Done in 0.28.0 Apr 7, 2020
@sean-mcmanus
Copy link
Collaborator

@elahehrashedi
Copy link
Contributor

This issue is fixed in 0.28.0.
0.28.0 release: https://github.com/microsoft/vscode-cpptools/releases/tag/0.28.0

@github-actions github-actions bot locked and limited conversation to collaborators Oct 9, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug embedded Feature: Compile Commands fixed Check the Milestone for the release in which the fix is or will be available. quick fix
Projects
No open projects
0.28.0
  
Done
Development

No branches or pull requests

5 participants