【问题标题】:Visual Studio Code - Breakpoints not working in fortran codeVisual Studio Code - 断点在 fortran 代码中不起作用
【发布时间】:2022-06-16 17:57:54
【问题描述】:

我是 VS Code 的新手,在调试 fortran 代码时遇到了麻烦,因为断点永远不会起作用并且会被跳过,就好像它们不存在一样。

我做了一个同样问题的测试程序:

program test

implicit none
real :: x

x = 10.0
print*, x

end program test

如果我在 print 语句处设置断点,调试器不会停止。

在运行期间,断点变为灰色,我收到此消息

Module containing this breakpoint has not yet loaded or the breakpoint address could not be obtained.

这是 tasks.json

{
"version": "2.0.0",
"tasks": [
    {
        "label": "compile",
        "type": "shell",
        "command": "gfortran",
        "args": [
            "test.f90"
        ],
        "options": {
            "cdw": "${workspaceRoot}"
        }
    }
]
}

还有这个 launch.json

{
"version": "0.2.0",
"configurations": [
    {
        "name": "Run GDB",
        "type": "cppdbg",
        "request": "launch",
        "program":"${workspaceRoot}/a.out",
        "args": [],
        "stopAtEntry": false,
        "cwd": "${workspaceRoot}",
        "externalConsole": false,
        "MIMode": "gdb",
        "preLaunchTask": "compile",
    },
    {
        "name": "Intel Debug Attach",
        "type": "cppvsdbg",
        "request": "attach",
        "processId": "${command:pickProcess}"
    }
]
}

我安装了扩展 C/C++、Xavier Hahn 的 fortran、Miguel Carvajal 的 Modern Fortran、Fortran IntelliSense 和 Fortran Breakpoint Support。

有人愿意帮我一把吗?

【问题讨论】:

  • 如何放置断点?
  • @VladimirF 通过单击编辑器中的行号旁边并放置一个红点,我进行了检查,它出现在断点列表中并且处于活动状态
  • 更新:在运行过程中断点变灰,我收到消息“包含此断点的模块尚未加载或无法获取断点地址。”
  • 哪个操作系统?
  • @VladimirF Linux Mint 20.3

标签: linux visual-studio-code fortran


【解决方案1】:

您的二进制文件中缺少调试符号。您需要在 tasks.json 中包含 -g 作为参数

{
"version": "2.0.0",
"tasks": [
    {
        "label": "compile",
        "type": "shell",
        "command": "gfortran",
        "args": [
            "-g",
            "-Wall",
            "test.f90"
        ],
        "options": {
            "cdw": "${workspaceRoot}"
        }
    }
]
}

附带说明,您只需要 Modern Fortran 扩展名


完全披露我是扩展的开发者之一

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-09-23
    • 1970-01-01
    • 2023-03-12
    • 2021-12-11
    • 2016-12-19
    • 2019-06-23
    • 1970-01-01
    相关资源
    最近更新 更多