我发现了几种使用 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"
关于c - 如何使用GCC在VSCode上进行编译调试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54969270/