Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: "Joseph S. Myers" <joseph@codesourcery.com>
To: gdb-patches@sourceware.org
Subject: Fix cross-endian DFP for GDB
Date: Fri, 27 Jun 2008 17:57:00 -0000	[thread overview]
Message-ID: <Pine.LNX.4.64.0806271739370.20407@digraph.polyomino.org.uk> (raw)

This patch fixes problems GDB has with decimal floating point when
host and target endianness differ.  decimal_convert failed to convert
endianness.  This patch fixes the following failures in a cross from
i686-pc-linux-gnu to powerpc-linux-gnu.  OK to commit?

FAIL: gdb.base/dfp-exprs.exp: p (_Decimal128) 3.7df
FAIL: gdb.base/dfp-test.exp: p d32=9.999999E96df
FAIL: gdb.base/dfp-test.exp: p d64=9.999999999999999E384dd
FAIL: gdb.base/dfp-test.exp: p d128=1.234567890123456789012345678901234dl
FAIL: gdb.base/dfp-test.exp: p d128=9.999999999999999999999999999999999E6144dl
FAIL: gdb.base/dfp-test.exp: 1.2345678901234567890123456789012345 is rounded to 1.234567890123456789012345678901234
FAIL: gdb.base/dfp-test.exp: print ds.dec128 = ds.dec32
FAIL: gdb.base/printcmds.exp: printf "%DDf\n",1.234567890123456789012345678901234dl
FAIL: gdb.base/printcmds.exp: printf "%DDf\n",-1.234567890123456789012345678901234dl
FAIL: gdb.base/printcmds.exp: printf "%DDf\n",1234567890123456789012345678901234.dl
FAIL: gdb.base/printcmds.exp: printf "%DDf\n",-1234567890123456789012345678901234.dl

2008-06-27  Joseph Myers  <joseph@codesourcery.com>

	* dfp.c (decimal_convert): Call match_endianness before and after
	conversion.

Index: dfp.c
===================================================================
RCS file: /cvs/src/src/gdb/dfp.c,v
retrieving revision 1.6
diff -u -p -r1.6 dfp.c
--- dfp.c	16 Jan 2008 16:16:44 -0000	1.6
+++ dfp.c	27 Jun 2008 17:27:20 -0000
@@ -395,7 +395,12 @@ decimal_convert (const gdb_byte *from, i
 		 int len_to)
 {
   decNumber number;
+  gdb_byte dec[16];
 
-  decimal_to_number (from, len_from, &number);
-  decimal_from_number (&number, to, len_to);
+  match_endianness (from, len_from, dec);
+
+  decimal_to_number (dec, len_from, &number);
+  decimal_from_number (&number, dec, len_to);
+
+  match_endianness (dec, len_to, to);
 }

-- 
Joseph S. Myers
joseph@codesourcery.com


             reply	other threads:[~2008-06-27 17:41 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-06-27 17:57 Joseph S. Myers [this message]
2008-06-27 18:18 ` Daniel Jacobowitz
2008-06-27 20:45   ` Joseph S. Myers
2008-06-27 20:47     ` Daniel Jacobowitz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Pine.LNX.4.64.0806271739370.20407@digraph.polyomino.org.uk \
    --to=joseph@codesourcery.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox