microsoft / vscode-cpptools

Official repository for the Microsoft C/C++ extension for VS Code.
Other
5.51k stars 1.55k forks source link

C/C++ not scan my code folder instead only scan my Visual Studio folder #12784

Open dahai-zhou opened 1 week ago

dahai-zhou commented 1 week ago

Environment

Bug Summary and Steps to Reproduce

When I use "Go To Definition" in .c, it always jump to .h, not the function code in .c. After debug, I found the root cause is C/C++ not scan my code folder instead only scan my Visual Studio folder, here is the log for cpptools/resetDatabase

LSP: (received) cpptools/resetDatabase LSP: (invoked) cpptools/resetDatabase Creating/updating compiler cache data tables (previously: 0) Code browsing service initialized Discovering files... Populating file name cache... Done populating filename cache. Elapsed time: 0 ms Processing folder (recursive): C:\PROGRAM FILES (X86)\WINDOWS KITS\10\INCLUDE\10.0.19041.0\SHARED\ Processing folder (recursive): C:\PROGRAM FILES (X86)\WINDOWS KITS\10\INCLUDE\10.0.19041.0\UM\ Processing folder (recursive): C:\PROGRAM FILES (X86)\WINDOWS KITS\10\INCLUDE\10.0.19041.0\CPPWINRT\ Processing folder (recursive): C:\PROGRAM FILES (X86)\WINDOWS KITS\10\INCLUDE\10.0.19041.0\UCRT\ Processing folder (recursive): C:\PROGRAM FILES (X86)\WINDOWS KITS\10\INCLUDE\10.0.19041.0\WINRT\ Processing folder (non-recursive): C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO\2019\ENTERPRISE\VC\TOOLS\MSVC\14.29.30133\ATLMFC\INCLUDE Processing folder (non-recursive): C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO\2019\ENTERPRISE\VC\TOOLS\MSVC\14.29.30133\INCLUDE Discovering files: 4871 file(s) processed 0 file(s) removed from database Done discovering files. Populating include completion cache. Parsing remaining files... Parsing: 0 files(s) processed Done parsing remaining files. Database safe to open.

Actually I have a code workspace like this: image

It has nothing to do with the .vscode/c_cpp_properties.json because I tried to delete it. I put the same code folder from remote SSH server (Windows) to local Windows system, the issue disappeared. Uninstall VS Code Server and install it again (so re-install the C/C++ extension), issue still happen. Uninstall VS Code on my local computer and reinstall it again, issue still happen.

I suspect it has something to do with my remote server, like network or something, but do not know how to debug further.

Configuration and Logs

