Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
259 views
in Technique[技术] by (71.8m points)

visual studio code - Inspect derived types in VSCode while debugging Fortran

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...