I'm trying to debug a fortran90 application, using vscode with gdb. In one particular function:
subroutine get_hamiltonian(...)
real :: list(:)
...
end subroutine get_hamiltonian
I can not print the value of variable list
. Specifically, I get this error:
(gdb) list
-var-create: unable to create variable object
I have checked that list is actually correctly instantiated and I have managed to print
the list too, and it works. Somehow, inside gdb, printing the value of list
doesn't work. Why?
I'm trying to debug a fortran90 application, using vscode with gdb. In one particular function:
subroutine get_hamiltonian(...)
real :: list(:)
...
end subroutine get_hamiltonian
I can not print the value of variable list
. Specifically, I get this error:
(gdb) list
-var-create: unable to create variable object
I have checked that list is actually correctly instantiated and I have managed to print
the list too, and it works. Somehow, inside gdb, printing the value of list
doesn't work. Why?
2 Answers
Reset to default 0The problem is that inside GDB, keyword list
is reserved. Specifically:
list linenum
Print lines centered around line number linenum in the current source file.
So, the quickest solution to read the value of that variable is to rename it. For example, if you rename the variable list
-> alist
, then printing alist
will work. For the purposes of debugging the application this should suffice.
Just use print
to print variables using GDB. Having to rename to rename variables in your code just to be able to debug it is absurd.
(gdb) print list
$2 = (1, 2, 3, 4, 5)
print list
? – Vladimir F Героям слава Commented Mar 31 at 13:47