Visual Studio Code在调试时使用输入文本文件 [英] Visual Studio Code use input text file on debug
问题描述
我正在尝试遵循此帖子的指示
I am trying to follow the direction from this post
但是当我将控制台配置添加到launch.json文件
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"
完整配置
{
"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"
}
]
}
推荐答案
我使用GDB而不是lldb,但仍然遇到相同的问题.当我在"launch.json"中键入参数时,它等待输入.这样归档:
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.
这篇关于Visual Studio Code在调试时使用输入文本文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!