我正在尝试在 Visual Studio 代码(ubuntu 18.04)上调试 fortran 文件。
我安装了以下扩展
我的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 程序。
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
{
"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/