delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/2000/04/12/06:18:33

Date: Wed, 12 Apr 2000 10:19:54 +0200 (IST)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
X-Sender: eliz AT is
To: Pierre Muller <muller AT cerbere DOT u-strasbg DOT fr>
cc: djgpp-workers AT delorie DOT com
Subject: Re: One more GDB for DJGPP little oddity
In-Reply-To: <200004071340.PAA16017@cerbere.u-strasbg.fr>
Message-ID: <Pine.SUN.3.91.1000412101930.16084N-100000@is>
MIME-Version: 1.0
Reply-To: djgpp-workers AT delorie DOT com
Errors-To: nobody AT delorie DOT com
X-Mailing-List: djgpp-workers AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

On Fri, 7 Apr 2000, Pierre Muller wrote:

>    if I have a long double var named x of value 1e+4893
> if I print it out
> 
>   "p x"
> I get
>   " 1e+4893"
> 
>   but once loaded onto FPU stack 
> I get +Inf on the right part of the display !

I think the following patch fixes this.  The patch can only be applied
to snapshots of GDB 5.0 (however, GDB 4.18 doesn't have the bug in the
first place).

2000-04-11  Eli Zaretskii  <eliz AT is DOT elta DOT co DOT il>

	* i387-tdep.c (print_i387_value): If the target long double type
	is supported and is wider than REGISTER_RAW_SIZE, widen the
	argument to the full size of the long double.  Call
	extract_floating instead of floatformat_to_doublest, to avoid
	losing precision or printing Inf for numbers that cannot be
	adequately represented by a double.

--- gdb/i387-tdep.c~0	Sat Apr  1 19:06:54 2000
+++ gdb/i387-tdep.c	Tue Apr 11 22:56:46 2000
@@ -161,14 +161,22 @@ print_387_status_word (status)
 /* Implement the `info float' layout based on the register definitions
    in `tm-i386.h'.  */
 
+#if defined(TARGET_LONG_DOUBLE_BIT) && (TARGET_LONG_DOUBLE_BIT / TARGET_CHAR_BIT) > REGISTER_RAW_SIZE
+# define TARGET_RAW_SIZE (TARGET_LONG_DOUBLE_BIT / TARGET_CHAR_BIT)
+#else
+# define TARGET_RAW_SIZE REGISTER_RAW_SIZE
+#endif
+
 /* Print the floating point number specified by RAW.  */
 static void
-print_i387_value (char *raw)
+print_i387_value (unsigned char *raw)
 {
   DOUBLEST value;
-  
-  floatformat_to_doublest (&floatformat_i387_ext, raw, &value);
+  unsigned char target_raw[TARGET_RAW_SIZE];
 
+  memcpy (target_raw, raw, TARGET_RAW_SIZE);
+  value = extract_floating (target_raw, TARGET_RAW_SIZE);
+  
   /* We try to print 19 digits.  The last digit may or may not contain
      garbage, but we'd better print one too many.  We need enough room
      to print the value, 1 position for the sign, 1 for the decimal

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019