Mirror of the gdb mailing list
 help / color / mirror / Atom feed
* multidimensional fortran arrays
@ 2010-09-02 17:29 Mathew Yeates
  2010-09-03  5:47 ` Jan Kratochvil
  0 siblings, 1 reply; 8+ messages in thread
From: Mathew Yeates @ 2010-09-02 17:29 UTC (permalink / raw)
  To: gdb

Hi
I mentioned this before but got no reply. So I have been getting the
address of the array and using "x/f".
But now I am using 4 dimensional arrays and this is getting old.

Anyone have any ideas how to fix this? print myarray(1,2) -> "so such
vec element"

-Mathew


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

* Re: multidimensional fortran arrays
  2010-09-02 17:29 multidimensional fortran arrays Mathew Yeates
@ 2010-09-03  5:47 ` Jan Kratochvil
  2010-09-07  4:34   ` Mathew Yeates
  0 siblings, 1 reply; 8+ messages in thread
From: Jan Kratochvil @ 2010-09-03  5:47 UTC (permalink / raw)
  To: Mathew Yeates; +Cc: gdb

On Thu, 02 Sep 2010 19:29:07 +0200, Mathew Yeates wrote:
> I mentioned this before but got no reply. So I have been getting the
> address of the array and using "x/f".
> But now I am using 4 dimensional arrays and this is getting old.
> 
> Anyone have any ideas how to fix this? print myarray(1,2) -> "so such
> vec element"

For some reason it really does not work even for static arrays.  
program a
  integer :: v (2, 3, 4)
  v (:, :, :) = 10
  v (2, 3, 4) = 20
  v (2, 3, 4) = 20 ! line 5
end
(gdb) b 5
(gdb) r
(gdb) p v(2,3,4)
no such vector element

It works on archer-jankratochvil-vla
(gdb) p v(2,3,4)
$1 = 20
available at
	http://sourceware.org/gdb/wiki/ArcherBranchManagement
(or Fedora releases) but the support has some other problems and I should
merge it to FSF GDB soon.


Thanks,
Jan


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

* Re: multidimensional fortran arrays
  2010-09-03  5:47 ` Jan Kratochvil
@ 2010-09-07  4:34   ` Mathew Yeates
  2010-09-07 22:19     ` Andrew Burgess
  0 siblings, 1 reply; 8+ messages in thread
From: Mathew Yeates @ 2010-09-07  4:34 UTC (permalink / raw)
  To: Jan Kratochvil; +Cc: gdb

gdb shouldn't claim to support gfortran until this  is fixed.
Seriously, I cant print the value of a multidimensional  array?

On Thu, Sep 2, 2010 at 10:46 PM, Jan Kratochvil
<jan.kratochvil@redhat.com> wrote:
> On Thu, 02 Sep 2010 19:29:07 +0200, Mathew Yeates wrote:
>> I mentioned this before but got no reply. So I have been getting the
>> address of the array and using "x/f".
>> But now I am using 4 dimensional arrays and this is getting old.
>>
>> Anyone have any ideas how to fix this? print myarray(1,2) -> "so such
>> vec element"
>
> For some reason it really does not work even for static arrays.
> program a
>  integer :: v (2, 3, 4)
>  v (:, :, :) = 10
>  v (2, 3, 4) = 20
>  v (2, 3, 4) = 20 ! line 5
> end
> (gdb) b 5
> (gdb) r
> (gdb) p v(2,3,4)
> no such vector element
>
> It works on archer-jankratochvil-vla
> (gdb) p v(2,3,4)
> $1 = 20
> available at
>        http://sourceware.org/gdb/wiki/ArcherBranchManagement
> (or Fedora releases) but the support has some other problems and I should
> merge it to FSF GDB soon.
>
>
> Thanks,
> Jan
>


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

