c++ - VS代码忽略了C++调试中的断点

标签 c++ visual-studio-code visual-studio-debugging

我正在 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/

相关文章:

c++ - 类构造函数和对象实例化/初始化 C++/GCC

c++ - 如何在 Visual Studio 中调试错误的调用堆栈

f# - 为什么 Visual Studio 2010 调试器不拾取调试符号来处理 F# 序列中的异常?

visual-studio-code - Jest Puppeteer - 为其设置 Visual Studio Code

asp.net-core-mvc - 在 .NET CORE MVC 6 应用程序中调试未命中断点

c++ - cout 语句如何影响编写的代码的 O/P?

c++ - 如何创建一个工厂函数模板来构造给定任意数量参数的对象?

一个文件中的c++类

visual-studio-code - 如何在vscode中侧面加载字体?

visual-studio-code - 在 VSCode 中运行任务时如何拆分终端?