Fortran module variables not available in debuggers

I compiled Fortran code that contains several modules using both gfortran 4.4 and intel 11.1, and then tried to debug it using both gdb and DDT. In all cases, I do not see the values ​​of any variables declared in the modules. These global variables have values ​​because the code is still executing correctly, but I don't see that the values ​​are in my debuggers. Local variables are beautiful. I am having trouble finding a solution to this problem elsewhere on the Internet, so there may not be a simple solution, but it will be very difficult to debug my code if I cannot see the values ​​of any of my global variables.

+7
source share
2 answers

With the newer GDBs (7.2, if I remember correctly), the debugging modules are simple. Take the following program:

module modname integer :: var1 = 1 , var2 = 2 end module modname use modname, only: newvar => var2 newvar = 7 end 

Now you can run:

 $ gfortran -g -o mytest test.f90; gdb --quiet ./mytest Reading symbols from /dev/shm/mytest...done. (gdb) b 6 Breakpoint 1 at 0x4006a0: file test.f90, line 6. (gdb) run Starting program: /dev/shm/mytest Breakpoint 1, MAIN__ () at test.f90:6 6 newvar = 7 (gdb) p newvar $1 = 2 (gdb) p var1 No symbol "var1" in current context. (gdb) p modname::var1 $2 = 1 (gdb) p modname::var2 $3 = 2 (gdb) n 7 end (gdb) p modname::var2 $4 = 7 (gdb) 
+4
source

In gdb, try referencing global variables with names like __modulename__variablename

You can verify that this is the correct scheme using nm and grep to find one of your global variables in the symbols of your program.

If this does not work, make sure you are using the latest version of gdb.

Here is a thread on this topic: http://gcc.gnu.org/ml/fortran/2005-04/msg00064.html

+3
source

All Articles