microsoft / microsoft/vscode-cpptools

User input when debugging C++ on MacOs

Open
#5,595 3 comments 2 reactions 1 assignee View on GitHub

@WardenGnaw is already working on this.

Since Jun 3, 2020.

debugger
Dominant language
TypeScript
Stars
6.2k
Forks
1.7k
Avg merge
14h 46m
Merged PRs (30d)
61

Description

Type: Debugger

Describe the bug

  • OS and Version:
    image

  • VS Code Version:
    image

  • C/C++ Extension Version: 0.28.1

  • Other extensions you installed (and if the issue persists after disabling them):
    image

  • A clear and concise description of what the bug is.
    When attempting to debug a simple C++ script that requires user input, the external console does not allow for the input to be given, instead displaying darwin-debug description (print screen in additional context.).

To Reproduce
Please include a code sample and launch.json configuration.

Code sample

#include <iostream>

using namespace std;

int main(){
    string output;

    cout << "Teste" << endl;
    cin >> output;

    cout << output << endl;

    return 0;
}

launch.json

{
    // 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": "clang++ - Criar e depurar o arquivo ativo",
            "type": "cppdbg",
            "request": "launch",
            "program": "${fileDirname}/${fileBasenameNoExtension}",
            "args": [],
            "stopAtEntry": false,
            "cwd": "${workspaceFolder}",
            "environment": [],
            "externalConsole": true,
            "MIMode": "lldb",
            "preLaunchTask": "clang++ build active file"
        }
    ]
}

tasks.json

{
    "version": "2.0.0",
    "tasks": [
        {
            "type": "shell",
            "label": "clang++ build active file",
            "command": "/usr/bin/clang++",
            "args": [
                "-std=c++17",
                "-stdlib=libc++",
                "-g",
                "${file}",
                "-o",
                "${fileDirname}/${fileBasenameNoExtension}"
            ],
            "options": {
                "cwd": "${workspaceFolder}"
            },
            "problemMatcher": [
                "$gcc"
            ],
            "group": {
                "kind": "build",
                "isDefault": true
            }
        }
    ]
}

Steps to reproduce the behavior:

  1. Create .vscode folder and within it setup tasks.json and launch.json.
  2. Create hello_world.cpp and paste the code sample.
  3. Select the run and debug tab.
  4. Click the green run icon.

Additional context
External console print screen
image

I have already tried using the workaround described at #https://github.com/microsoft/vscode-cpptools/issues/5079#issuecomment-626090192

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.