Skip to content

External terminal when debugging in WSL #1772

Open

Description

@kbumsik

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!

Activity

  1. pieandcakes commented on Apr 5, 2018

    @pieandcakes
    Contributor

    How can I open an external terminal for WSL debugging?

    Because it is a pipe communication, there isn't a way to do it currently.

    Even there is not external terminal, how to get output from stdout and input to stdin during the debugging session?

    You can try and use an input file and an output file, but I don't think we have a solution for this yet.

  2. kbumsik commented on Apr 5, 2018

    @kbumsik
    Author

    Thank you for the answer. So do you think there is no way to debug ELF-compiled program with an external terminal currently, I mean on Windows?

  3. Spongman commented on May 16, 2018

    @Spongman

    Is there a way to add this?

    I'm trying to debug a program that uses console input, scrolling, cursor movement.

    it's pretty much useless for this as it is.

  4. ThePiyushGupta commented on Aug 26, 2018

    @ThePiyushGupta

    same problem here

  5. youngspe commented on Sep 13, 2018

    @youngspe

    As a workaround I was able to have the tty configuration in GDB point to the result of tty in a separate bash terminal, have the terminal sleep infinity, and then start debugging. To make it a little quicker I set up a script to find the tty for a new terminal, create a symlink to it. In launch.json I set GDB's tty configuration to that symlink and made the script my prelaunch task so as to not have to potentially change launch.json every time. But it feels like a hack, so it'd be nice to have a built-in way to do this.

    Alternately, start the process separately and attach the debugger to it, but I'm not sure if there's a way to have it break at the beginning of execution that way.

  6. yalshekerchi commented on Nov 11, 2018

    @yalshekerchi

    Spencer Young (@youngspe) I'm interested in trying out your workaround, do u mind providing some more detailed information on how to set it up?

  7. youngspe commented on Nov 11, 2018

    @youngspe
  8. giuliofoletto commented on Feb 23, 2019

    @giuliofoletto

    Same issue here. Seems to be kind of a basic feature. Hope to see it fixed in the near future.

  9. buliuzi commented on Mar 30, 2019

    @buliuzi

    Same issue here.

  10. ezineo commented on Apr 19, 2019

    @ezineo

    Have it be solved?

  11. vitorlana commented on Oct 4, 2019

    @vitorlana

    Same issue here

  12. scratchmex commented on Feb 11, 2020

    @scratchmex

    Same here. When "externalConsole": true the debugger gets stuck.

    vscode_debugger_stuck

    EDIT:
    For those who want to activate the external console to be able to stream a file to stdin like < in.txt and debug it, I've managed to do so including a piece of code.

    freopen("in.txt", "r", stdin);
    // code who read from stdin piped from in.txt
    fclose(stdin);
  13. AnsonH commented on Mar 30, 2020

    @AnsonH

    Same issue here. Even when I tried to make g++ output an .exe file in tasks.json, the debugger still get stuck.

  14. DrDinosaur commented on Jul 5, 2020

    @DrDinosaur

    I would like to see this added as well, running into this issue

  15. andres-pcg commented on Jul 22, 2020

    @andres-pcg

    I'm having same issue. I hope someone can pay attention to this some day. It's been two years and no answers so far

  16. mikucukyilmaz commented on Jan 31, 2021

    @mikucukyilmaz

    Same issue here when debugging remote target from WSL.

  17. lamarch commented on Feb 25, 2021

    @lamarch

    Same issue here.

  18. Lambda1107 commented on Oct 31, 2021

    @Lambda1107

    Same issue here.

  19. jaredtconnor commented on Feb 23, 2022

    @jaredtconnor

    +1 on this issue please.

  20. trace1729 commented on Oct 11, 2022

    @trace1729

    Same issue here

  21. totszwai commented on Feb 8, 2023

    @totszwai

    Please make this as high priority. Thank you!

  22. sryio commented on Apr 3, 2023

    @sryio

    Same issue here

  23. rindev0901 commented on Jun 22, 2023

    @rindev0901

    same issue here

  24. datah4zard commented on Aug 14, 2023

    @datah4zard

    +1

  25. jiangshuai1995 commented on Dec 21, 2023

    @jiangshuai1995

    mac remote login to linux server to start debugging also has this problem

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Feature Requestdebuggerverified

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions