vscode-cpptools icon indicating copy to clipboard operation
vscode-cpptools copied to clipboard

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

Open RabbitSeries opened this issue 10 months ago • 3 comments

Environment

  • OS and version: Microsoft Windows 11 Pro 10.0.26100 N/A Build 26100
  • VS Code: 1.96.2
  • C/C++ extension: [email protected]
  • 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

RabbitSeries avatar Jan 06 '25 17:01 RabbitSeries