簡體   English   中英

斷點在 Visual Studio Code 中的 Fortran 代碼中不起作用

[英]Breakpoints not working in Fortran code in Visual Studio Code

我是 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。

有人願意幫我一把嗎?

您缺少二進制文件中的調試符號。 您需要在tasks.json中包含-g作為參數

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

作為旁注,您只需要Modern Fortran擴展


完全披露我是擴展的開發者之一

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM