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

Problem with intellisense and build tasks with RX project #58

Closed
larlin opened this issue Aug 8, 2023 · 19 comments
Closed

Problem with intellisense and build tasks with RX project #58

larlin opened this issue Aug 8, 2023 · 19 comments
Assignees
Labels
bug Something isn't working

Comments

@larlin
Copy link

larlin commented Aug 8, 2023

I have had intermittent problems with intellisense for some time but it got more stable in the spring now when I got back after my vacation I can't get it to work at all. Seems to be related to includes could be related to #8 but I get some other strangeness so my guess is that this is another issue.

Here is the IAR Build log from when starting VSC:

[8/8/2023, 2:29:23 PM][Debug] Activating extension
[8/8/2023, 2:29:23 PM][Debug] Toolchain: selected 'undefined' (index undefined)
[8/8/2023, 2:29:23 PM][Debug] Loaded thrift workbench 'undefined'
[8/8/2023, 2:29:23 PM][Debug] Loaded extended project 'undefined'
[8/8/2023, 2:29:24 PM][Error] Failed to fetch toolchains from registry: Error: Process exited with code: 1
[8/8/2023, 2:29:24 PM][Debug] Collected 1 toolchains
[8/8/2023, 2:29:24 PM][Debug] Toolchain: selected 'Embedded Workbench 8.4 (RX)' (index 0)
[8/8/2023, 2:29:24 PM][Debug] 1 new toolchain(s) added
[8/8/2023, 2:29:24 PM][Debug] Loaded thrift workbench 'undefined'
[8/8/2023, 2:29:24 PM][Debug] Loaded extended project 'undefined'
[8/8/2023, 2:29:28 PM][Debug] Found 3 workspace(s) in the VS Code workspace
[8/8/2023, 2:29:28 PM][Debug] Workspace: selected 'sentrac_v2' (index 0)
[8/8/2023, 2:29:28 PM][Debug] Project: selected 'sentrac_v2' (index 2)
[8/8/2023, 2:29:28 PM][Debug] Configuration: selected 'Debug' (index 0)
[8/8/2023, 2:29:28 PM][Debug] Loaded extended project 'undefined'
[8/8/2023, 2:29:29 PM][Debug] Found 3 project(s) in the VS Code workspace

The undefined part there doesn't seem great?

This is running without a c_cpp_properties.json file and my understanding is that then the IAR Config Generator should output some info when it generates the configuration for the c/cpp plugin? That Output tab is empty so it does not seem like it is triggered properly.

I also get this error for the IAR Build plugin:
image

Also possible related strangeness if I use the Run Task: Build Project button in the IAR BUILD tab it runs a terminal that only prints the following:

Executing task: iar: Build Project 

If I instead do Run task... I have two iar:Build Task one that works the same as using the button in the IAR BUILD tab and the other works correctly.
image

'C:\Program Files (x86)\IAR Systems\Embedded Workbench 8.4/common/bin/iarbuild.exe' 'c:\PROJECT_PATH' '-make' 'Debug' '-log' 'info' '-parallel' '4'

     IAR Command Line Build Utility V8.4.10.7051/W32
     Copyright 2002-2020 IAR Systems AB.

Building configuration: sentrac_v2 - Debug
Updating build tree...

Configuration is up-to-date.

PROJECT_PATH is the correct path to the project .ewp file.

Not sure if these things are related.

@jlonnberg
Copy link
Collaborator

Hi,

How does the problem with intellisense manifest itself? Do you have no code assistance at all or some?

With the async nature of VsCode, the "undefined" part is by itself as we should handle it properly but we might end up with a problem in your case.

Have you made any other changes, e.g., upgraded VsCode or EWRX version?

@jlonnberg jlonnberg self-assigned this Aug 9, 2023
@jlonnberg jlonnberg added the bug Something isn't working label Aug 9, 2023
@larlin
Copy link
Author

larlin commented Aug 9, 2023

Hi,

Thanks for the reply. VsCode is updating automatically it did so after I tested things yesterday. I don't remember if it was updated earlier in the week as well. I have not updated the EWRX in many months.

