Problem printing expressions in gdb on linux/alpha.

Harvey J. Stein hjstein@bfr.co.il
Thu Mar 25 00:36:00 GMT 1999


gdb is printing expressions incorrectly on linux running on an alpha.
This is a Redhat 5.2 setup.  I suppose it could be a gcc bug or it
could be a gdb bug, so I'm reporting to both addresses.

Here's the program:

[hjstein@dp264 hjstein]$ cat gdbug.c
typedef double doublereal;

int main(void)
{
    doublereal d;
    doublereal stripytm;

    stripytm= (float).0464208987;
    d = stripytm * .5 + 1.;
    return(0);
} /* MAIN__ */


Here's the failure:

   [hjstein@dp264 hjstein]$ cc -g    gdbug.c   -o gdbug
   [hjstein@dp264 hjstein]$ gdb gdbug
   GNU gdb 4.17.0.4 with Linux/x86 hardware watchpoint and FPU support
   Copyright 1998 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 "alpha-redhat-linux"...
   (gdb) b 10
   Breakpoint 1 at 0x1200006bc: file gdbug.c, line 10.
   (gdb) r
   Starting program: /home/hjstein/gdbug 

   Breakpoint 1, main () at gdbug.c:10
   10	    return(0);
   (gdb) p d
   $1 = 1.0232104491442442
   (gdb) p stripytm * .5 + 1.
   $2 = 1
   (gdb) quit
   The program is running.  Exit anyway? (y or n) y

Note that d = stripytm * .5 + 1. in the program, but printing:
   stripytm * .5 + 1.
displays 1 instead of the correct value.

Here's the program (gdbug.c), along with the gcc -s output (gdbug.s,
in case it's a stabs generation error) & the preprocessor output
(gdbug.cpp), tarred, gzipped & uuencoded:

begin 644 gdbug.tar.gz
M'XL(`"?U^38``^U8W8^C-A#?U_!76&D>DFU";`/&!.6AM[J>*MW>6Y\C$KPL
M+8$<D-.>JO[OG3&0KR.[?;C=JB?_(CYL_V:8&<\8DR1>[Y-Y@F=[<_,Z8)0*
MUR4WA!!?>/K*VK8&%X(0(7SA^,QC'HQRU_-O"'TE>\ZPK^JH).3F\8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D`J]7?!`&@]P<UTVS8\Z=.)2#$?N
M!<;N?1,[OY?APQ#FC=8.\Z</1T?Q?()U^V2"P9O/>C(Q)U``=NK:($@I,9DV
M:1<W:=>5I$Z_7]EPZ@B=GF>#\8+3KD2]Z8R)XX+<?AN<$,1T)JW6&Q;P=LL`
M:=)U<NYVG>^Q3-,8BF`P_'!WMR#C#Y]^GQ"5;*H9MP-J\X`$DN*F<ZP[H0!M
M![X\,A55:C+\\3\T3O?_F]WN59[QXO>_S[K]/W<9?`LPAS+/[/_?`C^1TZW_
G_^7?`&+^`C`P,#`P,#`P,#`P,#`P,#`P,#`P>`'_`"*O8:8`*```
`
end


Version info:
   [hjstein@dp264 hjstein]$ uname -a
   Linux dp264 2.2.3-ac4 #1 SMP Wed Mar 24 11:26:44 EST 1999 alpha unknown

   [hjstein@dp264 hjstein]$ rpm -q gdb
   gdb-4.17.0.4-3
   [hjstein@dp264 hjstein]$ gdb -v
   GNU gdb 4.17.0.4 with Linux/x86 hardware watchpoint and FPU support
   Copyright 1998 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 "alpha-redhat-linux".

   [hjstein@dp264 hjstein]$ type cc
   cc is hashed (/usr/bin/cc)
   [hjstein@dp264 hjstein]$ cc --version
   egcs-2.90.29 980515 (egcs-1.0.3 release)
   [hjstein@dp264 hjstein]$ ls -l /usr/bin/cc
   lrwxrwxrwx   1 root     root            3 Dec  4  2026 /usr/bin/cc -> gcc
   [hjstein@dp264 hjstein]$ cc -v
   Reading specs from /usr/lib/gcc-lib/alpha-redhat-linux/egcs-2.90.29/specs
   gcc version egcs-2.90.29 980515 (egcs-1.0.3 release)
   [hjstein@dp264 hjstein]$ rpm -q egcs
   egcs-1.0.3a-14
   [hjstein@dp264 hjstein]$ rpm -qf /usr/bin/gcc
   egcs-1.0.3a-14

   [hjstein@dp264 hjstein]$ rpm -q glibc
   glibc-2.0.7-29
   [hjstein@dp264 hjstein]$ rpm -qf /lib/libc-2.0.7.so 
   glibc-2.0.7-29
   [hjstein@dp264 hjstein]$ rpm -qf /lib/libc.so.6.1
   glibc-2.0.7-29
   [hjstein@dp264 hjstein]$ ls -l /lib/libc*
   -rwxr-xr-x   1 root     root      4462177 Oct 12 22:18 /lib/libc-2.0.7.so
   lrwxrwxrwx   1 root     root           13 Dec  4  2026 /lib/libc.so.6.1 -> libc-2.0.7.so
   lrwxrwxrwx   1 root     root           17 Dec  4  2026 /lib/libcom_err.so.2 -> libcom_err.so.2.0
   -rwxr-xr-x   1 root     root        10612 Aug 28  1998 /lib/libcom_err.so.2.0
   -rwxr-xr-x   1 root     root       215172 Oct 12 22:22 /lib/libcrypt-2.0.7.so
   lrwxrwxrwx   1 root     root           17 Dec  4  2026 /lib/libcrypt.so.1.1 -> libcrypt-2.0.7.so

   [hjstein@dp264 hjstein]$ cat /proc/cpuinfo
   cpu                     : Alpha
   cpu model               : EV6
   cpu variation           : 7
   cpu revision            : 0
   cpu serial number       :
   system type             : Tsunami
   system variation        : DP264
   system revision         : 0
   system serial number    :
   cycle frequency [Hz]    : 500000000
   timer frequency [Hz]    : 1024.00
   page size [bytes]       : 8192
   phys. address bits      : 44
   max. addr. space #      : 255
   BogoMIPS                : 996.14
   kernel unaligned acc    : 0 (pc=0,va=0)
   user unaligned acc      : 1 (pc=200001203e8,va=11ff583bc)
   platform string         : AlphaPC 264DP 500 MHz
   CPUs probed 2 active 2 map 0x3 IPIs 4663211


More information about the Gcc mailing list