microsoft / vscode-cpptools

Official repository for the Microsoft C/C++ extension for VS Code.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Go to Definition goes to a correct source file but locating at a wrong line.

HuandongNB opened this issue · comments

Environment

  • OS and Version: Windows 10 家庭中文版 22H2
  • VS Code Version: 1.88.0
  • C/C++ Extension Version: v1.19.9
  • If using SSH remote, specify OS of remote machine: No.

Bug Summary and Steps to Reproduce

Hi everyone
There is function named RTC_ClearWakeupReason and its definition is in HAL_RTC.c line 1014. RTC_ClearWakeupReason is called by some other functions in different source files. But if I click 'Go to Definition' of RTC_ClearWakeupReason in Mod_Sync.c and then I will go to HAL_RTC.c line 943. Acutally line 943 is not the place where the definition beginning.
However, if I click 'Go to Definition' of RTC_ClearWakeupReason in HAL_RTC.c and I will go to line 1014 correctly.

Configuration and Logs

c_cpp_properties.json

{
    "configurations": [
        {
            "name": "Win32",
            "includePath": [
                "C:/Keil_v5/ARM/ARMCLANG/**",
                "${workspaceFolder}/MCU_OM6626/SRC_Core/",
                "${workspaceFolder}/SRC_HAL_Includes/",
                "${workspaceFolder}/SRC_Global/",
                "${workspaceFolder}/SRC_Modules/",
                "${workspaceFolder}/SRC_External/",
                "${workspaceFolder}/SDK/OM6626_SDK/common/",
                "${workspaceFolder}/SDK/OM6626_SDK/components/crypto/",
                "${workspaceFolder}/SDK/OM6626_SDK/components/evt/",
                "${workspaceFolder}/SDK/OM6626_SDK/components/mbr/",
                "${workspaceFolder}/SDK/OM6626_SDK/components/pm/",
                "${workspaceFolder}/SDK/OM6626_SDK/components/shell/",
                "${workspaceFolder}/SDK/OM6626_SDK/components/trace/",
                "${workspaceFolder}/SDK/OM6626_SDK/components/unity/",
                "${workspaceFolder}/SDK/OM6626_SDK/components/nvds/",
                "${workspaceFolder}/SDK/OM6626_SDK/hal/CMSIS/Core/Include/",
                "${workspaceFolder}/SDK/OM6626_SDK/hal/CMSIS/Dsp/Include/",
                "${workspaceFolder}/SDK/OM6626_SDK/hal/CMSIS/Dsp/Include/dsp/",
                "${workspaceFolder}/SDK/OM6626_SDK/hal/CMSIS/NN/Include/",
                "${workspaceFolder}/SDK/OM6626_SDK/hal/device/common/",
                "${workspaceFolder}/SDK/OM6626_SDK/hal/device/include/",
                "${workspaceFolder}/SDK/OM6626_SDK/hal/driver/om6626/",
                "${workspaceFolder}/SDK/OM6626_SDK/hal/driver/include/",
                "${workspaceFolder}/SDK/OM6626_SDK/hal/driver/common/",
                "${workspaceFolder}/SDK/OM6626_SDK/include/",
                "${workspaceFolder}/SDK/OM6626_SDK/hal/device/om6626/rom_lib/current/config/",
                "${workspaceFolder}/UnitTest/",
                "${workspaceFolder}/UnitTest/Shell/inc/",
                "${workspaceFolder}/SRC_Utility/mbedtls-3.5.0/tests/include/alt-dummy",
                "${workspaceFolder}/SRC_Utility/mbedtls-3.5.0/include",
                "${workspaceFolder}/SRC_Utility/mbedtls-3.5.0/library",
                "${workspaceFolder}/SRC_Utility/",
            ],
            "defines": [
                "_DEBUG",
                "UNICODE",
                "_UNICODE",
                "BUILD_OM6256_ESL",
                "DOXYGEN",
                "CONFIG_LIB_PRESET_NO_BLE",
                "CONFIG_AUTOCONF_PRESET",
                "CONFIG_OM6626A",
                "BUILD_ESL",
                // "UNIT_TEST",
                "__ARMCC_VERSION=6190004",
                "__INT64_TYPE__=long long"
            ],
            "compilerPath": "",
            "cStandard": "c11",
            "cppStandard": "c++03",
            "intelliSenseMode": "windows-clang-arm"
        }
    ],
    "version": 4
}

