[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Can't Print Two Dimensional Array Element for Fortran
From: |
Ingo Krabbe |
Subject: |
Re: Can't Print Two Dimensional Array Element for Fortran |
Date: |
Sat, 24 Apr 2010 04:08:18 +0200 |
User-agent: |
Mutt/1.5.20 (2009-06-14) |
On Fri, Apr 23, 2010 at 08:22:40PM -0500, lylelyle wrote:
>
> No, I can't do this in gdb.
>
> (gdb) print a(4)
> Wrong number of subscripts
>
> (gdb) print a(6,1)
> no such vector element
>
> lyle
>
I'm, quite sorry. As gdb relies on language features, you might either examine
the memory directly (calculating the address by hand):
(showing the second step):
(gdb) x/5f &a
0x7fffffffd360: 1 0 -9.05608908e+33 4.59163468e-41
0x7fffffffd370: -4.65473378e+33
(gdb) x/5f 0x7fffffffd374
0x7fffffffd374: 2 0 0 -nan(0x7fd4c8)
0x7fffffffd384: 4.59163468e-41
or more convenient switch the language to C: be carefull: the colummn numbers
are calculated from 1 up, as the first element a[0][0] is skipped internally.
I once knew why, but I can't remember why.
(gdb) set language c
(gdb) p a
$32 = {{1, 4, -9.05608908e+33, 4.59163468e-41, -4.65473378e+33}, {2, 5, 0,
-nan(0x7fd4c8), 4.59163468e-41}, {3, 6, 1.40129846e-45, 0, -4.65251539e+33}}
(gdb) p a[2][2]
$33 = 6
of course you can always get back to fortran again:
(gdb) set language fortran
(gdb) p a
$36 = (( 1, 4, -9.05608908e+33, 4.59163468e-41, -4.65473378e+33) ( 2, 5, 0,
-nan(0x7fd4c8), 4.59163468e-41) ( 3, 6, 1.40129846e-45, 0, -4.65251539e+33) )
bye ingo