When building and debugging Fortran on Windows, I investigated what kind of tools should be combined. I was a little stuck with a problem that did not stop at the breakpoint in debugging, but it was solved. I am thinking with the minimum necessary configuration.
・ Windows 10 ・ Visual Studio Code
-Download "tdm64-gcc-***. Exe" from TDM-GCC
{
// Learn the available attributes using IntelliSense.
// Hover and display the description of existing attributes.
// Check the following for more information: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "(gdb) start",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/a.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"miDebuggerPath": "C:/TDM-GCC-64/bin/gdb.exe",
"setupCommands": [
{
"description": "Enable reformatting of gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
}
]
}
-Build work is executed at the command prompt, not on VS Code. -Be sure to add the option "-g" to debug this time.
C:\Temp>gfortran -g fortran_program.f90
-The exe file is created.
-Open the Fortran file with VS Code and hit the debug point to the left of the number of lines. -Execution-> Debug execution. Then, it stops at the debug point properly!
I was a little clogged up with the need for options when building, but I'm glad I did. When I was a student, I could only debug with print statements, so I'm deeply impressed that I can debug with Fortran as well. Please use it if you like.
I'm not sure if "gfortran -g" can be run from VS Code. I wonder how to do it, maybe it's easy, but I'll leave it here.
Recommended Posts