visual-studio-codegdb

GDB debugger terminates after using step over


I'm using visual studio code (1.93.1) along with GDB debugger (15.1) and g++ compiler (14.2.0) on windows. Whenever I use a breakpoint and try to click the step-over button, the debugger stops working, but doesn't terminate (there's a gif explaining what happens below) for context here's my tasks.json:

{
    "tasks": [
        {
            "type": "cppbuild",
            "label": "C/C++: g++.exe build active file",
            "command": "C:\\msys64\\mingw64\\bin\\g++.exe",
            "args": [
                "-fdiagnostics-color=always",
                "-g",
                "${file}",
                "-o",
                "${fileDirname}\\${fileBasenameNoExtension}.exe"
            ],
            "options": {
                "cwd": "${fileDirname}"
            },
            "problemMatcher": [
                "$gcc"
            ],
            "group": {
                "kind": "build",
                "isDefault": true
            },
            "detail": "Task generated by Debugger."
        }
    ],
    "version": "2.0.0"
}

launch.json:

{
    "configurations": [
        {
            "name": "C/C++: g++.exe build and debug active file",
            "type": "cppdbg",
            "request": "launch",
            "program": "${fileDirname}/${fileBasenameNoExtension}.exe",
            "args": [],
            "stopAtEntry": false,
            "cwd": "${fileDirname}",
            "environment": [],
            "externalConsole": false,
            "MIMode": "gdb",
            "miDebuggerPath": "C:/msys64/mingw64/bin/gdb.exe",
            "setupCommands": [
                {
                    "description": "Enable pretty-printing for gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                },
                {
                    "description": "Set Disassembly Flavor to Intel",
                    "text": "-gdb-set disassembly-flavor intel",
                    "ignoreFailures": true
                }
            ],
            "preLaunchTask": "C/C++: g++.exe build active file"
        }
    ],
    "version": "2.0.0"
}

gif

I've tried reinstalling the compiler and debugger multiple times with no success, everything in the debugger works except for this functionality.

Edit: here's a code example that causes this problem:

#include <bits/stdc++.h>

using namespace std;

int mod (int b, int p, int m)
{
    if (p==0) return 1;
    if (p%2==0)
    {
        int r = mod(b,p/2,m);
        return (r*r)%m;   
    } else {
        return (b%m*mod(b,p-1,m))%m;   
    }
}


int main()
{
    int T; scanf("%d", &T);
    while (T--)
    {
        int b,p,m; cin >> b >> p >> m;
        printf("%d\n", mod(b,p,m));
    }
}

By using this as input

1
18132
17
17

And putting a braekpoint on line 8 and using step over, it breaks.


Solution

  • Quoted from this
    The Gui debug hang is solved by added the following to the launch.json file:

    "setupCommands": [
    {
    "description": "Disable target async",
    "text": "set target-async off",
    "ignoreFailures": true
    }