c/c++ logging from Mod_sync.c jumping to HAL_RTC.c:
LSP: (received) cpptools/didChangeVisibleTextEditors
LSP: (invoked) cpptools/didChangeVisibleTextEditors
LSP: (received) cpptools/didChangeVisibleTextEditors
LSP: (invoked) cpptools/didChangeVisibleTextEditors
Intellisense update pending for: file:///d%3A/15_ESL_OM6626/03_ESL_OM6626_Project/SRC_Modules/MOD_Sync.c
LSP: (received) cpptools/getCodeActions: file:///d%3A/15_ESL_OM6626/03_ESL_OM6626_Project/SRC_Modules/MOD_Sync.c (id: 503)
LSP: (invoked) cpptools/getCodeActions: file:///d%3A/15_ESL_OM6626/03_ESL_OM6626_Project/SRC_Modules/MOD_Sync.c (id: 503)
LSP: Sending response (id: 503)
LSP: (received) cpptools/didChangeTextEditorSelection
LSP: (invoked) cpptools/didChangeTextEditorSelection
LSP: (received) cpptools/didChangeActiveEditor: file:///d%3A/15_ESL_OM6626/03_ESL_OM6626_Project/SRC_Modules/MOD_Sync.c
LSP: (invoked) cpptools/didChangeActiveEditor: file:///d%3A/15_ESL_OM6626/03_ESL_OM6626_Project/SRC_Modules/MOD_Sync.c
LSP: (received) textDocument/documentHighlight: file:///d%3A/15_ESL_OM6626/03_ESL_OM6626_Project/SRC_Modules/MOD_Sync.c (id: 504)
LSP: (invoked) textDocument/documentHighlight: file:///d%3A/15_ESL_OM6626/03_ESL_OM6626_Project/SRC_Modules/MOD_Sync.c (id: 504)
LSP: Sending response (id: 504)
LSP: (received) cpptools/getCodeActions: file:///d%3A/15_ESL_OM6626/03_ESL_OM6626_Project/SRC_Modules/MOD_Sync.c (id: 505)
LSP: (invoked) cpptools/getCodeActions: file:///d%3A/15_ESL_OM6626/03_ESL_OM6626_Project/SRC_Modules/MOD_Sync.c (id: 505)
LSP: Sending response (id: 505)
LSP: (received) cpptools/getFoldingRanges: file:///d%3A/15_ESL_OM6626/03_ESL_OM6626_Project/SRC_Modules/MOD_Sync.c (id: 506)
LSP: (invoked) cpptools/getFoldingRanges: file:///d%3A/15_ESL_OM6626/03_ESL_OM6626_Project/SRC_Modules/MOD_Sync.c (id: 506)
LSP: (received) cpptools/getDocumentSymbols: file:///d%3A/15_ESL_OM6626/03_ESL_OM6626_Project/SRC_Modules/MOD_Sync.c (id: 507)
LSP: (invoked) cpptools/getDocumentSymbols: file:///d%3A/15_ESL_OM6626/03_ESL_OM6626_Project/SRC_Modules/MOD_Sync.c (id: 507)
LSP: Sending response (id: 507)
LSP: Sending response (id: 506)
IntelliSense update scheduled and TU acquisition started for: file:///d%3A/15_ESL_OM6626/03_ESL_OM6626_Project/SRC_Modules/MOD_Sync.c
Update IntelliSense time (sec): 0.236
LSP: (received) cpptools/getFoldingRanges: file:///d%3A/15_ESL_OM6626/03_ESL_OM6626_Project/SRC_Modules/MOD_Sync.c (id: 508)
LSP: (invoked) cpptools/getFoldingRanges: file:///d%3A/15_ESL_OM6626/03_ESL_OM6626_Project/SRC_Modules/MOD_Sync.c (id: 508)
LSP: Sending response (id: 508)
LSP: (received) cpptools/getDocumentSymbols: file:///d%3A/15_ESL_OM6626/03_ESL_OM6626_Project/SRC_Modules/MOD_Sync.c (id: 509)
LSP: (invoked) cpptools/getDocumentSymbols: file:///d%3A/15_ESL_OM6626/03_ESL_OM6626_Project/SRC_Modules/MOD_Sync.c (id: 509)
LSP: Sending response (id: 509)
LSP: (received) textDocument/hover: file:///d%3A/15_ESL_OM6626/03_ESL_OM6626_Project/SRC_Modules/MOD_Sync.c (id: 510)
LSP: (invoked) textDocument/hover: file:///d%3A/15_ESL_OM6626/03_ESL_OM6626_Project/SRC_Modules/MOD_Sync.c (id: 510)
LSP: Sending response (id: 510)
LSP: (received) textDocument/definition: file:///d%3A/15_ESL_OM6626/03_ESL_OM6626_Project/SRC_Modules/MOD_Sync.c (id: 511)
LSP: (invoked) textDocument/definition: file:///d%3A/15_ESL_OM6626/03_ESL_OM6626_Project/SRC_Modules/MOD_Sync.c (id: 511)
LSP: Sending response (id: 511)
LSP: (received) textDocument/documentHighlight: file:///d%3A/15_ESL_OM6626/03_ESL_OM6626_Project/SRC_Modules/MOD_Sync.c (id: 512)
LSP: (invoked) textDocument/documentHighlight: file:///d%3A/15_ESL_OM6626/03_ESL_OM6626_Project/SRC_Modules/MOD_Sync.c (id: 512)
LSP: Sending response (id: 512)
LSP: (received) cpptools/didChangeTextEditorSelection
LSP: (invoked) cpptools/didChangeTextEditorSelection
LSP: (received) textDocument/definition: file:///d%3A/15_ESL_OM6626/03_ESL_OM6626_Project/SRC_Modules/MOD_Sync.c (id: 513)
LSP: (invoked) textDocument/definition: file:///d%3A/15_ESL_OM6626/03_ESL_OM6626_Project/SRC_Modules/MOD_Sync.c (id: 513)
LSP: Sending response (id: 513)
LSP: (received) cpptools/didChangeVisibleTextEditors
LSP: (invoked) cpptools/didChangeVisibleTextEditors
LSP: (received) textDocument/documentHighlight: file:///d%3A/15_ESL_OM6626/03_ESL_OM6626_Project/SRC_Modules/MOD_Sync.c (id: 514)
LSP: (invoked) textDocument/documentHighlight: file:///d%3A/15_ESL_OM6626/03_ESL_OM6626_Project/SRC_Modules/MOD_Sync.c (id: 514)
LSP: $/cancelRequest (textDocument/documentHighlight, id: 514)
LSP: (received) cpptools/didChangeVisibleTextEditors
LSP: (received) cpptools/didChangeActiveEditor: file:///d%3A/15_ESL_OM6626/03_ESL_OM6626_Project/MCU_OM6626/SRC_HAL/HAL_RTC.c
LSP: (received) cpptools/getCodeActions: file:///d%3A/15_ESL_OM6626/03_ESL_OM6626_Project/MCU_OM6626/SRC_HAL/HAL_RTC.c (id: 515)
LSP: (received) cpptools/didChangeTextEditorSelection
LSP: (invoked) cpptools/didChangeVisibleTextEditors
Intellisense update pending for: file:///d%3A/15_ESL_OM6626/03_ESL_OM6626_Project/MCU_OM6626/SRC_HAL/HAL_RTC.c
LSP: (invoked) cpptools/didChangeActiveEditor: file:///d%3A/15_ESL_OM6626/03_ESL_OM6626_Project/MCU_OM6626/SRC_HAL/HAL_RTC.c
LSP: (invoked) cpptools/getCodeActions: file:///d%3A/15_ESL_OM6626/03_ESL_OM6626_Project/MCU_OM6626/SRC_HAL/HAL_RTC.c (id: 515)
LSP: Sending response (id: 515)
LSP: (invoked) cpptools/didChangeTextEditorSelection
IntelliSense update scheduled and TU acquisition started for: file:///d%3A/15_ESL_OM6626/03_ESL_OM6626_Project/MCU_OM6626/SRC_HAL/HAL_RTC.c
LSP: (received) cpptools/getCodeActions: file:///d%3A/15_ESL_OM6626/03_ESL_OM6626_Project/MCU_OM6626/SRC_HAL/HAL_RTC.c (id: 516)
LSP: (invoked) cpptools/getCodeActions: file:///d%3A/15_ESL_OM6626/03_ESL_OM6626_Project/MCU_OM6626/SRC_HAL/HAL_RTC.c (id: 516)
LSP: Sending response (id: 516)
Update IntelliSense time (sec): 0.085
LSP: (received) cpptools/getFoldingRanges: file:///d%3A/15_ESL_OM6626/03_ESL_OM6626_Project/MCU_OM6626/SRC_HAL/HAL_RTC.c (id: 517)
LSP: (invoked) cpptools/getFoldingRanges: file:///d%3A/15_ESL_OM6626/03_ESL_OM6626_Project/MCU_OM6626/SRC_HAL/HAL_RTC.c (id: 517)
LSP: (received) cpptools/getDocumentSymbols: file:///d%3A/15_ESL_OM6626/03_ESL_OM6626_Project/MCU_OM6626/SRC_HAL/HAL_RTC.c (id: 518)
LSP: (invoked) cpptools/getDocumentSymbols: file:///d%3A/15_ESL_OM6626/03_ESL_OM6626_Project/MCU_OM6626/SRC_HAL/HAL_RTC.c (id: 518)
LSP: Sending response (id: 518)
LSP: Sending response (id: 517)
LSP: (received) cpptools/getDocumentSymbols: file:///d%3A/15_ESL_OM6626/03_ESL_OM6626_Project/MCU_OM6626/SRC_HAL/HAL_RTC.c (id: 519)
LSP: (invoked) cpptools/getDocumentSymbols: file:///d%3A/15_ESL_OM6626/03_ESL_OM6626_Project/MCU_OM6626/SRC_HAL/HAL_RTC.c (id: 519)
LSP: Sending response (id: 519)

