Debugging Fortran code with gdb under Visual Studio Code in Windows

Viewed 269

I saw other posts like this that explain how to debug with gdb. But it still wont work with me. I installed the following extensions:

enter image description here

I created the following launch.json:

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Run GDB",
            "type": "cppdbg",
            "request": "launch",
            "program": "${workspaceFolder}\run.exe",
            "args": [],
            "stopAtEntry": false,
            "cwd": "${workspaceFolder}",
            "externalConsole": false,
            "MIMode": "gdb",
            "preLaunchTask": "compile_with_gfortran"      
        }
    ]
}

and the following tasks.json

{
    "version": "2.0.0",
    "tasks": [

        {
            "label": "compile_with_gfortran",
            "type": "shell",
            "command": "gfortran -o run.exe example.f90 -g",
            "options": {
                "cwd": "${workspaceFolder}"
            },
            "group": {
                "kind": "build",
                "isDefault": true
            }            
        }
    ]

}

Both json files are inside the folder .vscode. By hitting shift-ctrl-B the task builds correctly and creates the executable. When I click F5 to start the compiler, the preLaunchTask runs, the compiling buttons (step in etc...) show up but nothing attaches to the Fortran file, although I added breakpoints into proper locations. And nothing shows up in the debug console. Any suggestion?

0 Answers
Related