* display character strings in fortran
@ 2009-06-10 11:34 kamaraju kusumanchi
2009-06-10 11:50 ` Arjen Markus
0 siblings, 1 reply; 4+ messages in thread
From: kamaraju kusumanchi @ 2009-06-10 11:34 UTC (permalink / raw)
To: gdb; +Cc: fortran
Consider the following code. (This is a reduced version of a large
code that I am working with.)
$cat char_string.f90
program string_size
implicit none
character (len=20) :: first_name
write(first_name, *) 'kamaraju'
write(*,*) first_name
end program string_size
The program compiles and runs fine.
$gfortran -g char_string.f90
$./a.out
kamaraju
However, when debugged, the character strings are not displayed properly.
$gdb ./a.out
Using host libthread_db library "/lib/i686/cmov/libthread_db.so.1".
(gdb) b char_string.f90:5
Breakpoint 1 at 0x8048620: file char_string.f90, line 5.
(gdb) r
Starting program: /home/rajulocal/work/fortran/a.out
Breakpoint 1, string_size () at char_string.f90:5
5 write(*,*) first_name
Current language: auto; currently fortran
(gdb) p first_name
$1 = (32 ' ', 107 'k', 97 'a', 109 'm', 97 'a', 114 'r', 97 'a', 106
'j', 117 'u', 32 ' ', 32 ' ', 32 ' ', 32 ' ', 32 ' ', 32 ' ', 32 ' ',
32 ' ', 32 ' ', 32 ' ', 32 ' ')
(gdb) quit
The program is running. Exit anyway? (y or n) y
I am using a Debian Etch machine running
$gfortran -v
Using built-in specs.
Target: i486-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Debian
4.3.2-1.1' --with-bugurl=file:///usr/share/doc/gcc-4.3/README.Bugs
--enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr
--enable-shared --with-system-zlib --libexecdir=/usr/lib
--without-included-gettext --enable-threads=posix --enable-nls
--with-gxx-include-dir=/usr/include/c++/4.3 --program-suffix=-4.3
--enable-clocale=gnu --enable-libstdcxx-debug --enable-objc-gc
--enable-mpfr --enable-targets=all --enable-cld
--enable-checking=release --build=i486-linux-gnu --host=i486-linux-gnu
--target=i486-linux-gnu
Thread model: posix
gcc version 4.3.2 (Debian 4.3.2-1.1)
$gdb -v
GNU gdb 6.4.90-debian
Copyright (C) 2006 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "i486-linux-gnu".
Is this a bug in gdb or gfortran? I appreciate if you could fix it.
thanks
raju
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: display character strings in fortran
2009-06-10 11:34 display character strings in fortran kamaraju kusumanchi
@ 2009-06-10 11:50 ` Arjen Markus
0 siblings, 0 replies; 4+ messages in thread
From: Arjen Markus @ 2009-06-10 11:50 UTC (permalink / raw)
To: kamaraju kusumanchi; +Cc: gdb, fortran
With the p command in gdb you print via the debugger - that is
something completely
different than writing/printing a variable's value in the Fortran
program. What you see
is simply the debugger's way of looking at (Fortran) strings.
Regards,
Arjen
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: display character strings in fortran
2009-06-10 11:56 Tobias Burnus
@ 2009-06-10 12:19 ` kamaraju kusumanchi
0 siblings, 0 replies; 4+ messages in thread
From: kamaraju kusumanchi @ 2009-06-10 12:19 UTC (permalink / raw)
To: Tobias Burnus; +Cc: fortran, gdb
On Wed, Jun 10, 2009 at 7:56 AM, Tobias Burnus<burnus@net-b.de> wrote:
> kamaraju kusumanchi wrote:
>> However, when debugged, the character strings are not displayed properly.
>> [...]
>> (gdb) p first_name
>> $1 = (32 ' ', 107 'k', 97 'a', 109 'm', 97 'a', 114 'r', 97 'a', 106
>> 'j', 117 'u', 32 ' ', 32 ' ', 32 ' ', 32 ' ', 32 ' ', 32 ' ', 32 ' ',
>> 32 ' ', 32 ' ', 32 ' ', 32 ' ')
>> [...]
>> gcc version 4.3.2 (Debian 4.3.2-1.1)
>
>> Is this a bug in gdb or gfortran? I appreciate if you could fix it.
>
> The GCC bug was fixed about half a year ago. Please use GCC 4.4.0 (which
> was released April 21, 2009) or later. Using GCC 4.4.x, one gets:
>
> (gdb) p first_name
> $1 = ' kamaraju', ' ' <repeats 11 times>
>
> Tobias
>
Upgraded my gfortran to
$gfortran-4.4 -v
Using built-in specs.
Target: i486-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Debian
4.4.0-5' --with-bugurl=file:///usr/share/doc/gcc-4.4/README.Bugs
--enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr
--enable-shared --enable-multiarch --with-system-zlib
--libexecdir=/usr/lib --without-included-gettext
--enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.4
--program-suffix=-4.4 --enable-nls --enable-clocale=gnu
--enable-libstdcxx-debug --enable-mpfr --enable-objc-gc
--enable-targets=all --with-arch-32=i486 --with-tune=generic
--enable-checking=release --build=i486-linux-gnu --host=i486-linux-gnu
--target=i486-linux-gnu
Thread model: posix
gcc version 4.4.0 (Debian 4.4.0-5)
Now it works as intended.
thanks for the quick replies
raju
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: display character strings in fortran
@ 2009-06-10 11:56 Tobias Burnus
2009-06-10 12:19 ` kamaraju kusumanchi
0 siblings, 1 reply; 4+ messages in thread
From: Tobias Burnus @ 2009-06-10 11:56 UTC (permalink / raw)
To: fortran, gdb
kamaraju kusumanchi wrote:
> However, when debugged, the character strings are not displayed properly.
> [...]
> (gdb) p first_name
> $1 = (32 ' ', 107 'k', 97 'a', 109 'm', 97 'a', 114 'r', 97 'a', 106
> 'j', 117 'u', 32 ' ', 32 ' ', 32 ' ', 32 ' ', 32 ' ', 32 ' ', 32 ' ',
> 32 ' ', 32 ' ', 32 ' ', 32 ' ')
> [...]
> gcc version 4.3.2 (Debian 4.3.2-1.1)
> Is this a bug in gdb or gfortran? I appreciate if you could fix it.
The GCC bug was fixed about half a year ago. Please use GCC 4.4.0 (which
was released April 21, 2009) or later. Using GCC 4.4.x, one gets:
(gdb) p first_name
$1 = ' kamaraju', ' ' <repeats 11 times>
Tobias
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2009-06-10 12:19 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-06-10 11:34 display character strings in fortran kamaraju kusumanchi
2009-06-10 11:50 ` Arjen Markus
2009-06-10 11:56 Tobias Burnus
2009-06-10 12:19 ` kamaraju kusumanchi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox