I use Eclipse (Neon.3 Release 4.6.3) with gdb 7.11.1 and gfortran 5.4.0 to debug the executable, but it seems that you can only observe local subroutine variables and simple strong> external variables. Consider this simplified example:
module ext_class type extstruct_type integer(kind=4), ::svar1 integer(kind=4), ::svar2 end type extstruct_type integer(kind=4), save :: extvar integer(kind=4), dimension(4), save :: extarray type (extstruct_type), save :: extstruct end module mod subroutine foo(invar) use ext_class, only : extvar, extarray, extstruct type (real::8), intent(in) :: invar integer(kind=4) :: i ... !Debugger breakpoint inserted here to check variable visibility end end
List of Variables Eclipse will correctly display local variables ( i ) and inputs ( invar ), even if they are modules / arrays, but any external / global variables ( extvar, extarray, extstruct ) are not displayed in the list. If I try to enter them manually in the expression view, this will give errors in that you cannot evaluate the missing characters:
Several bugs reported.
1) Failed to execute MI command: -var-create - * extvar Error message from the end of the debugger: -var-create: cannot create a variable object
2) Unable to create a variable object
3) The MI command failed to execute: -data-evaluation-expression extvar Error message from the back of the debugger: in the current context, the symbol "extvar" is missing.
4) Failed to execute the MI command: -var-create - * extvar Error message from the end of the debugger: -var-create: cannot create a variable object
I found a special notation used by the compiler to store these global variables in a binary executable using the command:
nm <binaryname> | grep <modulename>
In general, I can see the global members of a module in gdb by typing:
print __<modulename>_MOD_<membername>
However, it only works for simple member types in a module ! For example, I can correctly see the integer element:
print __ext_class_MOD_extvar $1 = 0
For a static array of integers, it only prints the first element incorrectly, which prevents me from viewing any of the elements in the array of other elements:
print __ext_class_MOD_extarray $2 = 0 print __ext_class_MOD_extarray(1:4) Cannot perform substring on this type
For the structure type, it only incorrectly prints the first element ( svar1 ), which prevents me from viewing any structure of other members:
print __ext_class_MOD_extstruct $3 = 0 print __ext_class_MOD_extstruct%svar2 Attempt to extract a component of a value that is not a structure.
I read here that this could be a problem with gfortran, not gdb, because it works fine when using Intel compilers. Is it possible to set an additional flag during compilation? I already use -g -O0