VS代码gdb在作为vs代码调试器

时间:2018-02-11 21:47:50

标签: debugging visual-studio-code editor

当我通过终端和gdb调试我的应用程序时,一切都按预期工作,但是如果我尝试使用gdb作为vs代码的调试器,它会立即存在输出:

Breakpoint 1, main (argc=1, argv=0x7fffffffe638) at /home/kronos/Desktop/voxel-world/source/main.cpp:60
60  {
[Inferior 1 (process 7771) exited with code 01]
The program '/home/kronos/Desktop/voxel-world/build/voxel-world' has exited with code 1 (0x00000001).

这是我的配置文件:

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "(gdb) Launch",
            "type": "cppdbg",
            "request": "launch",
            "program": "${workspaceRoot}/build/voxel-world",
            "args": [],
            "stopAtEntry": false,
            "cwd": "${workspaceRoot}",
            "environment": [],
            "externalConsole": true,
            "MIMode": "gdb",
            "setupCommands": [
                {
                    "description": "Enable pretty-printing for gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                }
            ]
        }
    ]
}

1 个答案:

答案 0 :(得分:3)

首先,我要确保程序没有按设计退出返回码1(例如,由于健全性检查等)。 您可以从设置

开始
"stopAtEntry": true

在配置文件launch.json中,然后逐步调试main()