Vscode-cpptools: Goto Definition works only for intelliSenseEngine = “Tag Parser” for vscode 1.36 in ubuntu 16.04 VM

Created on 9 Jul 2019  ·  6Comments  ·  Source: microsoft/vscode-cpptools

Type: LanguageService

Describe the bug

OS and Version: Ubuntu VM 16.04 amd64 on windows 7 host (gcc/g++ 5.4.0
VS Code Version: 1.36.0
C/C++ Extension Version: 0.24.0
Other extensions you installed (and if the issue persists after disabling them): This is the only extension I use

A clear and concise description of what the bug is.
When I use Goto Definition over a function the vscode goes to the relevant declaration instead.

The c_cpp_properties.json file I use it the following:

{

    "configurations": [
        {
            "name": "Linux",
            "intelliSenseMode":"gcc-x64",
            "compilerPath": "/usr/bin/gcc",
            "includePath": [ "${workspaceFolder}/include"],
            "cppStandard": "c++14",
            "browse": {
                "path": [ "${workspaceFolder}" ],
                "limitSymbolsToIncludedHeaders": true,
                "databaseFilename": ""
            }

        }
    ],
    "version": 4
}

while the settings file is the following :

{
    "C_Cpp.intelliSenseEngine" : "Default"
}

However when I change the "C_Cpp.intelliSenseEngine" : "Tag Parser"the goto definition works fine but Tag Parser uses use the "fuzzy" IntelliSense engine which is not context aware.
I also added the "C_Cpp.intelliSenseEngineFallback": "Disabled"in the settings file but nothing changed.

To Reproduce

It happens to all functions accessed via arrow operator and the non void functions accessed via the arrow operator.

Expected behavior
Goto Definition should work for "C_Cpp.intelliSenseEngine" : "Default" as well.

Additional context
The developen tools produced no error logs when Goto Definition was not working properly.
The extension log I got is the following :


[2019-07-09 11:33:14.360] [exthost] [info] extension host started
[2019-07-09 11:33:14.444] [exthost] [info] ExtensionService#_doActivateExtension ms-vscode.cpptools {"startup":false,"activationEvent":"onLanguage:cpp"}
[2019-07-09 11:33:14.445] [exthost] [info] ExtensionService#loadCommonJSModule /home/dkli/.vscode/extensions/ms-vscode.cpptools-0.24.0/dist/main
[2019-07-09 11:33:14.647] [exthost] [info] ExtensionService#_doActivateExtension vscode.debug-auto-launch {"startup":true,"activationEvent":"*"}
[2019-07-09 11:33:14.647] [exthost] [info] ExtensionService#loadCommonJSModule /usr/share/code/resources/app/extensions/debug-auto-launch/dist/extension
[2019-07-09 11:33:14.652] [exthost] [info] ExtensionService#_doActivateExtension vscode.emmet {"startup":true,"activationEvent":"*"}
[2019-07-09 11:33:14.652] [exthost] [info] ExtensionService#loadCommonJSModule /usr/share/code/resources/app/extensions/emmet/dist/extension
[2019-07-09 11:33:14.679] [exthost] [info] ExtensionService#_doActivateExtension vscode.git {"startup":true,"activationEvent":"*"}
[2019-07-09 11:33:14.686] [exthost] [info] ExtensionService#loadCommonJSModule /usr/share/code/resources/app/extensions/git/dist/main
[2019-07-09 11:33:14.781] [exthost] [info] ExtensionService#_doActivateExtension vscode.merge-conflict {"startup":true,"activationEvent":"*"}
[2019-07-09 11:33:14.781] [exthost] [info] ExtensionService#loadCommonJSModule /usr/share/code/resources/app/extensions/merge-conflict/dist/extension
[2019-07-09 11:33:15.015] [exthost] [info] eager extensions activated
[2019-07-09 11:33:16.108] [exthost] [info] ExtensionService#_doActivateExtension vscode.configuration-editing {"startup":false,"activationEvent":"onLanguage:json"}
[2019-07-09 11:33:16.108] [exthost] [info] ExtensionService#loadCommonJSModule /usr/share/code/resources/app/extensions/configuration-editing/dist/extension
[2019-07-09 11:33:16.112] [exthost] [info] ExtensionService#_doActivateExtension vscode.extension-editing {"startup":false,"activationEvent":"onLanguage:json"}
[2019-07-09 11:33:16.112] [exthost] [info] ExtensionService#loadCommonJSModule /usr/share/code/resources/app/extensions/extension-editing/dist/extension
[2019-07-09 11:33:16.151] [exthost] [info] ExtensionService#_doActivateExtension vscode.json-language-features {"startup":false,"activationEvent":"onLanguage:json"}
[2019-07-09 11:33:16.151] [exthost] [info] ExtensionService#loadCommonJSModule /usr/share/code/resources/app/extensions/json-language-features/client/dist/jsonMain
[2019-07-09 11:33:16.179] [exthost] [info] ExtensionService#_doActivateExtension vscode.npm {"startup":false,"activationEvent":"onLanguage:json"}
[2019-07-09 11:33:16.179] [exthost] [info] ExtensionService#loadCommonJSModule /usr/share/code/resources/app/extensions/npm/dist/main

Can you help me solve this ?

Go to Definition Language Service bug fixed (release pending) quick fix regression verified

Most helpful comment

All 6 comments

We need more repro info. Are you able to provide any sample code that exhibits the Go to Def problem? Does the problem only occur with certain types of C++ constructs? It's possible the IntelliSense type checking is failing for some reason (and we should probably add better logging to make this easier to determine). Are you able to use the Install Another Version... feature to check if 0.23.1 is working for you? We made a change in 0.24.0 that improved the performance of Go to Def.

Hi again
I installed the 0.23.1 version of the extension and the behavior was the same as with the latest.
Unfortunately the project is a private one and I'm not allowed to provide any sample of code.
Apart from that the vast majority of the functions do not work with go to definition so I can't find any pattern regarding specific structs.
I'll try to provide a simple sample that has this behavior but is there anything else I can do to get any more logs that could help you more ?

The simplest code I can provide that does not work is the following :
The main.cpp is :

#include "measurement.h"
#include "iostream"

using namespace std;
using namespace MyProject;

int main()
    {
        try
        {
                Measurement measurement;
        measurement.start();
        }
        catch(const std::exception& e)
        {
            std::cerr << e.what() << '\n';
        }
    }

The measurement.h is

#ifndef INCLUDE_MEASURE_H_
#define INCLUDE_MEASURE_H_

#include "cstring"
#include "sys/times.h"
#include "sys/vtimes.h"

using namespace std;

namespace MyProject
{
class Measurement
{
public:
    Measurement(){}
    void start();

private:
clock_t _lastCPU, _lastSysCPU, _lastUserCPU;
int _numProcessors;
};
}
#endif 

The measurement.cpp is

#include "measurement.h"
#include "iomanip"
using namespace MyProject;

void Measurement::start()
{

    FILE* file;
    struct tms timeSample;
    char line[128];

    _lastCPU = times(&timeSample);
    _lastSysCPU = timeSample.tms_stime;
    _lastUserCPU = timeSample.tms_utime;

    file = fopen("/proc/cpuinfo", "r");
    _numProcessors = 0;
    while(fgets(line, 128, file) != NULL){
        if (strncmp(line, "processor", 9) == 0) _numProcessors++;
    }
    fclose(file); 
}

The project folder contains a src folder where main.cpp and measurement.cpp exist and an include folder where measurement.h resides.

When I pressed go to definition on start() function in main it redirected me at the declaration in measurement.h file.
When I changed the intelliSenseEngine into "Tag Parser" the redirection end up correctly in the measurement.cpp file and the definition of start() function.

I also added "C_Cpp.loggingLevel": "Debug" at settings file and here are the logs when I pressed go to definition on start() function

textDocument/documentHighlight: 27
cpptools/activeDocumentChange
cpptools/textEditorSelectionChange
textDocument/codeAction: 28
idle loop: reparsing the active document
Checking for syntax errors: file:///home/user/Vs_Code/src/main.cpp
queue_update_intellisense for files in tu of: /home/user/Vs_Code/src/main.cpp
errorSquiggles count: 0
errorSquiggles count: 0
cpptools/activeDocumentChange
cpptools/textEditorSelectionChange
idle loop: reparsing the active document
Checking for syntax errors: file:///home/user/Vs_Code/src/main.cpp
queue_update_intellisense for files in tu of: /home/user/Vs_Code/src/main.cpp
textDocument/hover: 29
errorSquiggles count: 0
errorSquiggles count: 0
textDocument/hover: 30
textDocument/definition: 31
textDocument/codeAction: 32
cpptools/activeDocumentChange
cpptools/textEditorSelectionChange
cpptools/textEditorSelectionChange
textDocument/codeAction: 33
idle loop: reparsing the active document
Checking for syntax errors: file:///home/user/Vs_Code/include/measurement.h
queue_update_intellisense for files in tu of: /home/user/Vs_Code/src/main.cpp
errorSquiggles count: 0
errorSquiggles count: 0

Thanks a lot for the repro. It appears to be a bug with our IntelliSense type checking.

I tried the 0.25 version and the Goto Definition worked fine.
Thanks for the support.

Was this page helpful?
0 / 5 - 0 ratings