internalConsoleOptions
"configurations": [
{
"name": "(gdb) Launch",
"request": "launch",
"program": "${workspaceFolder}/src/smud",
"args": ["3000"],
"stopAtEntry": false,
"cwd": "${workspaceFolder}/area",
"preLaunchTask": "Run the makefile",
"internalConsoleOptions": "neverOpen",
"postDebugTask": "Return to build"
}
]
tosss.json:
{
"type": "shell",
"label": "Return to build",
"command": "cd ${workspaceFolder}/src/build; exec $SHELL",
"options": {
"cwd": "${workspaceFolder}/src/build"
},
"presentation": {
"reveal": "always",
"panel": "new",
"echo": false
}
}
当我拥有过程运行时,这可以在我拥有的时候起作用,但是我遇到了该过程永无止境的问题。一旦我杀死它,终端就会关闭,然后重新启动回到工作的DIR。如果我没有
exec $SHELL
,它立即重置,好像任务甚至不存在。感谢您的帮助!
当在Visual Studio代码中进行调试时,该程序完成执行后通常会立即关闭,尤其是当它是构建过程或调试配置的一部分时。要在调试后将终端打开,您可以在工作区中修改
launch.json配置。以下是:步骤保持终端开放
在VS代码中,打开命令调色板(Mac上的
exec $SHELL
Ctrl+Shift+P
Cmd+Shift+P
Debug: Open launch.json
属性,以
launch.json
"console"
。例如:
integratedTerminal
externalTerminal
- 在VS代码的集成终端中运行该程序。端,使用
{
"version": "0.2.0",
"configurations": [
{
"name": "Debug Program",
"type": "cppdbg", // or the type of your debugger (e.g., "node", "python").
"request": "launch",
"program": "${workspaceFolder}/build/myprogram", // Path to your executable.
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}/build", // Your build directory.
"environment": [],
"console": "integratedTerminal" // Use the integrated terminal.
}
]
}
在单独的终端窗口中打开程序。
run debug配置::
开始调试(
"console": "integratedTerminal"
保持终端会话手动打开: 如果您想手动使终端打开:
,例如,在C ++中:
"console": "externalTerminal"
F5
#include <iostream>
int main() {
std::cout << "Press Enter to exit...";
std::cin.get();
return 0;
}
,您确保终端会话在调试结束后不会立即关闭。