我正在 VS Code 中调试 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 文件:
{
// 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++ 编译程序。
关于c++ - VS代码忽略了C++调试中的断点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48268226/