VS code gdb exiting immediately when run as vs code debugger

1

When I debug my application through a terminal and gdb, everything works as expected, however if I try to use gdb as the debugger for vs code, it exists immediately with output:

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).

This is my configuration file:

{
    "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
                }
            ]
        }
    ]
}
debugging
visual-studio-code
editor
asked on Stack Overflow Feb 11, 2018 by Makogan

1 Answer

4

First I would make sure that the program is not exiting with return code 1 by design (e.g., due to sanity checks etc.). You could start by setting

"stopOnEntry": true

in config file launch.json, then proceed by debugging stepwise through main().

answered on Stack Overflow Apr 24, 2018 by mrhd • edited Sep 5, 2020 by eljefedelrodeodeljefe

User contributions licensed under CC BY-SA 3.0