-------- Diagnostics - 9/30/2024, 2:39:01 PM
Version: 1.22.6
Current Configuration:
{
    "name": "Win32",
    "includePath": [
        "d:/BHS-BIOS/**"
    ],
    "defines": [
        "_DEBUG",
        "UNICODE",
        "_UNICODE",
        "MAX_SOCKET"
    ],
    "forcedInclude": [
        "MdePkg/Include/X64/ProcessorBind.h",
        "MdePkg/Include/Base.h",
        "MdePkg/Include/Uefi.h"
    ],
    "compilerPathIsExplicit": false,
    "cStandardIsExplicit": false,
    "cppStandardIsExplicit": false,
    "intelliSenseModeIsExplicit": false,
    "macFrameworkPath": [],
    "windowsSdkVersion": "10.0.19041.0",
    "cStandard": "c17",
    "cppStandard": "c++17",
    "intelliSenseMode": "windows-msvc-x64",
    "mergeConfigurations": false,
    "compilerPath": "C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Enterprise\\VC\\Tools\\MSVC\\14.29.30133\\bin\\Hostx64\\x64\\cl.exe",
    "browse": {
        "path": [
            "d:/BHS-BIOS/**",
            "${workspaceFolder}"
        ],
        "limitSymbolsToIncludedHeaders": true
    }
}
Modified Settings:
{
    "C_Cpp.dimInactiveRegions": false,
    "C_Cpp.loggingLevel": "Debug"
}
Additional Tracked Settings:
{
    "editorTabSize": 2,
    "editorInsertSpaces": true,
    "editorAutoClosingBrackets": "languageDefined",
    "filesEncoding": "utf8",
    "filesAssociations": {
        "*.sd": "edk2_vfr",
        "*.h": "c"
    },
    "filesExclude": {
        "**/.git": true,
        "**/.svn": true,
        "**/.hg": true,
        "**/CVS": true,
        "**/.DS_Store": true,
        "**/Thumbs.db": true
    },
    "filesAutoSaveAfterDelay": false,
    "editorInlayHintsEnabled": true,
    "editorParameterHintsEnabled": true,
    "searchExclude": {
        "**/node_modules": true,
        "**/bower_components": true,
        "**/*.code-search": true,
        "/Original": true,
        "**/DEBUG_VS20??/FV": true,
        "**/DEBUG_VS20??/IA32": true,
        "**/DEBUG_VS20??/X64": true,
        "**/RELEASE_VS20??/FV": true,
        "**/RELEASE_VS20??/IA32": true,
        "**/RELEASE_VS20??/X64": true,
        "*.rom": true,
        "*.bin": true,
        "*.fd": true,
        "*.zip": true,
        "*.exe": true,
        "Doc": true
    },
    "workbenchSettingsEditor": "ui"
}
cpptools version (native): 1.22.6.0
Current database path: C:\USERS\ADMINISTRATOR\APPDATA\LOCAL\MICROSOFT\VSCODE-CPPTOOLS\245AD5896190AFBE2AD35ECEDAFB20F9\.BROWSE.VC.DB
No active translation units.

------- Workspace parsing diagnostics -------
Number of files discovered (not excluded): 4871

Other Extensions

Disable all others, still happen.

Additional context

Add #1: image The Extension UI is loading forever, and the status is not synced with SSH server. Maybe this could help.

Here is installing log from Server output: 2024-09-30 16:20:16.099 [info] Downloaded extension to file:///c%3A/Users/Administrator/.vscode-server/data/CachedExtensionVSIXs/781492cc-f7b8-4f25-ad22-4dc571903101 2024-09-30 16:20:16.105 [info] Installing extension: ms-python.python {"installOnlyNewlyAddedFromExtensionPack":false,"isApplicationScoped":false,"profileLocation":{"$mid":1,"fsPath":"c:\Users\Administrator\.vscode-server\extensions\extensions.json","_sep":1,"external":"file:///c%3A/Users/Administrator/.vscode-server/extensions/extensions.json","path":"/C:/Users/Administrator/.vscode-server/extensions/extensions.json","scheme":"file"},"productVersion":{"version":"1.93.1","date":"2024-09-11T17:20:05.685Z"}} 2024-09-30 16:21:28.939 [info] Downloaded extension to file:///c%3A/Users/Administrator/.vscode-server/data/CachedExtensionVSIXs/958349ab-bfa0-4054-9a0c-3747c1dd7d7c 2024-09-30 16:21:28.977 [info] Installing extension: ms-vscode.cpptools {"installOnlyNewlyAddedFromExtensionPack":false,"isApplicationScoped":false,"profileLocation":{"$mid":1,"fsPath":"c:\Users\Administrator\.vscode-server\extensions\extensions.json","_sep":1,"external":"file:///c%3A/Users/Administrator/.vscode-server/extensions/extensions.json","path":"/C:/Users/Administrator/.vscode-server/extensions/extensions.json","scheme":"file"},"productVersion":{"version":"1.93.1","date":"2024-09-11T17:20:05.685Z"}} 2024-09-30 16:21:30.928 [info] Extracted extension to file:///c%3A/Users/Administrator/.vscode-server/extensions/ms-vscode.cpptools-1.22.6: ms-vscode.cpptools 2024-09-30 16:21:30.941 [info] Renamed to c:\Users\Administrator.vscode-server\extensions\ms-vscode.cpptools-1.22.6 2024-09-30 16:21:30.987 [info] Extension installed successfully: ms-vscode.cpptools file:///c%3A/Users/Administrator/.vscode-server/extensions/extensions.json 2024-09-30 16:24:12.859 [info] New EH opened, aborting shutdown