* RE: multidimensional fortran arrays
  2010-09-07  4:34   ` Mathew Yeates
@ 2010-09-07 22:19     ` Andrew Burgess
  2010-09-09 16:37       ` Mathew Yeates
  0 siblings, 1 reply; 8+ messages in thread
From: Andrew Burgess @ 2010-09-07 22:19 UTC (permalink / raw)
  To: Mathew Yeates, Jan Kratochvil; +Cc: gdb

[-- Attachment #1: Type: text/plain, Size: 1656 bytes --]

The attached patch might fix the issue for you. It should apply cleanly to 7.2

I'll write a test and submit to the patches list in a couple of days. Let me know if you run into any problems.


Andrew



> -----Original Message-----
> From: gdb-owner@sourceware.org [mailto:gdb-owner@sourceware.org] On
> Behalf Of Mathew Yeates
> Sent: 07 September 2010 05:34
> To: Jan Kratochvil
> Cc: gdb@sourceware.org
> Subject: Re: multidimensional fortran arrays
> 
> gdb shouldn't claim to support gfortran until this  is fixed.
> Seriously, I cant print the value of a multidimensional  array?
> 
> On Thu, Sep 2, 2010 at 10:46 PM, Jan Kratochvil
> <jan.kratochvil@redhat.com> wrote:
> > On Thu, 02 Sep 2010 19:29:07 +0200, Mathew Yeates wrote:
> >> I mentioned this before but got no reply. So I have been getting the
> >> address of the array and using "x/f".
> >> But now I am using 4 dimensional arrays and this is getting old.
> >>
> >> Anyone have any ideas how to fix this? print myarray(1,2) -> "so
> such
> >> vec element"
> >
> > For some reason it really does not work even for static arrays.
> > program a
> >  integer :: v (2, 3, 4)
> >  v (:, :, :) = 10
> >  v (2, 3, 4) = 20
> >  v (2, 3, 4) = 20 ! line 5
> > end
> > (gdb) b 5
> > (gdb) r
> > (gdb) p v(2,3,4)
> > no such vector element
> >
> > It works on archer-jankratochvil-vla
> > (gdb) p v(2,3,4)
> > $1 = 20
> > available at
> >        http://sourceware.org/gdb/wiki/ArcherBranchManagement
> > (or Fedora releases) but the support has some other problems and I
> should
> > merge it to FSF GDB soon.
> >
> >
> > Thanks,
> > Jan
> >


[-- Attachment #2: arrays.patch --]
[-- Type: application/octet-stream, Size: 3641 bytes --]

diff -rcp gdb-7.2-clean/gdb/ChangeLog gdb-7.2/gdb/ChangeLog
*** gdb-7.2-clean/gdb/ChangeLog	2010-09-03 00:37:25.000000000 +0100
--- gdb-7.2/gdb/ChangeLog	2010-09-07 22:58:01.229977481 +0100
***************
*** 1,3 ****
--- 1,13 ----
+ 2010-09-07 Andrew Burgess <aburgess@broadcom.com>
+ 
+ 	* valarith.c (value_subscripted_rvalue) Walk through
+ 	multi-dimensional arrays to find the element type for the
+ 	array. Allows the upper bound check to work with multi-dimensional
+ 	arrays.
+ 	* eval.c (evaluate_subexp_standard) Remove hack from
+ 	multi_f77_subscript case now that multi-dimensional arrays are
+ 	supported in valarith.c
+ 
  2010-09-02  Joel Brobecker  <brobecker@adacore.com>
  
  	* NEWS: Replace "Changes since GDB 7.1" by "Changes in GDB 7.2".
diff -rcp gdb-7.2-clean/gdb/eval.c gdb-7.2/gdb/eval.c
*** gdb-7.2-clean/gdb/eval.c	2010-07-07 17:15:15.000000000 +0100
--- gdb-7.2/gdb/eval.c	2010-09-07 22:44:31.493976944 +0100
*************** evaluate_subexp_standard (struct type *e
*** 2296,2311 ****
  
  	    subscript_array[nargs - i - 1] -= lower;
  
! 	    /* If we are at the bottom of a multidimensional 
! 	       array type then keep a ptr to the last ARRAY
! 	       type around for use when calling value_subscript()
! 	       below. This is done because we pretend to value_subscript
! 	       that we actually have a one-dimensional array 
! 	       of base element type that we apply a simple 
! 	       offset to. */
! 
! 	    if (i < nargs - 1)
! 	      tmp_type = check_typedef (TYPE_TARGET_TYPE (tmp_type));
  	  }
  
  	/* Now let us calculate the offset for this item */
--- 2296,2302 ----
  
  	    subscript_array[nargs - i - 1] -= lower;
  
! 	    tmp_type = check_typedef (TYPE_TARGET_TYPE (tmp_type));
  	  }
  
  	/* Now let us calculate the offset for this item */
*************** evaluate_subexp_standard (struct type *e
*** 2316,2329 ****
  	  offset_item =
  	    array_size_array[i - 1] * offset_item + subscript_array[i - 1];
  
- 	/* Let us now play a dirty trick: we will take arg1 
- 	   which is a value node pointing to the topmost level
- 	   of the multidimensional array-set and pretend
- 	   that it is actually a array of the final element 
- 	   type, this will ensure that value_subscript()
- 	   returns the correct type value */
- 
- 	deprecated_set_value_type (arg1, tmp_type);
  	return value_subscripted_rvalue (arg1, offset_item, 0);
        }
  
--- 2307,2312 ----
diff -rcp gdb-7.2-clean/gdb/valarith.c gdb-7.2/gdb/valarith.c
*** gdb-7.2-clean/gdb/valarith.c	2010-06-07 17:11:31.000000000 +0100
--- gdb-7.2/gdb/valarith.c	2010-09-07 22:52:25.154057798 +0100
*************** struct value *
*** 193,199 ****
  value_subscripted_rvalue (struct value *array, LONGEST index, int lowerbound)
  {
    struct type *array_type = check_typedef (value_type (array));
!   struct type *elt_type = check_typedef (TYPE_TARGET_TYPE (array_type));
    unsigned int elt_size = TYPE_LENGTH (elt_type);
    unsigned int elt_offs = elt_size * longest_to_int (index - lowerbound);
    struct value *v;
--- 193,208 ----
  value_subscripted_rvalue (struct value *array, LONGEST index, int lowerbound)
  {
    struct type *array_type = check_typedef (value_type (array));
!   struct type *elt_type = array_type; 
! 
!   /* Peel of the array indices until we reach the array element type */
!   do {
!     elt_type = TYPE_TARGET_TYPE(elt_type);
!   }
!   while ( TYPE_CODE(elt_type) == TYPE_CODE_ARRAY);
! 
!   elt_type = check_typedef(elt_type);
! 
    unsigned int elt_size = TYPE_LENGTH (elt_type);
    unsigned int elt_offs = elt_size * longest_to_int (index - lowerbound);
    struct value *v;

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

* Re: multidimensional fortran arrays
  2010-09-07 22:19     ` Andrew Burgess
