debugging - 无法运行 fortran 调试器。 Visual Studio Code

标签 debugging visual-studio-code fortran gdb gfortran

我正在尝试在 Visual Studio 代码(ubuntu 18.04)上调试 fortran 文件。

我安装了以下扩展

enter image description here

我的launch.json文件如下

"version": "0.0.1",
"configurations": [
    {
        "name": "Fortran Launch (GDB)",
        "type": "cppdbg",
        "request": "launch",
        "targetArchitecture": "x86",
        "program": "${workspaceRoot}/./a.out",
        "miDebuggerPath": "gdb",
        "args": [],
        "stopAtEntry": false,
        "cwd": "${workspaceRoot}",
        "externalConsole": true,
        "preLaunchTask": "gfortran"
    }
]

因为我使用的是 linux,所以我不需要给出 gfortran 的路径。我还尝试通过更改 .exe 来稍微更改 launch.json到 linux 扩展。我已经在问题中更新了它。但是调试器仍然没有运行并在控制台中给出以下错误
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word".
=cmd-param-changed,param="pagination",value="off"
Stopped due to shared library event (no libraries added or removed)
Loaded '/lib64/ld-linux-x86-64.so.2'. Symbols loaded.
Breakpoint 1, 0x0000555555554a60 in main ()
[Inferior 1 (process 24472) exited normally]
The program '/home/m/gSoC/GasSimulator/./a.out' has exited with code 0 (0x00000000).

最佳答案

我不知道如何解决您的具体问题,但在这里我如何在 Visual Studio Code 中调试 Fortran 程序。

  • 我安装了 3 个插件:“C/C++”、Xavier Hahn 的“fortran”和“Fortran Breakpoint Support”
  • 我按照 fortranwiki.org 的建议编译了我的程序.
  • gfortran SOME FORTRAN FILES -g -Wall -Wextra -Warray-temporaries -Wconversion -fimplicit-none -fbacktrace -ffree-line-length-0 -fcheck=all -ffpe-trap=zero,overflow,underflow -finit-real=nan
    
  • 我生成了一个 launch.json 文件,只改变了我的程序路径和参数,没有别的。这给出了类似
  • 的内容
        {
            "version": "0.2.0",
            "configurations": [
                {
                    "name": "(gdb) Lancer",
                    "type": "cppdbg",
                    "request": "launch",
                    "program": "${workspaceFolder}/a.out",    // <-- Change this
                    "args": [],                               // <-- Change this
                    "stopAtEntry": false,
                    "cwd": "${workspaceFolder}",              // <-- And maybe this
                    "environment": [],
                    "externalConsole": false,
                    "MIMode": "gdb",
                }
            ]
        }
    

    也许在 2018 年这是不可能的或 super 困难的,谁知道呢?从那时起,VSCode 及其插件进行了大量更新。

    关于debugging - 无法运行 fortran 调试器。 Visual Studio Code ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51866003/

    相关文章:

    debugging - 调试 WF 工作流时 Visual Studio 2015 未命中断点

    visual-studio-code - vscode 在自动完成弹出窗口中为所选项目自定义主题颜色

    C 或 fortran 库无法在 R 中加载

    fortran - 在 Fortran 函数声明的第二行找到星号 *

    c - 从哪里开始修改开源软件?

    xcode - GDB 与 LLDB 调试器

    android - 如何判断哪些线程产生了所有垃圾?

    android - 即使在出厂重置后也保持 USB 调试,也绕过 RSA key

    git - VSCode,Perforce : "SOURCE CONTROL No source control providers registered."

    python - VS Code 未发现 Python 单元测试测试