Fix cross-endian DFP for GDB
Joseph S. Myers
joseph@codesourcery.com
Fri Jun 27 17:57:00 GMT 2008
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
More information about the Gdb-patches
mailing list