public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
* About the debugging of gfortran arrays
@ 2005-06-25  6:43 Wu Zhou
  2005-06-29  9:20 ` Wu Zhou
  2005-06-30  3:23 ` Feng Wang
  0 siblings, 2 replies; 4+ messages in thread
From: Wu Zhou @ 2005-06-25  6:43 UTC (permalink / raw)
  To: fortran; +Cc: gdb

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: About the debugging of gfortran arrays
  2005-06-25  6:43 About the debugging of gfortran arrays Wu Zhou
@ 2005-06-29  9:20 ` Wu Zhou
  2005-06-30  3:23 ` Feng Wang
  1 sibling, 0 replies; 4+ messages in thread
From: Wu Zhou @ 2005-06-29  9:20 UTC (permalink / raw)
  To: fortran; +Cc: gdb

Hi,

Is there any comments on theses two problems.  I believe that there should 
be one way for gdb and gfortran to work well together. 

Do you think that it is okay for me to file two PRs against them?  

TIA.

Cheers
- Wu Zhou

On Sat, 25 Jun 2005, Wu Zhou wrote:

> 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
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* re: About the debugging of gfortran arrays
  2005-06-25  6:43 About the debugging of gfortran arrays Wu Zhou
  2005-06-29  9:20 ` Wu Zhou
@ 2005-06-30  3:23 ` Feng Wang
  2005-06-30  7:22   ` Wu Zhou
  1 sibling, 1 reply; 4+ messages in thread
From: Feng Wang @ 2005-06-30  3:23 UTC (permalink / raw)
  To: Wu Zhou, fortran; +Cc: gdb

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset=gb2312, Size: 2329 bytes --]

--- Wu Zhou <woodzltc@cn.ibm.com>дµÀ:

> 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!)

Yes, all array.

> 
> 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?  

IMHO, one dimension array is easy to be changed. But multi-dimension array is
not supported under this structure.

> 
> 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:
>
[snip] 
> 
> 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? 
> 
Ok. I think we can build nested array type like C FE and reserve other type
discriptors. But from the explanation in trans-type.c it seems hard to solve
some other problems. This should be comfirmed by maintainers. Paul B, Steven B,
give some comments?

It's not only gdb problem, but also affects performance and optimization on the
tree-level. We lose the dimension infomation and can not get correct data
dependency. This limits many optimizations like loop interchange and loop
distribution, etc.

I think you can file a bug report. See:
http://gcc.gnu.org/bugzilla


Best Regards,
Feng Wang

--
Creative Compiler Research Group,
National University of Defense Technology, China.


	

	
		
___________________________________________________________ 
ÑÅ»¢Ãâ·ÑGÓÊÏ䣭ÖйúµÚÒ»¾øÎÞÀ¬»øÓʼþɧÈų¬´óÓÊÏä
http://cn.mail.yahoo.com/?id=77071

^ permalink raw reply	[flat|nested] 4+ messages in thread

* re: About the debugging of gfortran arrays
  2005-06-30  3:23 ` Feng Wang
@ 2005-06-30  7:22   ` Wu Zhou
  0 siblings, 0 replies; 4+ messages in thread
From: Wu Zhou @ 2005-06-30  7:22 UTC (permalink / raw)
  To: Feng Wang; +Cc: fortran, gdb

[-- Attachment #1: Type: TEXT/PLAIN, Size: 2734 bytes --]

Hi Feng,

Thanks for your reply.  I had opened a bug: 

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=22244

and added you into the CC-list.  Thanks for looking into this.

Cheers
- Wu Zhou

On Thu, 30 Jun 2005, Feng Wang wrote:

> --- Wu Zhou <woodzltc@cn.ibm.com>写道:
> 
> > 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!)
> 
> Yes, all array.
> 
> > 
> > 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?  
> 
> IMHO, one dimension array is easy to be changed. But multi-dimension array is
> not supported under this structure.
> 
> > 
> > 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:
> >
> [snip] 
> > 
> > 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? 
> > 
> Ok. I think we can build nested array type like C FE and reserve other type
> discriptors. But from the explanation in trans-type.c it seems hard to solve
> some other problems. This should be comfirmed by maintainers. Paul B, Steven B,
> give some comments?
> 
> It's not only gdb problem, but also affects performance and optimization on the
> tree-level. We lose the dimension infomation and can not get correct data
> dependency. This limits many optimizations like loop interchange and loop
> distribution, etc.
> 
> I think you can file a bug report. See:
> http://gcc.gnu.org/bugzilla
> 
> 
> Best Regards,
> Feng Wang
> 
> --
> Creative Compiler Research Group,
> National University of Defense Technology, China.
> 
> 
> 	
> 
> 	
> 		
> ___________________________________________________________ 
> 雅虎免费G邮箱-中国第一绝无垃圾邮件骚扰超大邮箱
> http://cn.mail.yahoo.com/?id=77071
> 
> 
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2005-06-30  7:22 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-06-25  6:43 About the debugging of gfortran arrays Wu Zhou
2005-06-29  9:20 ` Wu Zhou
2005-06-30  3:23 ` Feng Wang
2005-06-30  7:22   ` Wu Zhou

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).