Add #2: Some error code in Pty Host (Remote) 2024-09-30 16:19:15.125 [warning] Shell integration cannot be enabled for executable "C:\Windows\System32\cmd.exe" and args /c (powershell -Command "$ProgressPreference = 'SilentlyContinue'; (Invoke-WebRequest -TimeoutSec 7 -Uri http://metadata.google.internal/computeMetadata/v1/instance/id -UseBasicParsing -Headers @{\"Metadata-Flavor\"=\"Google\"}).Content") & exit /b 0

and also in Pty Host 2024-09-30 16:19:06.148 [warning] Shell integration cannot be enabled for executable "C:\Windows\System32\cmd.exe" and args /c (type "C:\Users\Admin\AppData\Local\Temp\vscode-linux-multi-line-command-XX.XX.XX.115-512463630.sh" | "C:\Windows\System32\OpenSSH\ssh.exe" -T -D 60576 "XX.XX.XX.115" powershell) & exit /b 0 Maybe this could help.

sean-mcmanus commented 5 days ago

I don't know why the workspace folder wouldn't be processed, i.e. with "Processing folder (recursive)" logging.

Do you have any "Folder: " logging when you generate the c_cpp_properties.json?

dahai-zhou commented 1 day ago

Do you have any "Folder: " logging when you generate the c_cpp_properties.json?

Could you let me know how to check the logging? Or any more log file you want?

dahai-zhou commented 1 day ago

Do you have any "Folder: " logging when you generate the c_cpp_properties.json?

Could you let me know how to check the logging? Or any more log file you want?

Here is the log when I input "C_Cpp.ConfigurationEditUI" after delete the c_cpp_properties.json: Intellisense update pending for: file:///d%3A/BHS-BIOS/ByteDanceUefiPkg/ByteDanceUefiPkg/Include/ByteDebug.h Shutting down IntelliSense server: D:\BHS-BIOS\ByteDanceUefiPkg\ByteDanceUefiPkg\Include\ByteDebug.h LSP: (received) cpptools/didChangeVisibleTextEditors LSP: (received) cpptools/didChangeCppProperties (id: 23) Attempting to get defaults from C++ compiler in "compilerPath" property: 'cl.exe' Attempting to get defaults from C compiler in "compilerPath" property: 'cl.exe' Folder: C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO\2019\ENTERPRISE\VC\TOOLS\MSVC\14.29.30133\ATLMFC\INCLUDE\* will be indexed Folder: C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO\2019\ENTERPRISE\VC\TOOLS\MSVC\14.29.30133\INCLUDE\* will be indexed Folder: C:\PROGRAM FILES (X86)\WINDOWS KITS\10\INCLUDE\10.0.19041.0\CPPWINRT\ will be indexed Folder: C:\PROGRAM FILES (X86)\WINDOWS KITS\10\INCLUDE\10.0.19041.0\SHARED\ will be indexed Folder: C:\PROGRAM FILES (X86)\WINDOWS KITS\10\INCLUDE\10.0.19041.0\UCRT\ will be indexed Folder: C:\PROGRAM FILES (X86)\WINDOWS KITS\10\INCLUDE\10.0.19041.0\UM\ will be indexed Folder: C:\PROGRAM FILES (X86)\WINDOWS KITS\10\INCLUDE\10.0.19041.0\WINRT\ will be indexed LSP: Sending response (id: 22) LSP: (invoked) cpptools/didChangeVisibleTextEditors LSP: (invoked) cpptools/didChangeCppProperties (id: 23) LSP: Sending response (id: 23) LSP: (received) cpptools/didChangeCppProperties (id: 24) LSP: (invoked) cpptools/didChangeCppProperties (id: 24) LSP: Sending response (id: 24)

dahai-zhou commented 7 hours ago

@sean-mcmanus