Visual studio code 在WSL中使用GDB进行调试时的输入/输出

Visual studio code 在WSL中使用GDB进行调试时的输入/输出,visual-studio-code,gdb,windows-subsystem-for-linux,Visual Studio Code,Gdb,Windows Subsystem For Linux,我已经开始在Windows上使用Visual Studio代码&我想调试以下文件 main.c(位于c:/Users/aibrakov/Projects/c目录): #包括 内部主(空){ int x=42;//在此处添加断点 printf(“你好,世界!\n”); getchar(); 返回0; } 遵循这一思路 我有 settings.json: { "window.zoomLevel": 0, "terminal.integrated.shell.windows"

我已经开始在Windows上使用Visual Studio代码&我想调试以下文件

main.c(位于c:/Users/aibrakov/Projects/c目录):

#包括
内部主(空){
int x=42;//在此处添加断点
printf(“你好,世界!\n”);
getchar();
返回0;
}
遵循这一思路

我有

settings.json

{
    "window.zoomLevel": 0,
    "terminal.integrated.shell.windows": "c:\\windows\\sysnative\\bash.exe"
}
{
    "version": "2.0.0",
    "tasks": [
        {
            "label": "Build project",
            "type": "shell",
            "command": "gcc",
            "args": [
                "-g", "main.c"
            ],
            "group": {
                "kind": "build",
                "isDefault": true
            }
        }
    ]
}
{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "C++ Launch",
            "type": "cppdbg",
            "request": "launch",
            "program": "/mnt/c/Users/aibrakov/Projects/c/a.out",
            "stopAtEntry": false,
            "cwd": "/mnt/c/Users/aibrakov/Projects/c",
            "environment": [],
            "externalConsole": true,
            "MIMode": "gdb",
            "pipeTransport": {
                "pipeCwd": "",
                "pipeProgram": "c:\\windows\\sysnative\\bash.exe",
                "pipeArgs": [
                    "-c"
                ],
                "debuggerPath": "/usr/bin/gdb"
            },
            "sourceFileMap": {
                "/mnt/c": "c:\\"
            }
        }
    ]
}
tasks.json

{
    "window.zoomLevel": 0,
    "terminal.integrated.shell.windows": "c:\\windows\\sysnative\\bash.exe"
}
{
    "version": "2.0.0",
    "tasks": [
        {
            "label": "Build project",
            "type": "shell",
            "command": "gcc",
            "args": [
                "-g", "main.c"
            ],
            "group": {
                "kind": "build",
                "isDefault": true
            }
        }
    ]
}
{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "C++ Launch",
            "type": "cppdbg",
            "request": "launch",
            "program": "/mnt/c/Users/aibrakov/Projects/c/a.out",
            "stopAtEntry": false,
            "cwd": "/mnt/c/Users/aibrakov/Projects/c",
            "environment": [],
            "externalConsole": true,
            "MIMode": "gdb",
            "pipeTransport": {
                "pipeCwd": "",
                "pipeProgram": "c:\\windows\\sysnative\\bash.exe",
                "pipeArgs": [
                    "-c"
                ],
                "debuggerPath": "/usr/bin/gdb"
            },
            "sourceFileMap": {
                "/mnt/c": "c:\\"
            }
        }
    ]
}
launch.json

{
    "window.zoomLevel": 0,
    "terminal.integrated.shell.windows": "c:\\windows\\sysnative\\bash.exe"
}
{
    "version": "2.0.0",
    "tasks": [
        {
            "label": "Build project",
            "type": "shell",
            "command": "gcc",
            "args": [
                "-g", "main.c"
            ],
            "group": {
                "kind": "build",
                "isDefault": true
            }
        }
    ]
}
{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "C++ Launch",
            "type": "cppdbg",
            "request": "launch",
            "program": "/mnt/c/Users/aibrakov/Projects/c/a.out",
            "stopAtEntry": false,
            "cwd": "/mnt/c/Users/aibrakov/Projects/c",
            "environment": [],
            "externalConsole": true,
            "MIMode": "gdb",
            "pipeTransport": {
                "pipeCwd": "",
                "pipeProgram": "c:\\windows\\sysnative\\bash.exe",
                "pipeArgs": [
                    "-c"
                ],
                "debuggerPath": "/usr/bin/gdb"
            },
            "sourceFileMap": {
                "/mnt/c": "c:\\"
            }
        }
    ]
}
使用Ctrl+Shift+B构建项目成功

调试有点有效:它在断点处停止,并且可以访问
DEBUG CONSOLE
选项卡,但我没有得到输出(
Hello World!
,在我的示例中),也无法发送
getchar
等待的字符

有没有办法使用运行我的程序的终端?还是我遗漏了什么