|
From: | lylelyle |
Subject: | RE: Can't Print Two Dimensional Array Element for Fortran |
Date: | Sun, 25 Apr 2010 13:34:55 -0500 |
Setting language to c works. Yes, the subscript numbers are a little bit wired: the row number is from 0, and the column number is from 1. This doesn't like C or Fortran. Thanks, Lyle > Date: Sat, 24 Apr 2010 04:08:18 +0200 > From: address@hidden > To: address@hidden > CC: address@hidden > Subject: Re: Can't Print Two Dimensional Array Element for Fortran > > 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 Hotmail: 免费、可靠、丰富的电子邮件服务。 立即获取。 |
[Prev in Thread] | Current Thread | [Next in Thread] |