【发布时间】:2014-05-23 19:13:43
【问题描述】:
我正在尝试使用 gdb 调试以下代码 (GNU gdb (Ubuntu/Linaro 7.4-2012.04-0ubuntu2.1) 和 gfortran (gcc-版本 4.6.3)。如果我启动 gdb 并逐步执行子例程 有趣,我想在其中打印派生类型“mytype”的变量 模块类测试。打印变量“int”很容易,它也是 在模块“class_test”中使用命令: print class_test::int 。 我的问题是如何打印变量 int1, int2 ... int4 如果 gdb 逐步完成子程序的乐趣?
!!类定义
module class_test
integer :: int = 1
type, public :: mytype
private
integer :: int1 = 2
integer :: int2 = 3
integer :: int3 = 4
integer :: int4 = 5
contains
procedure, pass(this) :: fun
end type mytype
contains
subroutine fun ( this )
class(mytype) :: this
write (*,*) "subroutine"
end subroutine fun
end module class_test
!! Program
program test
use class_test
type(mytype) :: struct
write (*,*) "whateveryouwant"
call struct%fun()
end program
【问题讨论】:
-
这将是一个大问题。 GDB 可能不理解 gfortran 多态描述符。试着在某处找出它的结构。