Vscode-cpptools: Is there a way to pass input to std::cin during debugging / in debug console?

Created on 15 Jan 2017  路  12Comments  路  Source: microsoft/vscode-cpptools

I have mac / windows if that helps at all.

debugger

Most helpful comment

@JewsOfHazard if you enable "externalConsole":true in the launch.json then you will get a pop up console window that you can type in.

We have plans to integrate the debugConsole that is within VSCode.

All 12 comments

@JewsOfHazard if you enable "externalConsole":true in the launch.json then you will get a pop up console window that you can type in.

We have plans to integrate the debugConsole that is within VSCode.

@JewsOfHazard Did enabling the "externalConsole" work for you?

Yes sorry I didn't get back to you. That did open the external console and I was able to input text.

However, is there a way to change syntax on that command that runs in the external console? The shell I use has a slightly different command for the status code ($status instead of $?)
It's ultimately not a big deal but might be interesting to consider.

@JewsOfHazard There is work to use the VSCode integrated console which may allow you to make changes but this work hasn't been done yet. Issue #35 is tracking that

have a problem:Property externalConsole is not allowed

@fanjc320 if you need more help, we need your launch.json to see what is going on.

@pieandcakes I can't enable "externalConsole":true when using vscode-cmake-tools with Visual Studio as kits. The extension controls the launch.json when debuging.

The extension generates the config for cpptools as below

function createMSVCDebugConfiguration(target) {
    return {
        type: 'cppvsdbg',
        name: `Debug ${target.name}`,
        request: 'launch',
        cwd: '${workspaceRoot}',
        args: [],
        program: target.path
    };
}

As for the cppdbg, the cpptools use the integrated terminal to debug. I can use it to input the stuff. But the cppvsdbg not.

@zeyugao please file an issue with the cmake extension to allow you to set "externalConsole": true. This is currently the only way with cppvsdbg to allow you to process stdin with your debuggee.

Hi @pieandcakes , I set externalConsole: true but it seems that it only launch a normal terminal without running my program. Is there any step that I miss ?
Here is my launch.json

{
  // Use IntelliSense to learn about possible attributes.
  // Hover to view descriptions of existing attributes.
  // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
  "version": "0.2.0",
  "configurations": [

    {
      "name": "clang++ - Build and debug active file",
      "type": "cppdbg",
      "request": "launch",
      "program": "${fileDirname}/${fileBasenameNoExtension}",
      "args": [],
      "stopAtEntry": true,
      "cwd": "${workspaceFolder}",
      "environment": [],
      "externalConsole": true,
      "MIMode": "lldb",
      "preLaunchTask": "clang++ build active file",
    }
  ]
}

Here is my screen recording , it open a terminal but then it doesn't run my code. Even if i execute my code manually in that terminal, the debugger doesn't capture my input.

image

@fawwaz the screen recording is just a screenshot. Please file a new issue and fill out the template. I don't know what OS you are on or any other details so I don't have enough information to go off of.

  • Inspite of having "externalConsole": true, I am unable to debug the code.

  • Exact similar issue as above, and

  • I see Warning - * 'Debuggee TargetArchitecture not detected, assuming x86_64."*
Was this page helpful?
0 / 5 - 0 ratings