Sorry for not describing the problem with more details. The problem is missing references and includes.

Now I have tested a bit more with the latest version of VsCode and now it seems to work somewhat in the sense that I get less errors if I have an empty configuration (no c_cpp_properties.json file). But it seems to default to the default MSVC headers and not the iar headers. Which still gives problems with iar specific things such as intrinsics.h.

If I create a custom configuration something like this:

        {
            "name": "RX",
            "includePath": [
                "${workspaceFolder}/**",
                "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 8.4\\rx\\inc",
                "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 8.4\\rx\\inc\\c"
            ],
            "defines": [
                "_DEBUG",
                "UNICODE",
                "_UNICODE"
            ],
            "compilerPath": "C:\\Program Files (x86)\\IAR Systems\\Embedded Workbench 8.4\\rx\\bin\\iccrx.exe",
            "cStandard": "c17",
            "cppStandard": "c++17",
            "intelliSenseMode": "linux-gcc-arm",
            "configurationProvider": "iarsystems.iar-build"
        }

I still get errors as an example in stdint.h the folllowing errors and more:
´´´
identifier "INT_LEAST8_T_TYPE" is undefined
identifier "UINT_LEAST8_T_TYPE" is undefined
identifier "INT_LEAST16_T_TYPE" is undefined
identifier "UINT_LEAST16_T_TYPE" is undefined
´´´

Previously I have solved this problem by adding the definitions to the "iar-build.defines" setting in settings.json, but that does not seem to help now.

@jlonnberg
Copy link
Collaborator

So, I did a quick test on this using VsCode 1.81, IAR Build Extension version 1.30.2 and RX Version 4.20 (which is the same as yours) on a fresh project from Information Center and Intellisense works as expected and stdint.h is parsed properly. I did not create any custom configuration for my project.

Is it possible for you to test with a fresh project and see if the problem persists?

@larlin
Copy link
Author

larlin commented Aug 9, 2023

Hi,

Yes I have now created an new project in EWRX with one simple main.c and no extra configuration in VSC.

This is my main.c:

#include <stdint.h>
#include <intrinsics.h>

int main( void )
{
  return 0;
}

In VSC intrinsics.h is not found and if I use F12 on stdint.h VSC will open the MSVC stdint.h not the iar stdint.h.
(for me located in: C:\Program Files (x86)\Microsoft Visual Studio...\VC\Tools\MSVC\14.29.30133\include\stdint.h)
So this is from my installation of Visual Studio (not visual studio code).

So maybe that Visual Studio is installed with the Microsoft C compiler is a critical difference?

@jlonnberg
Copy link
Collaborator

It should not make a difference. I did my testing on a machine with MSVC installed as well and our extension should source the location of headers by itself, not using anything that might be in path.

Could you zip and upload the example tiny example project folder and the vscode workspace folder and upload for me to look at?

@larlin
Copy link
Author

larlin commented Aug 11, 2023

The EWRX folder is attached. I only used open folder in visual studio code for this test so I did not create a VSC workspace. My general settings file for VSC looks like this:

{
    "workbench.colorTheme": "Visual Studio Light - C++",
    "[python]": {
        "editor.formatOnType": true
    },
    "files.associations": {
        "*.h": "c"
    },
    "iar-build.iarInstallDirectories": [
        "C:\\Program Files\\IAR Systems",
        "C:\\Program Files (x86)\\IAR Systems"
    ]
}

VSC_IAR_TEST.zip

@jlonnberg
Copy link
Collaborator

So that project works perfectly for me and I can see no problems with the settings as such.
Can you include the complete output for IAR Build in the Output view from launching VSC and opening main.c? It might shine some light on the situation.

@larlin
Copy link
Author

larlin commented Aug 11, 2023

Here is the complete output for IAR Build from a newly started instance of VSC opening a the test project folder.

[8/11/2023, 10:03:32 AM][Debug] Activating extension
[8/11/2023, 10:03:32 AM][Debug] Toolchain: selected 'undefined' (index undefined)
[8/11/2023, 10:03:32 AM][Debug] Loaded thrift workbench 'undefined'
[8/11/2023, 10:03:32 AM][Debug] Loaded extended project 'undefined'
[8/11/2023, 10:03:32 AM][Error] Failed to fetch toolchains from registry: Error: Process exited with code: 1
[8/11/2023, 10:03:32 AM][Debug] Collected 1 toolchains
[8/11/2023, 10:03:32 AM][Debug] Toolchain: selected 'Embedded Workbench 8.4 (RX)' (index 0)
[8/11/2023, 10:03:32 AM][Debug] 1 new toolchain(s) added
[8/11/2023, 10:03:32 AM][Debug] Loaded thrift workbench 'undefined'
[8/11/2023, 10:03:32 AM][Debug] Loaded extended project 'undefined'
[8/11/2023, 10:03:32 AM][Debug] Found 1 workspace(s) in the VS Code workspace
[8/11/2023, 10:03:32 AM][Debug] Workspace: selected 'VSC_IAR_TEST' (index 0)
[8/11/2023, 10:03:32 AM][Debug] Project: selected 'VSC_IAR_TEST' (index 0)
[8/11/2023, 10:03:32 AM][Debug] Configuration: selected 'Debug' (index 0)
[8/11/2023, 10:03:32 AM][Debug] Loaded extended project 'undefined'
[8/11/2023, 10:03:33 AM][Debug] Found 1 project(s) in the VS Code workspace

Here is the output from the C/C++ plugin with loggingLevel Debug as well if that could help as well.

