我是Linux下gdb的初学者。 当我尝试调试使用ifort和-c,-g选项编译的程序时,我想检查几个数组的绑定。 不幸的是,我在谷歌找不到任何信息如何打印与gdb调试器绑定的数组。
[更新]
我有一个带可分配的公共数组的模块,它在这个模块的子程序中正确分配。
在主程序中(在调用子程序之后),我尝试使用whatis
并查看(*,*)
而不是形状。
答案 0 :(得分:5)
您可以使用whatis命令查看数组边界:例如,
program arr
real, dimension(2:41) :: arr1
real, allocatable, dimension(:), target :: arr2
integer :: i
allocate(arr2(40))
forall(i = 2:41) arr1(i) = i
arr2 = arr1 + 2
print *, arr1(2)
deallocate(arr2)
end program are
跑步给出
$ gfortran -g foo.f90
$ gdb a.out
[...]
(gdb) break 11
Breakpoint 1 at 0x400b01: file foo.f90, line 11.
(gdb) run
[...]
Breakpoint 1, arr () at foo.f90:11
11 print *, arr1(2)
(gdb) whatis arr1
type = real(kind=4) (2:41)
(gdb) whatis arr2
type = real(kind=4) (40)