@ 2010-09-09 16:37       ` Mathew Yeates
  2010-09-13 23:14         ` Mathew Yeates
  0 siblings, 1 reply; 8+ messages in thread
From: Mathew Yeates @ 2010-09-09 16:37 UTC (permalink / raw)
  To: Andrew Burgess; +Cc: Jan Kratochvil, gdb

Thanks Jan. This appears to work.

On Tue, Sep 7, 2010 at 3:19 PM, Andrew Burgess <aburgess@broadcom.com> wrote:
> The attached patch might fix the issue for you. It should apply cleanly to 7.2
>
> I'll write a test and submit to the patches list in a couple of days. Let me know if you run into any problems.
>
>
> Andrew
>
>
>
>> -----Original Message-----
>> From: gdb-owner@sourceware.org [mailto:gdb-owner@sourceware.org] On
>> Behalf Of Mathew Yeates
>> Sent: 07 September 2010 05:34
>> To: Jan Kratochvil
>> Cc: gdb@sourceware.org
>> Subject: Re: multidimensional fortran arrays
>>
>> gdb shouldn't claim to support gfortran until this  is fixed.
>> Seriously, I cant print the value of a multidimensional  array?
>>
>> On Thu, Sep 2, 2010 at 10:46 PM, Jan Kratochvil
>> <jan.kratochvil@redhat.com> wrote:
>> > On Thu, 02 Sep 2010 19:29:07 +0200, Mathew Yeates wrote:
>> >> I mentioned this before but got no reply. So I have been getting the
>> >> address of the array and using "x/f".
>> >> But now I am using 4 dimensional arrays and this is getting old.
>> >>
>> >> Anyone have any ideas how to fix this? print myarray(1,2) -> "so
>> such
>> >> vec element"
>> >
>> > For some reason it really does not work even for static arrays.
>> > program a
>> >  integer :: v (2, 3, 4)
>> >  v (:, :, :) = 10
>> >  v (2, 3, 4) = 20
>> >  v (2, 3, 4) = 20 ! line 5
>> > end
>> > (gdb) b 5
>> > (gdb) r
>> > (gdb) p v(2,3,4)
>> > no such vector element
>> >
>> > It works on archer-jankratochvil-vla
>> > (gdb) p v(2,3,4)
>> > $1 = 20
>> > available at
>> >        http://sourceware.org/gdb/wiki/ArcherBranchManagement
>> > (or Fedora releases) but the support has some other problems and I
>> should
>> > merge it to FSF GDB soon.
>> >
>> >
>> > Thanks,
>> > Jan
>> >
>
>


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

