microsoft / microsoft/vscode-cpptools

System("cls") doesn't work in the debugger terminal.

Aperta
#13,110 3 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

bug debugger help wanted tasks/build/debug
Lingua principale
TypeScript
Stelle
6.2k
Fork
1.7k
Merge medio
14h 46m
PR unite (30g)
61

Descrizione

Environment
  • OS and version: Microsoft Windows 11 Pro 10.0.26100 N/A Build 26100
  • VS Code: 1.96.2
  • C/C++ extension: ms-vscode.cpptools@1.22.11
  • OS and version of remote machine (if applicable): NONE
  • GDB / LLDB version: GNU gdb (GDB) 14.2
Bug Summary and Steps to Reproduce

Bug Summary:
In terminal std::system( "cls" ); or std::system( "pause" );, such command does not work as expected on windows OS.
However, manually execute the command still works, execute the program without the debugger still works, enable externalConsole works, on linux platform also works.

Image

Image

Steps to reproduce:

Minimal reproduce code:

#include "iostream"
#include "cstdlib"
int main(){
    std::cout << "This line should be cleared." << std::endl;    
    std::system( "cls" );
    std::cout << "This line will be the one and only line left." << std::endl;
    return 0;
}

launch config:

        {
            "name": "C/C++: g++.exe build and debug active file",
            "type": "cppdbg",
            "request": "launch",
            "program": "${fileDirname}\\${fileBasenameNoExtension}.exe",
            "args": [],
            "stopAtEntry": false,
            "cwd": "${fileDirname}",
            "environment": [],
            "externalConsole": false,
            "MIMode": "gdb",
            "miDebuggerPath": "D:\\Build_Tool_Lib\\x86_64-14.2.0-release-win32-seh-ucrt-rt_v12-rev0\\mingw64\\bin\\gdb.exe",
            "setupCommands": [
                {
                    "description": "Enable pretty-printing for gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                },
                {
                    "description": "Set Disassembly Flavor to Intel",
                    "text": "-gdb-set disassembly-flavor intel",
                    "ignoreFailures": true
                }
            ],
            "preLaunchTask": "C/C++: g++.exe build active file"
        },

Steps to reproduce:

Minimal reproduce code:

#include "iostream"
#include "cstdlib"
int main(){
    std::cout << "This line should be cleared." << std::endl;    
    // std::cout.flush();
    std::system( "cls" );
    std::cout << "This line will be the one and only line left." << std::endl;
    // std::cout.flush();
    return 0;
}
Debugger Configurations
{
            "name": "C/C++: g++.exe build and debug active file",
            "type": "cppdbg",
            "request": "launch",
            "program": "${fileDirname}\\${fileBasenameNoExtension}.exe",
            "args": [],
            "stopAtEntry": false,
            "cwd": "${fileDirname}",
            "environment": [],
            "externalConsole": false,
            "MIMode": "gdb",
            "miDebuggerPath": "D:\\Build_Tool_Lib\\x86_64-14.2.0-release-win32-seh-ucrt-rt_v12-rev0\\mingw64\\bin\\gdb.exe",
            "setupCommands": [
                {
                    "description": "Enable pretty-printing for gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                },
                {
                    "description": "Set Disassembly Flavor to Intel",
                    "text": "-gdb-set disassembly-flavor intel",
                    "ignoreFailures": true
                }
            ],
            "logging": { "engineLogging": true, "trace": true, "traceResponse": true },
            "preLaunchTask": "C/C++: g++.exe build active file"
        },
Debugger Logs
Unable to find /usr/bin/g++. [ArchLinux] C/C++: g++ build active file task is ignored.
Unable to find /usr/bin/g++. [ArchLinux] [Release] C/C++: g++ build active file task is ignored.
Unable to find /usr/bin/g++. [ArchLinux] C/C++: gcc build active file task is ignored.
Unable to find /usr/bin/g++. [ArchLinux] C/C++: g++ build active file task is ignored.
Unable to find /usr/bin/g++. [ArchLinux] [Release] C/C++: g++ build active file task is ignored.
Unable to find /usr/bin/g++. [ArchLinux] C/C++: gcc build active file task is ignored.
Launch configuration:
{
  "name": "C/C++: g++.exe build and debug active file",
  "type": "cppdbg",
  "request": "launch",
  "program": "D:\\back_up\\ProgrammingEvents\\AdventOfCode\\2024\\Day20\\test.exe",
  "args": [],
  "stopAtEntry": false,
  "cwd": "D:\\back_up\\ProgrammingEvents\\AdventOfCode\\2024\\Day20",
  "environment": [],
  "externalConsole": true,
  "MIMode": "gdb",
  "miDebuggerPath": "D:\\Build_Tool_Lib\\x86_64-14.2.0-release-win32-seh-ucrt-rt_v12-rev0\\mingw64\\bin\\gdb.exe",
  "setupCommands": [
    {
      "description": "Enable pretty-printing for gdb",
      "text": "-enable-pretty-printing",
      "ignoreFailures": true
    },
    {
      "description": "Set Disassembly Flavor to Intel",
      "text": "-gdb-set disassembly-flavor intel",
      "ignoreFailures": true
    }
  ],
  "logging": {
    "engineLogging": true,
    "trace": true,
    "traceResponse": true
  },
  "preLaunchTask": "C/C++: g++.exe build active file",
  "__configurationTarget": 6,
  "configSource": "workspaceFolder",
  "debugType": "debug"
}
Launch configuration:
{
  "name": "C/C++: g++.exe build and debug active file",
  "type": "cppdbg",
  "request": "launch",
  "program": "D:\\back_up\\ProgrammingEvents\\AdventOfCode\\2024\\Day20\\test.exe",
  "args": [],
  "stopAtEntry": false,
  "cwd": "D:\\back_up\\ProgrammingEvents\\AdventOfCode\\2024\\Day20",
  "environment": [],
  "externalConsole": false,
  "MIMode": "gdb",
  "miDebuggerPath": "D:\\Build_Tool_Lib\\x86_64-14.2.0-release-win32-seh-ucrt-rt_v12-rev0\\mingw64\\bin\\gdb.exe",
  "setupCommands": [
    {
      "description": "Enable pretty-printing for gdb",
      "text": "-enable-pretty-printing",
      "ignoreFailures": true
    },
    {
      "description": "Set Disassembly Flavor to Intel",
      "text": "-gdb-set disassembly-flavor intel",
      "ignoreFailures": true
    }
  ],
  "logging": {
    "engineLogging": true,
    "trace": true,
    "traceResponse": true
  },
  "preLaunchTask": "C/C++: g++.exe build active file",
  "__configurationTarget": 6,
  "configSource": "workspaceFolder",
  "debugType": "debug"
}
Launch configuration:
{
  "name": "C/C++: g++.exe build and debug active file",
  "type": "cppdbg",
  "request": "launch",
  "program": "D:\\back_up\\ProgrammingEvents\\AdventOfCode\\2024\\Day20\\test.exe",
  "args": [],
  "stopAtEntry": false,
  "cwd": "D:\\back_up\\ProgrammingEvents\\AdventOfCode\\2024\\Day20",
  "environment": [],
  "externalConsole": false,
  "MIMode": "gdb",
  "miDebuggerPath": "D:\\Build_Tool_Lib\\x86_64-14.2.0-release-win32-seh-ucrt-rt_v12-rev0\\mingw64\\bin\\gdb.exe",
  "setupCommands": [
    {
      "description": "Enable pretty-printing for gdb",
      "text": "-enable-pretty-printing",
      "ignoreFailures": true
    },
    {
      "description": "Set Disassembly Flavor to Intel",
      "text": "-gdb-set disassembly-flavor intel",
      "ignoreFailures": true
    }
  ],
  "logging": {
    "engineLogging": true,
    "trace": true,
    "traceResponse": true
  },
  "preLaunchTask": "C/C++: g++.exe build active file",
  "__configurationTarget": 6,
  "configSource": "workspaceFolder",
  "debugType": "debug"
}
Other Extensions

No response

Additional Information

No response

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Inizia con la riproduzione minima in C++ e le configurazioni di avvio cppdbg fornite, confrontando externalConsole true e false su Windows con GDB. Verifica come viene creato il terminale del debugger e come si comportano al suo interno system("cls") e system("pause"); il lavoro è completato quando entrambi i comandi funzionano come previsto senza externalConsole e il comportamento esistente su Linux rimane intatto.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
cpp, vscode
Ambito
desktop-dev, devtools
Tipo di issue
Bug
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
35/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.