loggingLevel: Debug
Custom configuration provider 'IAR Build' registered
cpptools version (TypeScript): 1.16.3
cpptools version (native): 1.16.3.0
Autocomplete is enabled.
Error squiggles are enabled if all header dependencies are resolved.
Hover is enabled.
IntelliSense Engine = default.
LSP: cpptools/queryCompilerDefaults (id: 1)
LSP: cpptools/queryCompilerDefaults (id: 2)
LSP: cpptools/didChangeCppProperties (id: 3)
LSP: cpptools/didChangeCppProperties (id: 4)
Code browsing service initialized
LSP: cpptools/pauseParsing
LSP: textDocument/didOpen: file:///c%3A/Users/lali/Documents/Projects/VSC_IAR_TEST/main.c
LSP: cpptools/textEditorSelectionChange
Attempting to get defaults from C++ compiler in "compilerPath" property: 'cl.exe'
LSP: cpptools/getInlayHints: file:///c%3A/Users/lali/Documents/Projects/VSC_IAR_TEST/main.c (id: 5)
LSP: cpptools/getDocumentSymbols: file:///c%3A/Users/lali/Documents/Projects/VSC_IAR_TEST/main.c (id: 6)
LSP: cpptools/getCodeActions: file:///c%3A/Users/lali/Documents/Projects/VSC_IAR_TEST/main.c (id: 7)
Attempting to get defaults from C compiler in "compilerPath" property: 'cl.exe'
  Folder: C:/PROGRAM FILES (X86)/MICROSOFT VISUAL STUDIO/2019/COMMUNITY/VC/TOOLS/MSVC/14.29.30133/ATLMFC/INCLUDE/* will be indexed
  Folder: C:/PROGRAM FILES (X86)/MICROSOFT VISUAL STUDIO/2019/COMMUNITY/VC/TOOLS/MSVC/14.29.30133/INCLUDE/* will be indexed
  Folder: C:/PROGRAM FILES (X86)/WINDOWS KITS/10/INCLUDE/10.0.22000.0/CPPWINRT/ will be indexed
  Folder: C:/PROGRAM FILES (X86)/WINDOWS KITS/10/INCLUDE/10.0.22000.0/SHARED/ will be indexed
  Folder: C:/PROGRAM FILES (X86)/WINDOWS KITS/10/INCLUDE/10.0.22000.0/UCRT/ will be indexed
  Folder: C:/PROGRAM FILES (X86)/WINDOWS KITS/10/INCLUDE/10.0.22000.0/UM/ will be indexed
  Folder: C:/PROGRAM FILES (X86)/WINDOWS KITS/10/INCLUDE/10.0.22000.0/WINRT/ will be indexed
  Folder: C:/USERS/LALI/DOCUMENTS/PROJECTS/VSC_IAR_TEST/ will be indexed
Discovering files...
  Processing folder (non-recursive): C:/PROGRAM FILES (X86)/MICROSOFT VISUAL STUDIO/2019/COMMUNITY/VC/TOOLS/MSVC/14.29.30133/ATLMFC/INCLUDE
LSP: cpptools/activeDocumentChange: file:///c%3A/Users/lali/Documents/Projects/VSC_IAR_TEST/main.c
  Processing folder (non-recursive): C:/PROGRAM FILES (X86)/MICROSOFT VISUAL STUDIO/2019/COMMUNITY/VC/TOOLS/MSVC/14.29.30133/INCLUDE
LSP: cpptools/getFoldingRanges: file:///c%3A/Users/lali/Documents/Projects/VSC_IAR_TEST/main.c (id: 8)
  Processing folder (recursive): C:/PROGRAM FILES (X86)/WINDOWS KITS/10/INCLUDE/10.0.22000.0/CPPWINRT/
  Processing folder (recursive): C:/PROGRAM FILES (X86)/WINDOWS KITS/10/INCLUDE/10.0.22000.0/SHARED/
  Processing folder (recursive): C:/PROGRAM FILES (X86)/WINDOWS KITS/10/INCLUDE/10.0.22000.0/UCRT/
  Processing folder (recursive): C:/PROGRAM FILES (X86)/WINDOWS KITS/10/INCLUDE/10.0.22000.0/UM/
  Processing folder (recursive): C:/PROGRAM FILES (X86)/WINDOWS KITS/10/INCLUDE/10.0.22000.0/WINRT/
  Processing folder (recursive): C:/USERS/LALI/DOCUMENTS/PROJECTS/VSC_IAR_TEST/
  Discovering files: 5003 file(s) processed
  1 file(s) removed from database
Done discovering files.
Populating include completion cache.
Parsing remaining files...
  Parsing: 0 files(s) processed
Done parsing remaining files.
LSP: cpptools/getSemanticTokens: file:///c%3A/Users/lali/Documents/Projects/VSC_IAR_TEST/main.c (id: 9)
LSP: cpptools/getCodeActions: file:///c%3A/Users/lali/Documents/Projects/VSC_IAR_TEST/main.c (id: 10)
LSP: cpptools/getCodeActions: file:///c%3A/Users/lali/Documents/Projects/VSC_IAR_TEST/main.c (id: 11)
  tag parsing file: C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\include\CodeAnalysis\sourceannotations.h
sending compilation args for C:\Users\lali\Documents\Projects\VSC_IAR_TEST\main.c
  include: C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO\2019\COMMUNITY\VC\TOOLS\MSVC\14.29.30133\INCLUDE
  include: C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO\2019\COMMUNITY\VC\TOOLS\MSVC\14.29.30133\ATLMFC\INCLUDE
  include: C:\PROGRAM FILES (X86)\WINDOWS KITS\10\INCLUDE\10.0.22000.0\UM
  include: C:\PROGRAM FILES (X86)\WINDOWS KITS\10\INCLUDE\10.0.22000.0\UCRT
  include: C:\PROGRAM FILES (X86)\WINDOWS KITS\10\INCLUDE\10.0.22000.0\SHARED
  include: C:\PROGRAM FILES (X86)\WINDOWS KITS\10\INCLUDE\10.0.22000.0\WINRT
  include: C:\PROGRAM FILES (X86)\WINDOWS KITS\10\INCLUDE\10.0.22000.0\CPPWINRT
  define: _DEBUG
  define: UNICODE
  define: _UNICODE
  stdver: ms_c17
  intelliSenseMode: windows-msvc-x64
Checking for syntax errors: C:\Users\lali\Documents\Projects\VSC_IAR_TEST\main.c
Queueing IntelliSense update for files in translation unit of: C:\Users\lali\Documents\Projects\VSC_IAR_TEST\main.c
Error squiggle count: 3
Error squiggles will be disabled in: file:///C%3A/Users/lali/Documents/Projects/VSC_IAR_TEST/main.c
Update IntelliSense time (sec): 1.726
LSP: cpptools/getCodeActions: file:///c%3A/Users/lali/Documents/Projects/VSC_IAR_TEST/main.c (id: 12)
LSP: cpptools/getFoldingRanges: file:///c%3A/Users/lali/Documents/Projects/VSC_IAR_TEST/main.c (id: 13)
LSP: cpptools/textEditorSelectionChange
LSP: cpptools/activeDocumentChange: file:///c%3A/Users/lali/Documents/Projects/VSC_IAR_TEST/main.c

@larlin
Copy link
Author

larlin commented Aug 11, 2023

One other thing I noticed is that in the mini test project I only have one build task:
image
And that one does not nothing it get stuck like this:
image

If I generate the task configuration in the mini test project that does not work I get this:

		{
			"type": "iar",
			"command": "build",
			"project": "${command:iar-config.project-file}",
			"config": "${command:iar-config.project-configuration}",
			"builder": "${command:iar-config.toolchain}/common/bin/iarbuild.exe",
			"label": "iar: Build Project",
			"argumentVariablesFile": "${command:iar-config.workspace-file}",
			"problemMatcher": [
				"$iar-cc",
				"$iar-linker"
			]
		}

In my real project I have two build tasks like this:
image
One of them works the other is the same as in the mini test project.

Not sure if it helps anything.

EDIT:

If I remove this line from the task in tasks.json:

"argumentVariablesFile": "${command:iar-config.workspace-file}",

The build task works. Not sure why that would change anything.

@jlonnberg
Copy link
Collaborator

Do you have cl.exe in path? If so, try to remove it and run VSC again and see if any improvements are made. I was able to reproduce the problem you described after adding cl.exe to my path.

@larlin
Copy link
Author

larlin commented Aug 11, 2023

Interesting find.

Not that I can see and if I try it in CMD it doesn't find it:

C:\>cl.exe
'cl.exe' is not recognized as an internal or external command,
operable program or batch file.

Neither does powershell from inside of VSC:

PS C:\> cl.exe
cl.exe : The term 'cl.exe' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ cl.exe
+ ~~~~~~
    + CategoryInfo          : ObjectNotFound: (cl.exe:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

Here are my paths for reference:

User PATH:

C:\Users\lali\AppData\Local\Microsoft\WindowsApps;
C:\Users\lali\.dotnet\tools;
C:\Users\lali\AppData\Local\atom\bin;
C:\Users\lali\AppData\Local\Programs\Azure Data Studio\bin;
%USERPROFILE%\.dotnet\tools;
C:\Users\lali\AppData\Local\Programs\Microsoft VS Code\bin

System PATH:

C:\Program Files\Eclipse Adoptium\jdk-8.0.382.5-hotspot\bin;
C:\Windows\system32;
C:\Windows;
C:\Windows\System32\Wbem;
C:\Windows\System32\WindowsPowerShell\v1.0\;
C:\Windows\System32\OpenSSH\;
C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;
C:\WINDOWS\system32;
C:\WINDOWS;
C:\WINDOWS\System32\Wbem;
C:\WINDOWS\System32\WindowsPowerShell\v1.0\;
C:\WINDOWS\System32\OpenSSH\;
C:\Program Files\dotnet\;
C:\Program Files (x86)\National Instruments\Shared\LabVIEW CLI;
C:\Program Files (x86)\IVI Foundation\VISA\WinNT\Bin\;
C:\Program Files\IVI Foundation\VISA\Win64\Bin\;
C:\Program Files (x86)\IVI Foundation\VISA\WinNT\Bin;
C:\Program Files (x86)\Windows Kits\10\Windows Performance Toolkit\;
C:\qp\qtools\mingw32\bin;
C:\qp\qtools\bin;
C:\Program Files\Git\cmd;
C:\Program Files\Intel\WiFi\bin\;
C:\Program Files\Common Files\Intel\WirelessCommon\

I wounder if in some way the context that runs the plugin has cl.exe in the path anyway.

@jlonnberg
Copy link
Collaborator

Is it possible for you to un-install VSC, zap any VSC cache and try again? I'm beggining to think that this might be a problem with the installation rather than our extension.

@larlin
Copy link
Author

larlin commented Aug 14, 2023

I have tried uninstall VSC and have changed name %appdata%\code.

This removed settings, but it seems like the installed plugins remained so I don't know if there is any other location for VSC data?

Any way this sadly did not improve anything, only slightly interesting was that when I opened the project directory I got notifications from some Cmake plugins that I had installed about setting up configurations. So I removed all Cmake plugins, deleted %appdata%\code and reinstalled again but no change in behavior.

This part of the "C/C++" plugin seems to be the one that finds the visual studio compiler:

Attempting to get defaults from C compiler in "compilerPath" property: 'cl.exe'
  Folder: C:/PROGRAM FILES (X86)/MICROSOFT VISUAL STUDIO/2019/COMMUNITY/VC/TOOLS/MSVC/14.29.30133/ATLMFC/INCLUDE/* will be indexed
  Folder: C:/PROGRAM FILES (X86)/MICROSOFT VISUAL STUDIO/2019/COMMUNITY/VC/TOOLS/MSVC/14.29.30133/INCLUDE/* will be indexed
  Folder: C:/PROGRAM FILES (X86)/WINDOWS KITS/10/INCLUDE/10.0.22000.0/CPPWINRT/ will be indexed
  Folder: C:/PROGRAM FILES (X86)/WINDOWS KITS/10/INCLUDE/10.0.22000.0/SHARED/ will be indexed
  Folder: C:/PROGRAM FILES (X86)/WINDOWS KITS/10/INCLUDE/10.0.22000.0/UCRT/ will be indexed
  Folder: C:/PROGRAM FILES (X86)/WINDOWS KITS/10/INCLUDE/10.0.22000.0/UM/ will be indexed
  Folder: C:/PROGRAM FILES (X86)/WINDOWS KITS/10/INCLUDE/10.0.22000.0/WINRT/ will be indexed
  Folder: C:/USERS/LALI/SOURCE/REPOS/BUMBLEBEE/MAIN_PRG/ will be indexed

Do you get the same in your "C/C++" log?

@jlonnberg
Copy link
Collaborator

I have the same but followed by
Attempting to get defaults from C++ compiler in "compilerPath" property: 'cl.exe'


Custom browse configuration received: {
  "browsePath": [
    "c:\\Users\\joakimlo\\Documents\\IAR Embedded Workbench\\rx\\examples\\RX starter kits\\RSKRX610\\Power_debugging_demo",
    "D:\\Devel\\EWRX\\StageWin64_17\\Debug\\rx\\inc",
    "D:\\Devel\\EWRX\\StageWin64_17\\Debug\\rx\\inc\\c",
    "c:\\users\\joakimlo\\documents\\iar embedded workbench\\rx\\examples\\rx starter kits\\rskrx610\\power_debugging_demo"
  ],
  "compilerPath": "",
  "standard": "c17",
  "windowsSdkVersion": "",
  "compilerArgsLegacy": []
}

@jlonnberg
Copy link
Collaborator

Let's go for the next logger... There is an output channel named IAR Config Generator which lists everyhing coupled to the intellisense. Can you please attach the output for that channel as well as the content of the build description file that is referenced in the output.

@larlin
Copy link
Author

larlin commented Aug 16, 2023

As you can see in the log I never get the "Custom browse configuration received".

My IAR Config Generator log is completely empty. Both in my real project and the mini test project.

@jlonnberg
Copy link
Collaborator

@larlin I think I've finally managed to figure out what is causing the problem; VSCode fails to create a folder named "iar-build" in AppData\Local\Temp for your user. As a WA, you can add the folder manually and we'll fix this in the next release!

@larlin
Copy link
Author

larlin commented Aug 22, 2023

That seems to have fixed the issue! I'm not sure I want to know how deep you had to dig to find that, good find!

Thanks a lot.

@jlonnberg
Copy link
Collaborator

We'll include a permanent fix in the next patch-release (I'll leave the issue open until then)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants