How to print fortran allocatable array in GDB?

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

How to print fortran allocatable array in GDB?

孔涛
Hi, everyone. How to print fortran allocatable array in GDB?  For example, the source file reads
--
program main
implicit none
real,dimension(5) :: a
real,dimension(:),allocatable :: b

allocate(b(10) )

call random_number(a)
call random_number(b)

deallocate(b)
end program

--
I use 'gfortran -g arr.f90 ' and use 'gdb ./a.exe' Then I got the following debug info
---------------------------------
(gdb) b 6
(gdb) b 10
(gdb) r
Starting program: D:\Documents\Projects\test/a.exe

[New Thread 6844.0x1a40]

Breakpoint 1, MAIN__ () at array.f90:6
6       allocate(b(10) )
(gdb) p a
$8 = (3.76478451e-039, 1.54142831e-044, 1.03794626e-038, -nan(0x7ffffe), 0)
(gdb) p b
$9 = (0)

(gdb) c
Continuing.

Breakpoint 2, MAIN__ () at array.f90:11
11      deallocate(b)
(gdb) p a
$10 = (0.997559547, 0.566824675, 0.965915322, 0.747927666, 0.367390871)
(gdb) p b
$11 = (0)

(gdb)
----------------------------------------
So why? How to show the variable b?




--
Have a nice day!

Kayneo

----
I saw, I came, I conquered!



------------------------------------------------------------------------------
Slashdot TV.  
Video for Nerds.  Stuff that matters.
http://tv.slashdot.org/
_______________________________________________
MinGW-users mailing list
[hidden email]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Also: mailto:[hidden email]?subject=unsubscribe
Reply | Threaded
Open this post in threaded view
|

Re: How to print fortran allocatable array in GDB?

Eli Zaretskii
> Date: Sat, 23 Aug 2014 10:32:14 +0800 (CST)
> From: 孔涛 <[hidden email]>
>
> How to print fortran allocatable array in GDB?

I suggest to post this question to the GDB list, [hidden email].
I see nothing MinGW-specific in your question.

One general comment:

> I use 'gfortran -g arr.f90 '

I suggest to always use -g3, to get the best debug info.  Some GDB
features are not available without -g3.

Also, when you post to the GDB list, please mention the version of
your gfortran compiler and the version of GDB you are using.  This
might be important to answer your questions quickly and accurately.



------------------------------------------------------------------------------
Slashdot TV.  
Video for Nerds.  Stuff that matters.
http://tv.slashdot.org/
_______________________________________________
MinGW-users mailing list
[hidden email]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Also: mailto:[hidden email]?subject=unsubscribe
Reply | Threaded
Open this post in threaded view
|

Re: How to print fortran allocatable array in GDB?

孔涛
Sorry! The compiler and gdb are the newest default ones in Ubuntu, cygwin, and MinGW
In mingw32: gfortran 4.8.1 and gdb 7.6.1.
in cygwin64:gfortran 4.8.3 and gdb 7.8. 
Both of the above  are on Windows 8.1 64-bit platform.

I used the method you suggest, i.e. add -g3 instead of -g, but get the same result.
In Cygwin, get: "Unhandled dwarf expression opcode 0x97"
in MinGW, get: " $2 = (0)"
in both case, whatis command cat get the type is "real(kind=8)"

But on my server, centos 6.3 with gcc 4.7.0 and gdb 7.2. It works well, it can show the allocatable array's contents.

How to show them in cygwin and mingw?







--
Have a nice day!

Kayneo

----
I saw, I came, I conquered!


在 2014-08-23 03:37:40,"Eli Zaretskii" <[hidden email]> 写道: >> Date: Sat, 23 Aug 2014 10:32:14 +0800 (CST) >> From: 孔涛 <[hidden email]> >> >> How to print fortran allocatable array in GDB? > >I suggest to post this question to the GDB list, [hidden email]. >I see nothing MinGW-specific in your question. > >One general comment: > >> I use 'gfortran -g arr.f90 ' > >I suggest to always use -g3, to get the best debug info. Some GDB >features are not available without -g3. > >Also, when you post to the GDB list, please mention the version of >your gfortran compiler and the version of GDB you are using. This >might be important to answer your questions quickly and accurately. > > > >------------------------------------------------------------------------------ >Slashdot TV. >Video for Nerds. Stuff that matters. >http://tv.slashdot.org/ >_______________________________________________ >MinGW-users mailing list >[hidden email] > >This list observes the Etiquette found at >http://www.mingw.org/Mailing_Lists. >We ask that you be polite and do the same. Disregard for the list etiquette may cause your account to be moderated. > >_______________________________________________ >You may change your MinGW Account Options or unsubscribe at: >https://lists.sourceforge.net/lists/listinfo/mingw-users >Also: mailto:[hidden email]?subject=unsubscribe



------------------------------------------------------------------------------
Slashdot TV.  
Video for Nerds.  Stuff that matters.
http://tv.slashdot.org/
_______________________________________________
MinGW-users mailing list
[hidden email]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Also: mailto:[hidden email]?subject=unsubscribe
Reply | Threaded
Open this post in threaded view
|

Re: How to print fortran allocatable array in GDB?

Eli Zaretskii
> Date: Sat, 23 Aug 2014 19:54:16 +0800 (CST)
> From: 孔涛 <[hidden email]>
>
> Sorry! The compiler and gdb are the newest default ones in Ubuntu, cygwin, and MinGW
> In mingw32: gfortran 4.8.1 and gdb 7.6.1.
> in cygwin64:gfortran 4.8.3 and gdb 7.8.
> Both of the above  are on Windows 8.1 64-bit platform.
>
> I used the method you suggest, i.e. add -g3 instead of -g, but get the same result.
> In Cygwin, get: "Unhandled dwarf expression opcode 0x97"
> in MinGW, get: " $2 = (0)"
> in both case, whatis command cat get the type is "real(kind=8)"
>
> But on my server, centos 6.3 with gcc 4.7.0 and gdb 7.2. It works well, it can show the allocatable array's contents.
>
> How to show them in cygwin and mingw?

Like I said: this question should be sent to the GDB list,
[hidden email].  There you will certainly get your answer.


------------------------------------------------------------------------------
Slashdot TV.  
Video for Nerds.  Stuff that matters.
http://tv.slashdot.org/
_______________________________________________
MinGW-users mailing list
[hidden email]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Also: mailto:[hidden email]?subject=unsubscribe
Reply | Threaded
Open this post in threaded view
|

Re: How to print fortran allocatable array in GDB?

xunxun
In reply to this post by 孔涛
于 2014/8/23 10:32, 孔涛 写道:
Hi, everyone. How to print fortran allocatable array in GDB?  For example, the source file reads
--
program main
implicit none
real,dimension(5) :: a
real,dimension(:),allocatable :: b

allocate(b(10) )

call random_number(a)
call random_number(b)

deallocate(b)
end program

--
I use 'gfortran -g arr.f90 ' and use 'gdb ./a.exe' Then I got the following debug info
---------------------------------
(gdb) b 6
(gdb) b 10
(gdb) r
Starting program: D:\Documents\Projects\test/a.exe

[New Thread 6844.0x1a40]

Breakpoint 1, MAIN__ () at array.f90:6
6       allocate(b(10) )
(gdb) p a
$8 = (3.76478451e-039, 1.54142831e-044, 1.03794626e-038, -nan(0x7ffffe), 0)
(gdb) p b
$9 = (0)

(gdb) c
Continuing.

Breakpoint 2, MAIN__ () at array.f90:11
11      deallocate(b)
(gdb) p a
$10 = (0.997559547, 0.566824675, 0.965915322, 0.747927666, 0.367390871)
(gdb) p b
$11 = (0)

(gdb)
----------------------------------------
So why? How to show the variable b?




--
Have a nice day!

Kayneo

----
I saw, I came, I conquered!


You should use archer gdb, which support fortran dynamic array.


-- 
Best Regards,
xunxun

------------------------------------------------------------------------------
Slashdot TV.  
Video for Nerds.  Stuff that matters.
http://tv.slashdot.org/
_______________________________________________
MinGW-users mailing list
[hidden email]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Also: mailto:[hidden email]?subject=unsubscribe
Reply | Threaded
Open this post in threaded view
|

Re: How to print fortran allocatable array in GDB?

xcmdos
This post has NOT been accepted by the mailing list yet.
where  can i down  archer gdb