Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Debugging on WSL - Must kill the integrated terminal after each debugging session, or gdb will not launch. #12240

Open
omsharp opened this issue Apr 22, 2024 · 1 comment
Labels
debugger help wanted Can be fixed in the public (open source) repo. Language Service

Comments

@omsharp
Copy link

omsharp commented Apr 22, 2024

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:

  1. In this environment: as mentioned above.
  2. With this config: launch.json included.
  3. Start debugging (F5) for the first time after you launch vscode.
  4. Debugger runs fine and everything works, and there is output in the integrated terminal.
  5. Stop debugging (Shift + F5), or maybe the program exists normally. (integrated terminal still open)
  6. Hit F5 to start debugging again, and nothing happens. Just the clock icon on the debug icon on sidebar and nothing happens.
  7. Stop debugging (Shift + F5).
  8. Kill the old terminal (from the last debugging session).
  9. Now if you press F5 everything works again normally.
  10. 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

image

kill terminal

image

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.

@browntarik browntarik added debugger help wanted Can be fixed in the public (open source) repo. Language Service labels Apr 22, 2024
@borjamunozf
Copy link

Wondering if this could be linked somehow to this issue I'm facing #12120

I have to kill the process of OpenDAP a lot of times but only the first try, after launching a second one it finally starts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
debugger help wanted Can be fixed in the public (open source) repo. Language Service
Projects
None yet
Development

No branches or pull requests

3 participants