VS代码正在忽略c++;调试 我在VS代码中调试C++代码,但它不在断点上停止,可视化变量,监视和调用堆栈,这是它应该做的。而不是在调试控制台中打印: Breakpoint 1, 0x000000000040074a in main () [Inferior 1 (process 9445) exited normally] The program '/home/hashir/x/a.out' has exited with code 0 (0x00000000)
下面是launch.json文件:VS代码正在忽略c++;调试 我在VS代码中调试C++代码,但它不在断点上停止,可视化变量,监视和调用堆栈,这是它应该做的。而不是在调试控制台中打印: Breakpoint 1, 0x000000000040074a in main () [Inferior 1 (process 9445) exited normally] The program '/home/hashir/x/a.out' has exited with code 0 (0x00000000),c++,visual-studio-code,visual-studio-debugging,C++,Visual Studio Code,Visual Studio Debugging,下面是launch.json文件: { // 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", "
{
// 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": "(gdb) Launch",
"type": "cppdbg",
"request": "launch",
"program": "/home/hashir/x/a.out",
"args": [],
"stopAtEntry": false,
"cwd": "/home/hashir/x/",
"environment": [],
"externalConsole": true,
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
}
]
}
使用
-g
标记和g++/clang++将程序混合在一起,我发现如果源代码文件名包含空格,如“Binary Search.cpp”,VSCode将忽略断点,而不管“stop at entry”配置如何。虽然源文件的路径中包含空格,但从源文件名称中删除空格仍然有效。例如,“C++练习/BinarySearch.cpp”似乎是有效的
在GitHub上公开的问题中,有人建议非ascii字符可能会导致此类问题。这个问题简直毁了我的一天。事实证明,我所要做的就是运行构建任务,然后开始调试。
或者Ctrl+Shift
+B
,然后开始调试。“stopAtEntry”:false
应该是“stopAtEntry”:true
?谢谢,我也面临同样的问题。你的回答对我很有帮助。有没有特别说明在哪里输入这个标签?谢谢。@andreyb在编译时添加该标志,如在运行g++file.cpp命令时。