microsoft / microsoft/vscode-cpptools

Macbook M1 - debugger, scanf does not read from console

Open
#9,025 11 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Bug type: Debugger

Describe the bug

  • OS and Version: Monterey
  • VS Code Version: Insiders edition
  • C/C++ Extension Version: 1.93
  • Other extensions you installed (and if the issue persists after disabling them): C/C++ debug extension
  • A clear and concise description of what the bug is. I can't read from standard input, i.e. terminal. In addition, I can't get the debugger working for C with an external terminal. It opens two terminals which are disconnected from the debugging process. When I do enter, say an integer, into the terminal, I just get the error: "Unable to perform this action because the process is running." Which I presume is due to standard input being disconnected from the debugger and the file as a whole, more or less.

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

Launch:
{ // 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": "(lldb) Launch", "type": "cppdbg", "request": "launch", "targetArchitecture": "x86_64", "program": "${workspaceFolder}/${fileBasenameNoExtension}.x86_64", "args": [], "stopAtEntry": true, "cwd": "${fileDirname}", "environment": [], "externalConsole": false, "osx": { "preLaunchTask": "build (x86_64)", "MIMode": "lldb" } } ] }

Tasks:
{ // See https://go.microsoft.com/fwlink/?LinkId=733558 // for the documentation about the tasks.json format "version": "2.0.0", "tasks": [ { "label": "build (x86_64)", "type": "shell", "command": "clang", "args": [ "-arch", "x86_64", "-g", "-o", "${workspaceFolder}/${fileBasenameNoExtension}.x86_64", "${fileDirname}/${fileBasename}" ], "group": "build" }, { "label": "build (arm64)", "type": "shell", "command": "clang", "args": [ "-arch", "arm64", "-g", "-o", "${workspaceFolder}/${fileBasenameNoExtension}.arm64", "${fileDirname}/${fileBasename}" ], "group": "build" }, { "label": "build (Mach-O Universal)", "type": "shell", "command": "lipo", "dependsOn":["build (x86_64)", "build (arm64)"], "args": [ "-create", "-output", "${workspaceFolder}/${fileBasenameNoExtension}", "${workspaceFolder}/${fileBasenameNoExtension}.x86_64", "${workspaceFolder}/${fileBasenameNoExtension}.arm64" ], "group": { "kind": "build", "isDefault": true } } ] }

Create a new c file, test.c.
Try running the code:
`#include <stdio.h>

int main(void) {
int test;
printf("hello");
scanf("%d", &test);
return 0;
}`

As a computer science student debugging is of vital importance for more or less all of my assignments. Solving this issue would heavily facilitate my workflow.
Thanks in advance.

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.

Research direction

Reproduce the problem with test.c, launch.json, and tasks.json using the shown cppdbg configuration, especially externalConsole and MIMode lldb. Start by checking how standard input is attached when the debugger launches and whether the two terminals are connected to the process. Done means scanf reads input and external-console debugging works without the “process is running” error.

Written by the indexing model from the issue text.

Assessment

Tech stack
c, vscode
Domain
devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
32/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.