c/c++ logging only in HAL_RTC.c:
LSP: (received) textDocument/hover: file:///d%3A/15_ESL_OM6626/03_ESL_OM6626_Project/MCU_OM6626/SRC_HAL/HAL_RTC.c (id: 591)
LSP: (invoked) textDocument/hover: file:///d%3A/15_ESL_OM6626/03_ESL_OM6626_Project/MCU_OM6626/SRC_HAL/HAL_RTC.c (id: 591)
LSP: Sending response (id: 591)
LSP: (received) cpptools/didChangeActiveEditor: file:///d%3A/15_ESL_OM6626/03_ESL_OM6626_Project/MCU_OM6626/SRC_HAL/HAL_RTC.c
LSP: (invoked) cpptools/didChangeActiveEditor: file:///d%3A/15_ESL_OM6626/03_ESL_OM6626_Project/MCU_OM6626/SRC_HAL/HAL_RTC.c
LSP: (received) textDocument/documentHighlight: file:///d%3A/15_ESL_OM6626/03_ESL_OM6626_Project/MCU_OM6626/SRC_HAL/HAL_RTC.c (id: 592)
LSP: (invoked) textDocument/documentHighlight: file:///d%3A/15_ESL_OM6626/03_ESL_OM6626_Project/MCU_OM6626/SRC_HAL/HAL_RTC.c (id: 592)
LSP: Sending response (id: 592)
LSP: (received) cpptools/didChangeTextEditorSelection
LSP: (invoked) cpptools/didChangeTextEditorSelection
LSP: (received) cpptools/getCodeActions: file:///d%3A/15_ESL_OM6626/03_ESL_OM6626_Project/MCU_OM6626/SRC_HAL/HAL_RTC.c (id: 593)
LSP: (invoked) cpptools/getCodeActions: file:///d%3A/15_ESL_OM6626/03_ESL_OM6626_Project/MCU_OM6626/SRC_HAL/HAL_RTC.c (id: 593)
LSP: Sending response (id: 593)
LSP: (received) textDocument/hover: file:///d%3A/15_ESL_OM6626/03_ESL_OM6626_Project/MCU_OM6626/SRC_HAL/HAL_RTC.c (id: 594)
LSP: (invoked) textDocument/hover: file:///d%3A/15_ESL_OM6626/03_ESL_OM6626_Project/MCU_OM6626/SRC_HAL/HAL_RTC.c (id: 594)
LSP: Sending response (id: 594)
LSP: (received) textDocument/definition: file:///d%3A/15_ESL_OM6626/03_ESL_OM6626_Project/MCU_OM6626/SRC_HAL/HAL_RTC.c (id: 595)
LSP: (invoked) textDocument/definition: file:///d%3A/15_ESL_OM6626/03_ESL_OM6626_Project/MCU_OM6626/SRC_HAL/HAL_RTC.c (id: 595)
LSP: Sending response (id: 595)
LSP: (received) textDocument/definition: file:///d%3A/15_ESL_OM6626/03_ESL_OM6626_Project/MCU_OM6626/SRC_HAL/HAL_RTC.c (id: 596)
LSP: (invoked) textDocument/definition: file:///d%3A/15_ESL_OM6626/03_ESL_OM6626_Project/MCU_OM6626/SRC_HAL/HAL_RTC.c (id: 596)
LSP: Sending response (id: 596)
LSP: (received) cpptools/didChangeTextEditorSelection
LSP: (invoked) cpptools/didChangeTextEditorSelection
LSP: (received) cpptools/getCodeActions: file:///d%3A/15_ESL_OM6626/03_ESL_OM6626_Project/MCU_OM6626/SRC_HAL/HAL_RTC.c (id: 597)
LSP: (invoked) cpptools/getCodeActions: file:///d%3A/15_ESL_OM6626/03_ESL_OM6626_Project/MCU_OM6626/SRC_HAL/HAL_RTC.c (id: 597)
LSP: Sending response (id: 597)

Other Extensions

No response

Additional context

No response

@HuandongNB When you do Go to Def in Mod_Sync.c it'll have to query the database for the location since the definition is not in that TU, but if you're in HAL_RTC.c then the TU has the definition so it doesn't need to query the database, so the bug is caused by the definition in the database having the wrong location. You might fix it by doing a Reset IntelliSense Database command, or check the Outline view and see if the definition symbol is incorrect there. If so, if a macro is used in the definition, you may need to add the macro to a cpp.hint file. If you can provide a code sample of the function definition that repros the issue we could investigate more.

It works well after doing a Reset IntelliSense Database.
Thanks for the help.