0

How does one add user input when debugging on VScode?

I have tried the following

  • Edited my launch.json to set externalConsole : true
  • Tried giving input as a command line argument as mentioned here

Irrespective of following step by step the above methods, something was off.

I kept getting a window where I couldn't do anything. The step up / down / in buttons went inactive.

Here in my launch.json file

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "g++-10 - Build and debug active file",
            "type": "cppdbg",
            "request": "launch",
            "program": "${fileDirname}/${fileBasenameNoExtension}",
            "args": [],
            "stopAtEntry": false,
            "cwd": "${workspaceFolder}",
            "environment": [],
            "externalConsole": true,
            "MIMode": "lldb",
            "preLaunchTask": "C/C++: g++-10 build active file"
        }
    ]
} 

and here is my tasks.json file

{
    "tasks": [

        {
            "type": "shell",
            "label": "C/C++: g++-10 build active file",
            "command": "g++",
            "args": [
                "-g",
                "${file}",
                "-std=c++17",
            ],
            "options": {
                "cwd": "${workspaceFolder}"
            },
            "problemMatcher": [
                "$gcc"
            ],
            "group": {
                "kind": "build",
                "isDefault": true
            }
        }
    ],
    "version": "2.0.0"
}

System details

Version: 1.48.1
Commit: 3dd905126b34dcd4de81fa624eb3a8cbe7485f13
Date: 2020-08-19T17:09:41.484Z
Electron: 7.3.2
Chrome: 78.0.3904.130
Node.js: 12.8.1
V8: 7.8.279.23-electron.0
OS: Darwin x64 20.0.0

1 Answers1

1

The resolve is given in a gist here

The issue is when VSCode launches the debug adapter, then the debug adapter launches lldb-mi, then lldb-mi launches Terminal. There is a prompt that should appear, but somehow the DebugAdapter is not forwarding this permissions request.

The work around is to have VS Code launch the terminal once. You can do this by adding and running this tasks in your tasks.json:

{
  "label": "Open Terminal",
  "type": "shell",
  "command": "osascript -e 'tell application \"Terminal\"\ndo script \"echo hello\"\nend tell'",
  "problemMatcher": []
}

You can run this specific task using Command + Shift + p. Type Tasks and look for Tasks: Run Tasks then select Open Terminal.

I have written a small blog post about the same, detailing each and every step with images which can be found here.