microsoft / microsoft/vscode-cpptools

External terminal when debugging in WSL

Open
#1,772 25 comments 18 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

debugger Feature Request verified
Dominant language
TypeScript
Stars
6.2k
Forks
1.7k
Avg merge
14h 46m
Merged PRs (30d)
61

Description

Hello,
Firstly I would like to say thank you for this awesome text editor and the C/C++ extension :)

I tried debugging C/C++ program in Windows Subsystem for Linux. The debugging session works fine but the only problem is that VS Code won't open an external terminal so I could not get stdout and stdin from a terminal during the debugging session.

So I have two questions:

  1. How can I open an external terminal for WSL debugging?
  2. Even there is not external terminal, how to get output from stdout and input to stdin during the debugging session?

Here is my launch.json, as you can see I set "externalConsole": true but an external terminal won't appear:


        {
            "name": "maze_solver",
            "type": "cppdbg",
            "request": "launch",
            "program": "maze_solver",
            "args": [],
            "stopAtEntry": false,
            "cwd": "./",
            "environment": [],
            "externalConsole": true,
            "pipeTransport": {
                "debuggerPath": "/usr/bin/gdb",
                "pipeProgram": "C:\\Windows\\sysnative\\bash.exe",
                "pipeArgs": ["-c"],
                "pipeCwd": "${workspaceFolder}/simulation/maze_solver"
            },
            "setupCommands": [
                {
                    "description": "Enable pretty-printing for gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                }
            ],
            "sourceFileMap": {
                "/mnt/d": "d:\\"
            },
            "logging": { "engineLogging": true }
        }

Thank you very much!

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the launch.json configuration, especially externalConsole and pipeTransport, and reproduce the C/C++ debugging session under WSL. Trace how the extension handles external terminals and standard input/output for this setup. Done means WSL debugging opens a usable external terminal or clearly supports stdin and stdout through the documented alternative.

Written by the indexing model from the issue text.

Assessment

Tech stack
bash, cpp, vscode
Domain
devtools, operating-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.