microsoft / microsoft/vscode-cpptools
Wrong debugging command on MSYS2 terminal
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 6.2k
- Forks
- 1.7k
- Avg merge
- 14h 46m
- Merged PRs (30d)
- 61
Description
Environment
- OS and version: Windows 11 22H2
- VS Code: 1.103.2
- C/C++ extension: 1.26.3
- GDB / LLDB version: 16.3
Bug Summary and Steps to Reproduce
Bug Summary:
After setting MSYS2 bash as the default terminal of VSCode, the command of compile and debug provided by C/C++ extension is still "cmd /c ${command}". However, in bash, "/c" is interpreted as a directory (A "c" directory in the root directory) instead of a parameter. It leads that the bash launch "cmd.exe /msys-root/c ${command}"
Steps to reproduce:
- Install MSYS2 on Windows
- Install ucrt64-binutils and ucrt64-gdb by pacman
- Set MSYS2 UCRT64 as the default terminal of VSCode
- Launch "Debug" (cppdbg) task
- See error...
The terminal will stop at "cmd.exe" in interactive mode, because "/c" parameter is interpreted as directory name by bash. The debug process failed for timeout.
A possible solution might be changing the command to "cmd //c ${command}" or just run "${command}", but I can't find anywhere to configure the command for compile and debug in C/C++ extension.
Debugger Configurations
tasks.json:
{
"type": "cppbuild",
"label": "mingw-debug",
"command": "g++",
"args": [
"-fdiagnostics-color=always",
"-g",
"${file}",
"-o",
"${fileDirname}/${fileBasenameNoExtension}.exe"
],
"options": {
"cwd": "${fileDirname}"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
}
}
launch.json:
{
"name": "Debug",
"type": "cppdbg",
"request": "launch",
"program": "${fileDirname}/${fileBasenameNoExtension}.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${fileDirname}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"miDebuggerPath": "gdb",
"preLaunchTask": "mingw-debug"
}
Debugger Logs
--> R (launch-2): {"type":"response","request_seq":2,"success":false,"command":"launch","message":"Unable to start debugging. Unable to establish a connection to GDB. Debug output may contain more information.","body":{"error":{"id":1005,"format":"Unable to start debugging. Unable to establish a connection to GDB. Debug output may contain more information."}},"seq":14}
Other Extensions
No response
Additional Information
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the failure using the provided tasks.json and launch.json with MSYS2 UCRT64 as the VS Code terminal, then trace how the C/C++ extension constructs the compile and debug command. Done means the generated command works in MSYS2 bash and the cppdbg session connects to GDB without timing out.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, typescript
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100