microsoft / microsoft/vscode-cpptools
System("cls") doesn't work in the debugger terminal.
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 6.2k
- Forks
- 1.7k
- Avg merge
- 14h 46m
- Merged PRs (30d)
- 61
Description
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.
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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the minimal C++ reproduction and the supplied cppdbg launch configurations, comparing externalConsole true and false on Windows with GDB. Check how the debugger terminal is created and how system("cls") and system("pause") behave there; done means both commands work as expected without externalConsole while existing Linux behavior remains intact.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, vscode
- Domain
- desktop-dev, devtools
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100