Debugging in Visual Studio Code with Conda environment

Previously, I installed the VSCode extension “Fortran Breakpoint Support” which is incompatible with “Modern Fortran”. However, with the breakpoint support and the following launch.json, I was able to run the code in debug mode, pause it, and see that it stops at a line in the code files. However, for some reason, I was not able to place breakpoints via the GUI. So I thought: if I can use the launch.json to run debug mode with the breakpoint support, surely I can do the same with Modern Fortran. However, with Modern Fortran, it immediately complains that “cppdbg” is not supported. Why is it not supported, and what do I need to do to make it work?

{
    // 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) Fortran",
        "type": "cppdbg",
        "request": "launch",
        "program": "${workspaceFolder}/src/LApx-dbg",
        "args": [], // Possible input args for a.out
        "stopAtEntry": false,
        "cwd": "${workspaceFolder}/example_inputs/TestEigen_CircleIsotropic_SameStiff",
        "environment": [],
        "externalConsole": false,
        "MIMode": "gdb",
        "setupCommands": [
          {
            "description": "Enable pretty-printing for gdb",
            "text": "-enable-pretty-printing",
            "ignoreFailures": true
          }
        ]
      }
    ]
  }
2 Likes

Even though this forum seems to be pretty dead, but in case anyone else found this in the future, I fixed the issue of cppdbg by installing C/C++ Runner and then with the launch.json above, I was able to debug my Fortran code.

3 Likes

@FQVBSina welcome to the forum. I am happy you were able to figure it out. Go ahead and report the issue at the fortls github repository: GitHub · Where software is built

1 Like