c - 如何使用GCC在VSCode上进行编译调试

标签 c gcc visual-studio-code

我发现了几种使用 GCC 编译器调试 C 的不同方法,但我希望默认启用调试。有什么办法可以通过我在 VSCode 中的 launch.json 中的设置来做到这一点?

这是我的 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": "${workspaceFolder}/a.out",
            "args": [],
            "stopAtEntry": false,
            "cwd": "${workspaceFolder}",
            "environment": [],
            "externalConsole": true,
            "MIMode": "gdb",
            "setupCommands": [
                {
                    "description": "Enable pretty-printing for gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                }
            ]
        }
    ]
}

最佳答案

将这些添加到您的 CFLAGS:-gdwarf-4 -g3

为此,请运行此命令:

export CFLAGS="${CFLAGS} -gdwarf-4 -g3"

参见 this链接以获取更多信息和this launch.json 中运行命令的链接。

关于c - 如何使用GCC在VSCode上进行编译调试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54969270/

相关文章:

c:计时器不允许程序完成

c++ - C++ (GCC) 中的四倍精度

visual-studio-code - 如何在 VS Code 中批量重命名文件?

powershell - 如何提高Powershell的调试速度

c - Cuda 中的算法

c 链式困惑

c++ - MinGW GCC.exe 从路径中删除所有\

java - 在 Java 代码上运行 GCC 预编译器

html - *.nunjucks 中的 VSCode/自动关闭

c++ - 什么语言创造了左值这个术语?