Visual Studio Code use input text file on debug

冷暖自知 提交于 2020-12-02 07:20:10

问题


I am trying to follow the direction from this post

Visual Studio Code redirect input on debug

but when I add the console config to the launch.json file

"console": "integratedTerminal"

it throws a "Property console is not allowed". and when I debug the program it still waits on input and never reach break point like I would if I start in shell like

"./a.out 1 test1.txt"

"./a.out 1 <test1.txt"    

Full config

{
    "version": "0.2.0",
    "configurations": [

    {
        "name": "(lldb) Launch",
        "type": "cppdbg",
        "request": "launch",
        //"program": "${workspaceRoot}/a.out.dSYM/Contents/Resources/DWARF/a.out",
        "program": "${workspaceRoot}/a.out",
        "args": ["1", "<","test1.txt"],
        "stopAtEntry": false,
        "cwd": "${workspaceRoot}/",
        "environment": [],
        "externalConsole": true,
        "MIMode": "lldb",
        //"miDebuggerPath": "C:\\mingw\\bin\\gdb.exe",
        "setupCommands": [
            {
                "description": "Enable pretty-printing for gdb",
                "text": "-enable-pretty-printing",
                "ignoreFailures": true
            }
        ],
        "console": "integratedTerminal"
        //"preLaunchTask": //"build test1"
    }
]

}


回答1:


I use GDB instead of lldb but still encountered the same issue. It waited input when I typed arguments in "launch.json" file this way:

"args": ["<", "test1.txt"],

But it started working properly when I had rewritten it in the following manner:

"args": ["<", "${workspaceFolder}/test1.txt"],

I think that one should add a parent folder even though the input file is in the workspace folder or simply use the full path.



来源:https://stackoverflow.com/questions/46259717/visual-studio-code-use-input-text-file-on-debug

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!