microsoft / microsoft/vscode-cpptools

Output is not displayed in the integrated VS Code Debug Console when stepping over output instructions

Open
#5,854 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

bug 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: Windows 10
  • VS Code Version: 1.47.3
  • C/C++ Extension Version: 0.29.0
  • Other extensions you installed (and if the issue persists after disabling them): None
  • When stepping over output lines like printf(), no output is displayed in the integrated VS Code Debug Console.

To Reproduce
Consider the following simple C code:

#include <stdio.h>

int main() {  
    printf("Connie\n");
    return 0;
}

launch.json configuration:

{
    // 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": "cl.exe - Compila ed esegui il debug del file attivo",
            "type": "cppvsdbg",
            "request": "launch",
            "program": "${fileDirname}\\${fileBasenameNoExtension}.exe",
            "args": [],
            "stopAtEntry": true,
            "cwd": "${workspaceFolder}",
            "environment": [],
            "externalConsole": false,
            "preLaunchTask": "C/C++: cl.exe build active file"
        }
    ]
}

Steps to reproduce the behavior:

  1. Set a breakpoint at the printf("Connie\n") line.

  2. Select Run | Start Debugging from the menu.

  3. Step over the above printf() line.

  4. See that no output is displayed in the Debug Console integrated window (screenshot attached).

Workaround
It seems that the problem is that the output is buffered. So, disabling output buffering with a line like the following seems to solve the problem and the output string is displayed immediately after stepping over it:

  /* Disable output buffering */
  setvbuf(stdout, NULL, _IONBF, 0); 

However, this is not an intuitive behavior. It would be more developer friendly to just show the output when stepping over output lines. Or, at least offer an option to customize that behavior (like "bufferedOutput": true/false).

VS_Code_C_No_Display_Output

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

Start by reproducing the behavior with the provided C program, launch.json configuration, Windows setup, and integrated Debug Console. Investigate how stepping over printf() handles buffered output in the cppvsdbg configuration. Done means output is shown as expected when stepping, or the behavior is clearly exposed through a documented configuration option.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.