Global arrays/structs not accessible in gdb while debugging gfortran executable in Eclipse -


i'm using eclipse (neon.3 release 4.6.3) gdb 7.11.1 , gfortran 5.4.0, debug executable, seems possible watch local subroutine variables , simple external variables properly. consider 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,          : extvar, extarray, extstruct     type (real::8), intent(in)  :: invar     integer(kind=4)             ::     ...     !debugger breakpoint inserted here check variable visibility   end end 

eclipse's variable list show local variables (i) , inputs (invar) if they're modules/arrays, external/global variables (extvar, extarray, extstruct) don't show in list. if try typing them manually "expressions" view, gives errors being unable evaluate missing symbols:

multiple errors reported.

1) failed execute mi command: -var-create - * extvar error message debugger end: -var-create: unable create variable object

2) unable create variable object

3) failed execute mi command: -data-evaluate-expression extvar error message debugger end: no symbol "extvar" in current context.

4) failed execute mi command: -var-create - * extvar error message debugger end: -var-create: unable create variable object

i discovered special notation used compiler store these global variables in binary executable using command:

nm <binaryname> | grep <modulename> 

i can see global module members in gdb typing:

print __<modulename>_mod_<membername> 

however, it works simple member types in module! example can see integer member properly:

print __ext_class_mod_extvar $1 = 0 

for static array of integers, improperly only prints first element, preventing me viewing of member array's other elements:

print __ext_class_mod_extarray $2 = 0 print __ext_class_mod_extarray(1:4) cannot perform substring on type 

for structure type, improperly only prints first member (svar1), preventing me viewing of structure's other members:

print __ext_class_mod_extstruct $3 = 0 print __ext_class_mod_extstruct%svar2 attempt extract component of value not structure. 

i read here might problem gfortran, not gdb, because works fine when using intel compilers. there possibly flag need set when compiling? use -g -o0

edit: issue has been resolved in versions (gfortran 6.2.0 gdb 7.12 on macos, not on same versions in ubuntu). update latest version before trying steps below.

i found workaround that's compatible in eclipse. seems binary isn't tracking information variable types, addresses in memory. variables can viewed casting them proper type. enter __ext_class_mod_extstruct eclipse's "expressions" tab , right-click entry , chose "cast type..." entering extstruct_type! alternatively, enter

(extstruct_type)__ext_class_mod_extstruct 

in "expression" tab. note asterisks omitted (differing c syntax). same can achieved @ gdb command line , individual members obtainable name using % delimiter:

print ((extstruct_type)(__ext_class_mod_extstruct) $5 = (0, 0) print ((extstruct_type)(__ext_class_mod_extstruct)%svar2 $6 = 0 

eclipse's "expression" option "display array..." fails seems using c syntax pointer arithmetic (*) isn't compatible gdb fortran, works when manually omitting asterisks:

print __ext_class_mod_extarray@4 $7 = (0, 0, 0, 0) print __ext_class_mod_extarray(2) cannot perform substring on type 

note accessing individual array elements still fails in versions. let's hope fix issue once , in newer releases.


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -