microsoft / vscode-cmake-tools

CMake integration in Visual Studio Code
https://marketplace.visualstudio.com/items?itemName=vector-of-bool.cmake-tools
MIT License
1.47k stars 454 forks source link

Debugger autodetection uses clang regex for gcc #4050

Open veimmone opened 2 months ago

veimmone commented 2 months ago

I don't have any experience in developing VS Code extensions so I don't even try to make a proper patch, but I found out that here:

https://github.com/microsoft/vscode-cmake-tools/blob/406216a5309d5d5997b8567c0fb98c04bbf563e2/src/debugger.ts#L219

the compilerPath.replace operation is using a clang-specific regex. In my local dist/main.js I replaced this line with:

miDebuggerPath = compilerPath.replace('gcc', 'gdb').replace('g++', 'gdb');

and got further on my bughunt. You might want to think if a similar regex as for clang.

(As a sidenote, it seems that when using a toolchain file with CMake, the CMAKE_<lang>_COMPILER variables don't necessarily end up in CMakeCache.txt so this method of auto-detection based on the cache fails to begin with...)

veimmone commented 2 months ago

Possibly related: https://github.com/microsoft/vscode-cmake-tools/issues/3908