Visual Studio代码在调试时使用输入文本文件

时间:2017-09-17 00:48:24

标签: c++ visual-studio-code

我正在尝试按照这篇文章的指示

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

}

1 个答案:

答案 0 :(得分:1)

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

 <form action="{{ route('admin.user.store') }}" method="post" class="form-horizontal"
              enctype="multipart/form-data" id ="upload_form">
            @csrf
            <div class="row justify-content-center">
                <div class="col-xl-9">
                    <!--begin::Wizard Step 1-->
                   <div class="my-5 step" data-wizard-type="step-content" data-wizard-state="current">
                        <h5 class="text-dark font-weight-bold mb-10">User's Profile Details:</h5>
                        <!--begin::Group-->
    
    
    
                        <div class="form-group row">
                            <label class="col-xl-3 col-lg-3 col-form-label text-left">Avatar</label>
                            <div class="col-lg-9 col-xl-9">
                                <div class="image-input image-input-outline" id="kt_user_add_avatar">
                                    <div class="image-input-wrapper" >
                        <img src="{{asset('assets/media/users/100_6.jpg')}}" width="120" height="120">
    
                                        </div>
                                    <label class="btn btn-xs btn-icon btn-circle btn-white btn-hover-text-primary btn-shadow" data-action="change" data-toggle="tooltip" title="" data-original-title="Change avatar">
                                        <i class="fa fa-pen icon-sm text-muted"></i>
                                        <input id="avatar" type="file" name="avatar" accept=".png, .jpg, .jpeg" />
                                    </label>
                                    <span class="btn btn-xs btn-icon btn-circle btn-white btn-hover-text-primary btn-shadow" data-action="cancel" data-toggle="tooltip" title="Cancel avatar">
                                                            <i class="ki ki-bold-close icon-xs text-muted"></i>
                                                        </span>
                                </div>
                            </div>
                        </div>
                        <!--end::Group-->

 

     <div class="form-group row">
                            <label class="col-xl-3 col-lg-3 col-form-label text-left">Avatar_2</label>
                            <div class="col-lg-9 col-xl-9">
                                <div class="image-input image-input-outline" id="kt_user_add_avatar">
                                    <div class="image-input-wrapper" >
                        <img src="{{asset('assets/media/users/100_6.jpg')}}" width="120" height="120">
    
                                        </div>
                                    <label class="btn btn-xs btn-icon btn-circle btn-white btn-hover-text-primary btn-shadow" data-action="change" data-toggle="tooltip" title="" data-original-title="Change avatar">
                                        <i class="fa fa-pen icon-sm text-muted"></i>
                                        <input id="avatar_2" type="file" name="avatar_2" accept=".png, .jpg, .jpeg" />
                                    </label>
                                    <span class="btn btn-xs btn-icon btn-circle btn-white btn-hover-text-primary btn-shadow" data-action="cancel" data-toggle="tooltip" title="Cancel avatar">
                                                            <i class="ki ki-bold-close icon-xs text-muted"></i>
                                                        </span>
                                </div>
                            </div>
                        </div>
    
    
    
    
    
    
    
    
    
      <div class="form-actions">
                        <div class="row">
                            <div class="col-md-offset-3 col-md-9">
                                <button type="submit" class="btn" style="background-color:#3699FF">Submit</button>
                                <a href="{{route('admin.user.index')}}" class="btn default" style="background-color: rgba(77, 89, 149, 0.06)">Cancel</a>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </form>

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

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

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