* Re: multidimensional fortran arrays
  2010-09-09 16:37       ` Mathew Yeates
@ 2010-09-13 23:14         ` Mathew Yeates
  2010-09-14  7:32           ` Andrew Burgess
  2010-09-15 17:45           ` Tom Tromey
  0 siblings, 2 replies; 8+ messages in thread
From: Mathew Yeates @ 2010-09-13 23:14 UTC (permalink / raw)
  To: Andrew Burgess; +Cc: Jan Kratochvil, gdb

uh oh. Doesn't seem to work for dimensions greater than 2.

-Mathew

On Thu, Sep 9, 2010 at 9:36 AM, Mathew Yeates <mat.yeates@gmail.com> wrote:
> Thanks Jan. This appears to work.
>
> On Tue, Sep 7, 2010 at 3:19 PM, Andrew Burgess <aburgess@broadcom.com> wrote:
>> The attached patch might fix the issue for you. It should apply cleanly to 7.2
>>
>> I'll write a test and submit to the patches list in a couple of days. Let me know if you run into any problems.
>>
>>
>> Andrew
>>
>>
>>
>>> -----Original Message-----
>>> From: gdb-owner@sourceware.org [mailto:gdb-owner@sourceware.org] On
>>> Behalf Of Mathew Yeates
>>> Sent: 07 September 2010 05:34
>>> To: Jan Kratochvil
>>> Cc: gdb@sourceware.org
>>> Subject: Re: multidimensional fortran arrays
>>>
>>> gdb shouldn't claim to support gfortran until this  is fixed.
>>> Seriously, I cant print the value of a multidimensional  array?
>>>
>>> On Thu, Sep 2, 2010 at 10:46 PM, Jan Kratochvil
>>> <jan.kratochvil@redhat.com> wrote:
>>> > On Thu, 02 Sep 2010 19:29:07 +0200, Mathew Yeates wrote:
>>> >> I mentioned this before but got no reply. So I have been getting the
>>> >> address of the array and using "x/f".
>>> >> But now I am using 4 dimensional arrays and this is getting old.
>>> >>
>>> >> Anyone have any ideas how to fix this? print myarray(1,2) -> "so
>>> such
>>> >> vec element"
>>> >
>>> > For some reason it really does not work even for static arrays.
>>> > program a
>>> >  integer :: v (2, 3, 4)
>>> >  v (:, :, :) = 10
>>> >  v (2, 3, 4) = 20
>>> >  v (2, 3, 4) = 20 ! line 5
>>> > end
>>> > (gdb) b 5
>>> > (gdb) r
>>> > (gdb) p v(2,3,4)
>>> > no such vector element
>>> >
>>> > It works on archer-jankratochvil-vla
>>> > (gdb) p v(2,3,4)
>>> > $1 = 20
>>> > available at
>>> >        http://sourceware.org/gdb/wiki/ArcherBranchManagement
>>> > (or Fedora releases) but the support has some other problems and I
>>> should
>>> > merge it to FSF GDB soon.
>>> >
>>> >
>>> > Thanks,
>>> > Jan
>>> >
>>
>>
>


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

