I am debugging some code that contains many Fortran derived types with various parts. These are usually imported across modules. Unfortunately, gdb with VScode seems to have trouble inspecting derived types when debugging.
If I enter the variable derived%part
as a watch expression for example, it returns -var-create: unable to create variable
. Similarly, the derived type variables do not appear in the list of variables whilst debugging.
Currently when I need to inspect a derived type variable, the only way to do so is to stop debugging, and manually alter the code to include a local variable equal to the derived type's part. In the example below, to find out what value of foo%bar
is passed to the function a_function
I would have to declare a new variable, like so
module setup
type(customDerived) :: foo
foo%bar = 1
end module setup
module example
use setup, only: foo
integer(ik) :: foobar <-- Stop debugging, add these lines, restart and inspect 'foobar'
foobar = foo%bar <--
a_function(foo%bar)
end module example
This is obviously very time consuming, and I don't know why VSCode should not be able to treat derived types. Any ideas? The following are the gfortran compiler flags I currently have turned on in the makefile
-Og -g -Wall -Wextra -Wline-truncation -pedantic -fimplicit-none -fcheck=all -fbacktrace
question from:
https://stackoverflow.com/questions/65921226/inspect-derived-types-in-vscode-while-debugging-fortran 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…