Type: Debugger
Describe the bug
I want to use the ingerated terminal inside VSC. I can only get inputs if I enable "externalConsole", which doesn't solve this issue as it requires using an external terminal.
To Reproduce
Sample launch.json:
"configurations": [
{
"name": "g++ Build & Debug Folder",
"type": "cppdbg",
"request": "launch",
"program": "${fileDirname}\\test.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${fileDirname}",
"environment": [],
"externalConsole": true, // Only to way get inputs currently =(
"MIMode": "gdb",
"miDebuggerPath": "C:\\MinGW\\bin\\gdb.exe",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
}
]
Sample C++ Program:
#include <iostream>
int main() {
int input {1};
std::cin >> input;
std::cout << input << '\n';
return 0;
}
Steps to reproduce the behavior:
Additional context
The following is ran inside the integrated terminal:
'c:\Users\Vrej\.vscode\extensions\ms-vscode.cpptools-0.28.0\debugAdapters\bin\WindowsDebugLauncher.exe' '--stdin=Microsoft-MIEngine-In-rzbbs23a.feg' '--stdout=Microsoft-MIEngine-Out-0mxge4rh.udl' '--stderr=Microsoft-MIEngine-Error-gcbm3hqx.mik' '--pid=Microsoft-MIEngine-Pid-imrtgchk.lay' '--dbgExe=C:\MinGW\bin\gdb.exe' '--interpreter=mi'
Then the cursor begins blinking in the new line, but I am unable to give any inputs.
I can't reproduce this issue, there may be some delay before the integrated terminal starts to work.
Can you try inputting when "Ready for Input" shows up in the window?
#include <iostream>
int main() {
int input {1};
std::cout << "Ready for Input" << std::endl;
std::cin >> input;
std::cout << input << '\n';
return 0;
}
If its still failing can you enable engineLogs by adding the following to your launch.json?
"logging": {
"engineLogging": true
}
For the first test, "Ready for Input" didn't show up in the integrated terminal, only showed up when I used the external terminal. Though "Ready for Input" did print inside the debug console in both cases:

I put the code you have sent me, it didn't make any difference. The integrated terminal still refuses to get any input.
What does the terminal tab look like?

I can repro this with mingw-get version 0.6.3-pre-20170905-1 installing gdb-7.6.1
Did you download MinGW from the link from the docs
Did you download MinGW from the link from the docs
I downloaded from the main MinGW website (www.mingw.org), all installed packages are up to date.
Looks like theres an issue with mingw with integrated terminal.
A workaround is to use mingw-w64 with integrated terminal on Windows.
Investigating.
I have the same problem using MSVC pipeline on Windows. Using the external console works just fine, but when trying to use the integrated one, it doesn't even print the first cout statement.
And btw, without any cin statements, everything also works perfectly fine in the integrated console.
Versions:
Here are some files if that helps:
main.cpp:
#include <iostream>
#include <string>
using namespace std;
int main()
{
int age;
string zipCode;
string promptAge = "Please enter you age: ";
string promptZipCode = "Please enter you ZIP code: ";
cout << promptAge;
cin >> age;
cout << promptZipCode;
cin >> zipCode;
cout << "Hi, you are " << age << " years old and your ZIP code is " << zipCode << ".\n";
return 0;
}
c_cpp_properties.json:
{
"configurations": [
{
"name": "Win32",
"includePath": [
"${workspaceFolder}/**"
],
"defines": [
"_DEBUG",
"UNICODE",
"_UNICODE"
],
"windowsSdkVersion": "10.0.18362.0",
"compilerPath": "C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.26.28801/bin/Hostx64/x64/cl.exe",
"cStandard": "c11",
"cppStandard": "c++17",
"intelliSenseMode": "msvc-x64"
}
],
"version": 4
}
launch.json:
{
"version": "0.2.0",
"configurations": [
{
"name": "Build and debug",
"type": "cppvsdbg",
"request": "launch",
"program": "${workspaceFolder}\\bin\\debug\\main.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}\\bin\\debug",
"environment": [],
"externalConsole": false,
"preLaunchTask": "Build debug"
}
]
}
tasks.json:
{
"version": "2.0.0",
"tasks": [
{
"type": "shell",
"label": "Build debug",
"command": "cl.exe",
"args": [
"/Zi",
"/EHsc",
"/Fe:",
"${workspaceFolder}\\bin\\debug\\main.exe",
"${workspaceFolder}\\src\\main.cpp"
],
"options": {
"cwd": "${workspaceFolder}\\bin\\debug"
},
"problemMatcher": [
"$msCompile"
],
"group": {
"kind": "build",
"isDefault": true
}
},
{
"type": "shell",
"label": "Build release",
"command": "cl.exe",
"args": [
"/EHsc",
"/GA",
"/Qpar",
"/O2",
"/Ot",
"/Ox",
"/favor:blend",
"/Fe:",
"${workspaceFolder}\\bin\\release\\main.exe",
"${workspaceFolder}\\src\\main.cpp"
],
"options": {
"cwd": "${workspaceFolder}\\bin\\release"
},
"problemMatcher": [
"$msCompile"
],
"group": "build",
}
]
}
I have the same problem debugging C++ programs.The terminal didn't output anything and of course can't get inputs.You say there's an issue with mingw,but I don't know the concrete steps to solve this problem.Thanks a lot.
Most helpful comment
Looks like theres an issue with mingw with integrated terminal.
A workaround is to use mingw-w64 with integrated terminal on Windows.
Investigating.