Subject: port-i386/17927: gdb messes up fp reisters
To: None <gnats-bugs@gnats.netbsd.org>
From: None <toshii@netbsd.org>
List: netbsd-bugs
Date: 08/13/2002 16:35:11
>Number:         17927
>Category:       port-i386
>Synopsis:       gdb messes up fp registers
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    port-i386-maintainer
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Aug 13 00:36:00 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator:     IWAMOTO Toshihiro
>Release:        NetBSD 1.6_BETA4
>Organization:
	
>Environment:
System: NetBSD kiku.my.domain 1.6_BETA4 NetBSD 1.6_BETA4 (KIKU) #127: Wed Jul 24 12:03:28 JST 2002 toshii@kiku.my.domain:/usr/src/syssrc/sys/arch/i386/compile/KIKU i386
Architecture: i386
Machine: i386
 cpu0: Intel Celeron (Mendocino) (686-class), 434.35 MHz
 cpu0: I-cache 16 KB 32b/line 4-way, D-cache 16 KB 32b/line 2-way
 cpu0: L2 cache 128 KB 32b/line 4-way
 cpu0: features 183f9ff<FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,SEP,MTRR>
 cpu0: features 183f9ff<PGE,MCA,CMOV,FGPAT,PSE36,MMX>
 cpu0: features 183f9ff<FXSR>
>Description:
	Trying to debug programs with gdb usually corrupts their floting-point
	variables.
>How-To-Repeat:
	$ cc -O2 -g a.c
	$ gdb a.out
	
	GNU gdb 5.0nb1
	Copyright 2000 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 "i386--netbsdelf"...
	(gdb) li
	1       #include <stdio.h>
	2
	3       int f(double);
	4
	5       int main() {
	6               double a = 0.0;
	7               double b = 0.1;
	8               double c = 0.2;
	9               double d = 0.3;
	10
	(gdb)
	11              for(;;) {
	12                      a = a + 1.0;
	13                      b = b + 1.0;
	14                      c = c + b;
	15                      d = b + c;
	16                      f(d);
	17              }
	18      }
	19
	20      int
	(gdb)
	21      f(double a) {
	22              printf("%f\n", a);
	23      }
	(gdb) br 16
	Breakpoint 1 at 0x8048922: file a.c, line 16.
	(gdb) run
	Starting program: /tmp/a.out

	Breakpoint 1, main () at a.c:16
	16                      f(d);
	(gdb) c
	Continuing.
	nan

	Breakpoint 1, main () at a.c:16
	16                      f(d);
	(gdb)

	If the program is run without a breakpoint, or compiled without "-O2",
	it gives correct results.
>Fix:
	I don't like to do by myself.
>Release-Note:
>Audit-Trail:
>Unformatted: