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

问题描述 投票:1回答:1

我已经发现了一些使用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
                }
            ]
        }
    ]
}
c gcc visual-studio-code
1个回答
3
投票

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

为此,请运行以下命令:

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

有关更多信息,请参阅this链接;有关this中运行命令的信息,请参阅launch.json链接。

© www.soinside.com 2019 - 2024. All rights reserved.