* RE: multidimensional fortran arrays
  2010-09-13 23:14         ` Mathew Yeates
@ 2010-09-14  7:32           ` Andrew Burgess
  2010-09-15 17:45           ` Tom Tromey
  1 sibling, 0 replies; 8+ messages in thread
From: Andrew Burgess @ 2010-09-14  7:32 UTC (permalink / raw)
  To: Mathew Yeates; +Cc: Jan Kratochvil, gdb

> On Tue, Sep 14, 2010 at 00:14, Mathew Yeates <mat.yeates@gmail.com>
> 
> uh oh. Doesn't seem to work for dimensions greater than 2.

Could you attach a test program, steps to compile, and the gdb commands and output please.
The following test program:

program a
  integer :: foo1 (2)
  integer :: foo2 (2,3)
  integer :: foo3 (2,3,4)
  integer :: foo4 (2,3,4,5)
  integer :: foo5 (2,3,4,5,6)
  integer :: foo6 (2,3,4,5,6,7)
  foo1 (:) = 10
  foo2 (:, :) = 10
  foo3 (:, :, :) = 10
  foo4 (:, :, :, :) = 10
  foo5 (:, :, :, :, :) = 10
  foo6 (:, :, :, :, :, :) = 10
  foo1 (2) = 20
  foo2 (2,3) = 20
  foo3 (2,3,4) = 20
  foo4 (2,3,4,5) = 20
  foo5 (2,3,4,5,6) = 20
  foo6 (2,3,4,5,6,7) = 20
  foo1 (2) = 20 ! Stop on line 20
end

Behaves like this with a patched gdb:

Reading symbols from /home/andrew/gdb-bug/myprog.x...done.
(gdb) b 20
Breakpoint 1 at 0x8048847: file a.f90, line 20.
(gdb) r
Starting program: /home/andrew/gdb-bug/myprog.x 

Breakpoint 1, a () at a.f90:20
20	  foo1 (2) = 20 ! Stop on line 20
 (gdb) p foo6(2,3,4,5,6,7)
$3 = 20
(gdb) p foo1(2)
$4 = 20
(gdb)


So I suspect we're trying to do different things.

Cheers,

Andrew


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

* Re: multidimensional fortran arrays
  2010-09-13 23:14         ` Mathew Yeates
  2010-09-14  7:32           ` Andrew Burgess
@ 2010-09-15 17:45           ` Tom Tromey
  1 sibling, 0 replies; 8+ messages in thread
From: Tom Tromey @ 2010-09-15 17:45 UTC (permalink / raw)
  To: Mathew Yeates; +Cc: Andrew Burgess, Jan Kratochvil, gdb

>>>>> "Mathew" == Mathew Yeates <mat.yeates@gmail.com> writes:

Mathew> uh oh. Doesn't seem to work for dimensions greater than 2.

Please file bugs like this in bugzilla.
qIt is ideal if you can include a small(-ish) self-contained test case.

Tom


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

end of thread, other threads:[~2010-09-15 17:45 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-09-02 17:29 multidimensional fortran arrays Mathew Yeates
2010-09-03  5:47 ` Jan Kratochvil
2010-09-07  4:34   ` Mathew Yeates
2010-09-07 22:19     ` Andrew Burgess
2010-09-09 16:37       ` Mathew Yeates
2010-09-13 23:14         ` Mathew Yeates
2010-09-14  7:32           ` Andrew Burgess
2010-09-15 17:45           ` Tom Tromey

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox