【问题标题】:Visual Studio Code use input text file on debugVisual Studio Code 在调试时使用输入文本文件
【发布时间】:2017-09-17 00:48:24
【问题描述】:

我正在尝试按照这篇文章的方向进行操作

Visual Studio Code redirect input on debug

但是当我将控制台配置添加到 launch.json 文件时

"console": "integratedTerminal"

它会抛出“不允许使用属性控制台”。当我调试程序时,它仍然等待输入并且永远不会像我在 shell 中启动时那样达到断点

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

}

【问题讨论】:

  • "./a.out 1
  • 另外,如果有人可以告诉我如何在 shell 中启动 cpp 程序,然后在 vscode 中附加我的 lldb 调试。这也行,谢谢
  • 经过一个月的研究,目前似乎没有办法在 Cpp for LLDB 调试器中这样做。但是有一个 Node 的解决方法,如问题中所列。stackoverflow.com/questions/32863807/…

标签: c++ visual-studio-code


【解决方案1】:

我使用GDB 而不是lldb,但仍然遇到同样的问题。当我以这种方式在“launch.json”文件中输入参数时,它等待输入:

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

但是当我用以下方式重写它时它开始正常工作:

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

我认为即使输入文件位于工作区文件夹中或仅使用完整路径,也应该添加父文件夹。

【讨论】:

  • 你拯救了我的理智!第一次在 vscode 中调试 .. 与 linux 中的 gdb 的兼容性并将文件发送到标准输入 .. omg ......我也在尝试一些建议,比如在你放“r
  • @Dalton 你在哪里可以看到输出,如果 externalConsole 为真,它是否有效
猜你喜欢
  • 1970-01-01
  • 2022-10-22
  • 2017-07-03
  • 2017-02-24
  • 1970-01-01
  • 2015-10-04
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多