Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio Code use input text file on debug

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"
    }
]

}

like image 430
echo Avatar asked Sep 17 '17 00:09

echo


1 Answers

I use GDB instead of lldb but still encountered the same issue. It waited for an input when I typed arguments in the "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.

like image 169
Meiram Shunshalin Avatar answered Sep 20 '22 22:09

Meiram Shunshalin