This is the mail archive of the gdb@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

About the debugging of gfortran arrays


Hello all,

I am trying to use gdb to debug gfortran program and encountered some 
problems with arrays:

1. The first one is about the lower bound.  It seems that gfortran change 
the lower bound of some arrays to 0 by default (I got this feeling from my 
experience and I also see this kind of transfer in part of the code in 
gcc/fortran/trans-type.c. Dunno know whether it apply to all arrays. 
Anyone could confirm or deny this?  Thanks in advance!)

To handle this, GDB need to make responsive change.  But I have one 
question here: is this kind of design (change the lower bound of array to 
zero) indispensible here?  Is it ok to still output the original bounds in the 
debug info?  

2. The second one is about two-dimension array.  In the debuginfo output 
by gfortran, two-dimension array will be flatten to one-dimension.  Take a 
look at the following testcase please:

       program array2
       integer a(5, 5)

       do i = 1, 5
         do j = 1, 5
           a(i, j) = i * j
           write (*, *) a(i, j)
         end do
       end do

       end program
       
After using gfortran to compile this testcase, I can use readelf to get
the following debuginfo:

 <2><89>: Abbrev Number: 3 (DW_TAG_variable)
     DW_AT_name        : a
     DW_AT_decl_file   : 1
     DW_AT_decl_line   : 2
     DW_AT_type        : <be>
     DW_AT_location    : 3 byte block: 75 94 7f         (DW_OP_breg5: 
-108)
 ...
 <1><be>: Abbrev Number: 7 (DW_TAG_array_type)
     DW_AT_type        : <b6>
 <2><c3>: Abbrev Number: 8 (DW_TAG_subrange_type)
     DW_AT_type        : <b6>
     DW_AT_lower_bound : 0
     DW_AT_upper_bound : 24
     
>From the above, we can see that two-dimension array a(5, 5) is changed to
a one-dimension array with 25 elements (0 - 24).  

Although there is no problem for the output binary, but it make some 
trouble for GDB.  So I am thinking of whether there is any solution
for this in gfortran's side? 

For example, treat it as one-dimension array in the outputed binary, but
still output two-dimension one in the debug information.  Maybe others? 

Just my two cents. Any comments are highly appreciated. 

Cheers
- Wu Zhou


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]