vscode-cpptools
vscode-cpptools copied to clipboard
Debugging on WSL - Must kill the integrated terminal after each debugging session, or gdb will not launch.
Environment
- OS and version: Window 11 (Build 22631.3447)
- VS Code: 1.88.1
- C/C++ extension: 1.19.9
- OS and version of remote machine (if applicable): WSL / Debian bookworm
- GDB / LLDB version: GDB 13.1
Bug Summary and Steps to Reproduce
I'm trying to debug on WSL with GDB. Debugger (gdb) runs only once per terminal instance, and I must kill the current terminal to start a new gdb session.
Steps to reproduce:
- In this environment: as mentioned above.
- With this config: launch.json included.
- Start debugging (F5) for the first time after you launch vscode.
- Debugger runs fine and everything works, and there is output in the integrated terminal.
- Stop debugging (Shift + F5), or maybe the program exists normally. (integrated terminal still open)
- Hit F5 to start debugging again, and nothing happens. Just the clock icon on the debug icon on sidebar and nothing happens.
- Stop debugging (Shift + F5).
- Kill the old terminal (from the last debugging session).
- Now if you press F5 everything works again normally.
- Each time you want to debug you'll have to make sure to kill the terminal used on that session before starting a new debugging session.
debugger hanging
kill terminal
Debugger Configurations
{
"configurations": [
{
"name": "CMake: Debug",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceRoot}/main",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"logging": {
"engineLogging": true
},
"externalConsole": false,
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
},
]
}
Debugger Logs
1: (52) LaunchOptions{"name":"CMake: Debug","type":"cppdbg","request":"launch","program":"/home/omar/code/c_test/main","args":[],"stopAtEntry":false,"cwd":"/home/omar/code/c_test","logging":{"engineLogging":true},"externalConsole":false,"MIMode":"gdb","setupCommands":[{"description":"Enable pretty-printing for gdb","text":"-enable-pretty-printing","ignoreFailures":true}],"__configurationTarget":6,"__sessionId":"5954018f-1d5b-4025-9b02-11d0935a260e"}
1: (85) DbgCmd:echo $$ > /tmp/Microsoft-MIEngine-Pid-hwtp1kiq.zbu ; cd "/home/omar/code/c_test" ; DbgTerm=`tty` ; set -o monitor ; trap 'rm "/tmp/Microsoft-MIEngine-In-bkwym34n.4jo" "/tmp/Microsoft-MIEngine-Out-35oyyhjc.0p5" "/tmp/Microsoft-MIEngine-Pid-hwtp1kiq.zbu" "/tmp/Microsoft-MIEngine-Cmd-0ciujqsx.thb"' EXIT ; "/usr/bin/gdb" --interpreter=mi --tty=$DbgTerm < "/tmp/Microsoft-MIEngine-In-bkwym34n.4jo" > "/tmp/Microsoft-MIEngine-Out-35oyyhjc.0p5" & clear; pid=$! ; echo $pid > "/tmp/Microsoft-MIEngine-Pid-hwtp1kiq.zbu" ; wait $pid;
1: (92) Wait for connection completion.
Other Extensions
CMake Tools: 1.17.17
Additional Information
1 - I installed xterm on my Debian/WSL and set { "externalConsole": true } in launch.json, and in that case debugging runs fine, and every time I press F5 a new external terminal (xterm) will launch even if the old one is not closed.
2 - The same setup works fine on Windows 11, with gcc, gdb, and source code all on Windows. The issue only happens if I'm trying to debug on WSL with gcc, gdb, and source code all on linux.